Read
Get content
Returns an array with all data from the spreadsheet.
Optional attributes
- Name
sheet
- Type
- string
- Description
The sheet (tab) you want to select.
- Name
limit
- Type
- integer
- Description
Limit the number of rows returned.
- Name
offset
- Type
- integer
- Description
Which result to start with (how many results to skip).
- Name
sort_by
- Type
- string
- Description
The name of the column by which you want to sort the results.
- Name
sort_order
- Type
- string
- Description
Sort order. You can choose:
asc
- sort in ascending orderdesc
- sort in descending orderrandom
- get data in random order
- Name
sort_method
- Type
- string
- Description
If you want to sort by date, set this attribute to
date
, SheetDB will try to automatically detect the data format but it is recommended to specify the format in thesort_date_format
attribute.
- Name
sort_date_format
- Type
- string
- Description
Date format, e.g. if your date is 2022-19-12 use
Y-m-d
. For date time like 2022-19-12 13:55:00 useY-m-d H:i:s
.
Applies only when sort_method=date.
- Name
cast_numbers
- Type
- string
- Description
If you want to cast a value into a number, use its column name here. You can use multiple column names separated by commas.
Example: https://sheetdb.io/api/v1/58f61be4dda40?cast_numbers=id,age
- Name
single_object
- Type
- boolean
- Description
If you want to get only one row as an object (not in an array), set this attribute to
true
.
- Name
mode
- Type
- string
- Description
Value Render Option, more info here.
Request
# Sort results by id in descending order, take two
# and return the age as an integer.
curl -G https://sheetdb.io/api/v1/58f61be4dda40 \
-d sort_by=id \
-d sort_order=desc \
-d limit=2 \
-d cast_numbers=age
JSON Response
[
{
"id": "5",
"name": "James",
"age": 19,
"comment": ""
},
{
"id": "4",
"name": "Steve",
"age": 22,
"comment": "special"
}
]
Keys
Returns an array with all column names. It's all the cells from the first row.
Request
# Sort results by id in descending order, take two
# and return the age as an integer.
curl -G https://sheetdb.io/api/v1/58f61be4dda40/keys
JSON Response
[
"id",
"name",
"age",
"comment"
]
Document name
Returns the name of the document.
JSON Response
{
"name": "SheetDB test document"
}
Count
Returns the number of rows in the document (without first row).
JSON Response
{
"rows": 5
}