# GET - Reading Rows

After importing the spreadsheet you will have access to the GET method which allows you to read, filter and query the data from the sheet. Simple request to this endpoint will return the content of the entire spreadsheet. Querying and filtering can be done by sending additional query paramaters that are documented below.

The following example shows how to read the data from the spreadsheet by sending a simple HTTP request.

# Replace SHEET_ID with your spreadsheet id
curl -X GET \
  "https://sheetrest.com/api/v1/SHEET_ID"
// Replace SHEET_ID with your spreadsheet id
fetch('https://sheetrest.com/api/v1/SHEET_ID', {
  method: 'GET',
  headers: {
    accept: 'application/json',
  },
});

# Querying Data

Querying gives you even more flexibility in retrievnig the data by giving additional operators to perform logical operations and select rows based on the values in the spreadsheet. You can send various filters to the GET request to your spreadsheet. For example:

# Replace SHEET_ID with your spreadsheet id
curl -X GET \
  "https://sheetrest.com/api/v1/SHEET_ID?Name=John&Age=__gt(30)"

# Filtering string values

The most basic filtering option is filtering by the column value, which can be done by passing a simple search query like {COLUMN_NAME}={SEARCH_PATTERN}. Column name must be valid and exist inside the sheet. And the search pattern can either be a direct string or a wildcard where * replaces any value. For example, if you want to filter rows by the Name column, you'd use the following query string, which will return you all the rows where the Name column is equal to John.

curl -X GET \
  "https://sheetrest.com/api/v1/SHEET_ID?Name=John"

Wildcards allow you to configure more complex queries. For example, if you want to filter the data by the Name column in a more flexible way, like retrieving all the rows where Name starts with Mr, you'd use the following query string:

curl -X GET \
  "https://sheetrest.com/api/v1/SHEET_ID/query?Name=Mr*"

# Additional operators

Operators are included in the query using the special syntax, operator name is preceded by the __ sign, followed by the operator name with value in the braces. For example, equality operator by the name of eq is used as __eq({value}). The list of available operators is available in the table below:

Operator Description Example
eq Equal to __eq(John)
ne Not equal to __ne(John)
gt Greater than __gt(30)
ge Greater than or equal to __ge(30)
lt Less than __lt(30)
le Less than or equal to __le(30)

# Examples

Let's say you have a spreadsheet with the following data:

Name Age City
John 30 New York
Jane 25 Los Angeles
John 40 Chicago
Alex 19 New Jersey
Kate 30 New York
Ilya 39 New York
Vova 42 DC

If you want to query all people with the name John and the age greater than 30, you'd use the following query string:

curl -X GET \
  "https://sheetrest.com/api/v1/SHEET_ID?Name=__eq(John)&Age=__gt(30)"

Which will give you the following JSON:

[
  {
    "Name": "John",
    "Age": 40,
    "City": "Chicago"
  }
]

If you want to query all the people with the age lower or equal to 30, you'd use the following query string:

curl -X GET \
  "https://sheetrest.com/api/v1/SHEET_ID?Age=__le(30)"

Which will give you the following JSON:

[
  {
    "Name": "John",
    "Age": 30,
    "City": "New York"
  },
  {
    "Name": "Jane",
    "Age": 25,
    "City": "Los Angeles"
  },
  {
    "Name": "Alex",
    "Age": 19,
    "City": "New Jersey"
  },
  {
    "Name": "Kate",
    "Age": 30,
    "City": "New York"
  }
]