Sheets DB API
Google Cloud Function that proxies requests to Google Sheets API, treating sheets as database tables
Getting Started
Authentication
All requests require the X-Spreadsheet-Id header containing your Google Sheets spreadsheet ID.
Data Format
The API uses JSON for request and response bodies. Row data is represented as key-value objects where keys are column headers.
Row Indexing
Rows are 1-indexed in the API. Row 1 contains headers, so data rows start at index 2.
Sheet Access
Share your Google Sheet with the API service account to grant access:
sheets-db-api@kinetic-object-322814.iam.gserviceaccount.com
Grant Editor access to allow the API to read and write data.
Health
Returns the health status of the API
Responses
{
"status": "ok"
}
Example
curl -X GET 'https://sheetsapi-g56q77hy2a-uc.a.run.app/health' \ -H 'Content-Type: application/json'
Sheets
Returns a list of all sheets in the spreadsheet
Parameters
| Name | Type | Location | Description |
|---|---|---|---|
| X-Spreadsheet-Id required | string | header | The Google Sheets spreadsheet ID |
Responses
{
"sheets": [
{
"sheetId": 0,
"title": "Users",
"index": 0
}
]
}
Example
curl -X GET 'https://sheetsapi-g56q77hy2a-uc.a.run.app/sheets' \ -H 'Content-Type: application/json' \ -H 'X-Spreadsheet-Id: 1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms'
Creates a new sheet in the spreadsheet
Parameters
| Name | Type | Location | Description |
|---|---|---|---|
| X-Spreadsheet-Id required | string | header | The Google Sheets spreadsheet ID |
Request Body
{
"name": "NewSheet"
}
Responses
{
"sheet": {
"sheetId": 0,
"title": "Users",
"index": 0
}
}
Example
curl -X POST 'https://sheetsapi-g56q77hy2a-uc.a.run.app/sheets' \
-H 'Content-Type: application/json' \
-H 'X-Spreadsheet-Id: 1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms' \
-d '{ "name": "NewSheet"}'
Deletes a sheet from the spreadsheet
Parameters
| Name | Type | Location | Description |
|---|---|---|---|
| X-Spreadsheet-Id required | string | header | The Google Sheets spreadsheet ID |
| sheetName required | string | path | The name of the sheet (tab) within the spreadsheet |
Responses
// No content
Example
curl -X DELETE 'https://sheetsapi-g56q77hy2a-uc.a.run.app/sheets/{sheetName}' \
-H 'Content-Type: application/json' \
-H 'X-Spreadsheet-Id: 1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms'
Returns the column headers (first row) of the sheet
Parameters
| Name | Type | Location | Description |
|---|---|---|---|
| X-Spreadsheet-Id required | string | header | The Google Sheets spreadsheet ID |
| sheetName required | string | path | The name of the sheet (tab) within the spreadsheet |
Responses
{
"columns": [
"id",
"name",
"email",
"created_at"
]
}
Example
curl -X GET 'https://sheetsapi-g56q77hy2a-uc.a.run.app/sheets/{sheetName}/schema' \
-H 'Content-Type: application/json' \
-H 'X-Spreadsheet-Id: 1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms'
Rows
Returns all rows from the sheet (excluding header row)
Parameters
| Name | Type | Location | Description |
|---|---|---|---|
| X-Spreadsheet-Id required | string | header | The Google Sheets spreadsheet ID |
| sheetName required | string | path | The name of the sheet (tab) within the spreadsheet |
Responses
{
"rows": [
{
"id": 1,
"name": "John Doe",
"email": "john@example.com",
"active": true
}
]
}
Example
curl -X GET 'https://sheetsapi-g56q77hy2a-uc.a.run.app/sheets/{sheetName}/rows' \
-H 'Content-Type: application/json' \
-H 'X-Spreadsheet-Id: 1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms'
Appends a new row to the sheet. If the sheet is empty, creates headers from the object keys.
Parameters
| Name | Type | Location | Description |
|---|---|---|---|
| X-Spreadsheet-Id required | string | header | The Google Sheets spreadsheet ID |
| sheetName required | string | path | The name of the sheet (tab) within the spreadsheet |
Request Body
{
"id": 1,
"name": "John Doe",
"email": "john@example.com",
"active": true
}
Responses
{
"rowIndex": 5
}
Example
curl -X POST 'https://sheetsapi-g56q77hy2a-uc.a.run.app/sheets/{sheetName}/rows' \
-H 'Content-Type: application/json' \
-H 'X-Spreadsheet-Id: 1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms' \
-d '{ "id": 1, "name": "John Doe", "email": "john@example.com", "active": true}'
Creates multiple rows in a single request. Accepts 1-1000 rows. If the sheet is empty, creates headers from the first row's keys.
Parameters
| Name | Type | Location | Description |
|---|---|---|---|
| X-Spreadsheet-Id required | string | header | The Google Sheets spreadsheet ID |
| sheetName required | string | path | The name of the sheet (tab) within the spreadsheet |
Request Body
{
"rows": [
{
"id": 1,
"name": "Alice",
"email": "alice@example.com",
"age": 30
},
{
"id": 2,
"name": "Bob",
"email": "bob@example.com",
"age": 25
}
]
}
Responses
{
"rows": [
{
"rowIndex": 5,
"data": {
"id": 1,
"name": "Alice",
"email": "alice@example.com",
"age": 30
}
},
{
"rowIndex": 6,
"data": {
"id": 2,
"name": "Bob",
"email": "bob@example.com",
"age": 25
}
}
]
}
Example
curl -X POST 'https://sheetsapi-g56q77hy2a-uc.a.run.app/sheets/{sheetName}/rows/bulk' \
-H 'Content-Type: application/json' \
-H 'X-Spreadsheet-Id: 1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms' \
-d '{ "rows": [ { "id": 1, "name": "Alice", "email": "alice@example.com", "age": 30 }, { "id": 2, "name": "Bob", "email": "bob@example.com", "age": 25 } ]}'
Update multiple rows by row index with partial data merge behavior. Only updates specified fields, leaving other columns unchanged.
Parameters
| Name | Type | Location | Description |
|---|---|---|---|
| sheetName required | string | path | The name of the sheet (tab) within the spreadsheet |
| X-Spreadsheet-Id required | string | header | The Google Sheets spreadsheet ID |
Request Body
{
"rows": [
{
"rowIndex": 5,
"data": {
"name": "Alice Updated",
"age": 31
}
}
]
}
Responses
{
"rows": [
{
"rowIndex": 5,
"data": {
"id": 1,
"name": "Alice Updated",
"email": "alice@example.com",
"age": 31
}
}
]
}
Example
curl -X PUT 'https://sheetsapi-g56q77hy2a-uc.a.run.app/sheets/{sheetName}/rows/bulk' \
-H 'Content-Type: application/json' \
-H 'X-Spreadsheet-Id: 1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms' \
-d '{ "rows": [ { "rowIndex": 5, "data": { "name": "Alice Updated", "age": 31 } } ]}'
Returns a single row by its index (1-indexed, must be >= 2 since row 1 contains headers)
Parameters
| Name | Type | Location | Description |
|---|---|---|---|
| X-Spreadsheet-Id required | string | header | The Google Sheets spreadsheet ID |
| sheetName required | string | path | The name of the sheet (tab) within the spreadsheet |
| rowIndex required | integer | path | The 1-indexed row number (must be >= 2, since row 1 contains headers) |
Responses
{
"row": {
"id": 1,
"name": "John Doe",
"email": "john@example.com",
"active": true
}
}
Example
curl -X GET 'https://sheetsapi-g56q77hy2a-uc.a.run.app/sheets/{sheetName}/rows/{rowIndex}' \
-H 'Content-Type: application/json' \
-H 'X-Spreadsheet-Id: 1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms'
Updates an existing row by its index
Parameters
| Name | Type | Location | Description |
|---|---|---|---|
| X-Spreadsheet-Id required | string | header | The Google Sheets spreadsheet ID |
| sheetName required | string | path | The name of the sheet (tab) within the spreadsheet |
| rowIndex required | integer | path | The 1-indexed row number (must be >= 2, since row 1 contains headers) |
Request Body
{
"id": 1,
"name": "John Doe",
"email": "john@example.com",
"active": true
}
Responses
// No content
Example
curl -X PUT 'https://sheetsapi-g56q77hy2a-uc.a.run.app/sheets/{sheetName}/rows/{rowIndex}' \
-H 'Content-Type: application/json' \
-H 'X-Spreadsheet-Id: 1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms' \
-d '{ "id": 1, "name": "John Doe", "email": "john@example.com", "active": true}'
Deletes a row by its index
Parameters
| Name | Type | Location | Description |
|---|---|---|---|
| X-Spreadsheet-Id required | string | header | The Google Sheets spreadsheet ID |
| sheetName required | string | path | The name of the sheet (tab) within the spreadsheet |
| rowIndex required | integer | path | The 1-indexed row number (must be >= 2, since row 1 contains headers) |
Responses
// No content
Example
curl -X DELETE 'https://sheetsapi-g56q77hy2a-uc.a.run.app/sheets/{sheetName}/rows/{rowIndex}' \
-H 'Content-Type: application/json' \
-H 'X-Spreadsheet-Id: 1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms'