### Making a GET Request to SheetDB API Source: https://docs.sheetdb.io/quickstart Demonstrates how to fetch data from the SheetDB API using a GET request. This example shows the cURL command to retrieve data from a specified API endpoint. ```shell curl https://sheetdb.io/api/v1/58f61be4dda40 ``` -------------------------------- ### Making a GET Request to SheetDB API (PHP) Source: https://docs.sheetdb.io/quickstart Illustrates how to make a GET request to the SheetDB API using PHP. This example shows how to retrieve data from the API endpoint using file_get_contents. ```php ``` -------------------------------- ### Making a GET Request to SheetDB API (JavaScript) Source: https://docs.sheetdb.io/quickstart Provides a JavaScript example for making a GET request to the SheetDB API. This snippet illustrates how to fetch data from the API endpoint using the fetch API. ```javascript fetch('https://sheetdb.io/api/v1/58f61be4dda40') .then(response => response.json()) .then(data => console.log(data)); ``` -------------------------------- ### GET /websites/sheetdb_io - Value Render Option Source: https://docs.sheetdb.io/value-render-input-option Controls how values are displayed in GET requests. Allows specifying formatted, unformatted, or formula values. ```APIDOC ## GET /websites/sheetdb_io ### Description Retrieves data from a Google Sheet with options to control how values are rendered. ### Method GET ### Endpoint /websites/sheetdb_io ### Query Parameters - **mode** (string) - Optional - Controls the value rendering. Accepted values: `FORMATTED_VALUE`, `UNFORMATTED_VALUE`, `FORMULA`. - `FORMATTED_VALUE`: Returns calculated and formatted values based on cell formatting and spreadsheet locale (default). - `UNFORMATTED_VALUE`: Returns calculated values without formatting. - `FORMULA`: Returns the formulas without calculation. ### Request Example ``` GET /websites/sheetdb_io?mode=UNFORMATTED_VALUE ``` ### Response #### Success Response (200) - **values** (array) - An array of values retrieved from the sheet. #### Response Example ```json { "values": [ "1.23", "1.23", "=A1" ] } ``` ``` -------------------------------- ### GET /api/v1/{APP_ID}/{API_KEY}/list Source: https://docs.sheetdb.io/global-api/get-all-apis Retrieves a list of all APIs associated with your account. Returns an array with a list of APIs. ```APIDOC ## GET /api/v1/{APP_ID}/{API_KEY}/list ### Description This method allows you to retrieve a list of all APIs associated with your account. Returns an array with a list of APIs. ### Method GET ### Endpoint `/api/v1/{APP_ID}/{API_KEY}/list` ### Parameters #### Path Parameters - **APP_ID** (string) - Required - Your SheetDB application ID. - **API_KEY** (string) - Required - Your SheetDB API key. ### Response #### Success Response (200) - **id** (string) - The unique identifier for the API. - **url** (string) - The URL to access this specific API. - **spreadsheet_id** (string) - The ID of the associated Google Sheet. - **spreadsheet_url** (string) - The URL of the associated Google Sheet. - **created_at** (string) - The timestamp when the API was created. #### Response Example ```json [ { "id":"xxxxxxxxxxxxx", "url":"https://sheetdb.io/api/v1/xxxxxxxxxxxxx", "spreadsheet_id":"1RjHxmJkDxvv6k2dyexxxxxxxxxxxxxxx-xxxxxxxxxx", "spreadsheet_url":"https://docs.google.com/spreadsheets/d/1RjHxmJkDxvv6k2dyexxxxxxxxxxxxxxx-xxxxxxxxxx/edit#gid=0", "created_at":"2022-12-07T14:32:10.000000Z" }, { "id":"xxxxxxxxxxxxx", "url":"https://sheetdb.io/api/v1/xxxxxxxxxxxxx", "spreadsheet_id":"1RjHxmJkDxvv6k2dyexxxxxxxxxxxxxxx-xxxxxxxxxx", "spreadsheet_url":"https://docs.google.com/spreadsheets/d/1RjHxmJkDxvv6k2dyexxxxxxxxxxxxxxx-xxxxxxxxxx/edit#gid=0", "created_at":"2022-12-11T09:07:38.000000Z" } ] ``` ``` -------------------------------- ### Negative Search Example Source: https://docs.sheetdb.io/sheetdb-api/search Shows how to exclude specific rows from search results using a negative search operator. The example demonstrates retrieving all rows where the 'name' is not 'Tom' by prefixing the value with an exclamation mark. ```URL https://sheetdb.io/api/v1/58f61be4dda40/search?name=!Tom ``` -------------------------------- ### Get All APIs - SheetDB API Source: https://docs.sheetdb.io/global-api/get-all-apis Retrieves a list of all APIs associated with your SheetDB account. This GET request requires your application ID and API key. The response is a JSON array containing details of each API. ```HTTP GET /api/v1/{APP_ID}/{API_KEY}/list ``` -------------------------------- ### Install SheetDB Handlebars Snippet in HTML Source: https://docs.sheetdb.io/handlebars Include the SheetDB Handlebars JavaScript library in your HTML to enable dynamic data display from Google Sheets. This script should be placed before the closing tag and included only once. ```html ``` -------------------------------- ### Multiple Queries for the Same Column Source: https://docs.sheetdb.io/sheetdb-api/search Demonstrates how to apply multiple search conditions to the same column using array notation. Examples include searching for 'id' values between 1 and 3, and excluding names 'Tom' and 'Steve'. ```URL https://sheetdb.io/api/v1/58f61be4dda40/search?id[]=>1&id[]=<3 ``` ```URL https://sheetdb.io/api/v1/58f61be4dda40/search?name[]=!Tom&name[]=!Steve ``` -------------------------------- ### GET /api/v1/{API_ID} Source: https://docs.sheetdb.io/quickstart This endpoint retrieves all data from a specified SheetDB API. It's a simple GET request to fetch the entire content of your spreadsheet. ```APIDOC ## GET /api/v1/{API_ID} ### Description Retrieves all data from a specified SheetDB API. This is a read-only operation to fetch the entire content of your spreadsheet. ### Method GET ### Endpoint /api/v1/{API_ID} ### Parameters #### Path Parameters - **API_ID** (string) - Required - The unique identifier for your SheetDB API. ### Request Example ```bash curl https://sheetdb.io/api/v1/58f61be4dda40 ``` ### Response #### Success Response (200) - **Array of Objects** - Each object represents a row in the spreadsheet with keys corresponding to column names. #### Response Example ```json [ { "id": "1", "name": "Tom", "age": "15", "comment": "" }, { "id": "2", "name": "Alex", "age": "24", "comment": "" }, { "id": "3", "name": "John", "age": "51", "comment": "" }, { "id": "4", "name": "Steve", "age": "22", "comment": "special" }, { "id": "5", "name": "James", "age": "19", "comment": "" } ] ``` ``` -------------------------------- ### Reuse Data with Slots (HTML) Source: https://docs.sheetdb.io/handlebars This HTML example shows how to use the `data-sheetdb-save` and `data-sheetdb-slot` attributes to save and reuse data fetched from SheetDB. This reduces API requests by allowing data to be displayed in multiple locations using a single fetch. ```html

Name: {{name}}

Age: {{age}}

``` -------------------------------- ### GET /api/v1/{API_ID}/keys Source: https://docs.sheetdb.io/sheetdb-api/read Retrieves all column names (keys) from the first row of the spreadsheet. ```APIDOC ## GET /api/v1/{API_ID}/keys ### Description Returns an array with all column names, which are the cells from the first row of the spreadsheet. ### Method GET ### Endpoint `/api/v1/{API_ID}/keys` ### Response #### Success Response (200) - **Array of Strings** - Each string is a column name. #### Response Example ```json [ "id", "name", "age", "comment" ] ``` ``` -------------------------------- ### Search OR Condition Example Source: https://docs.sheetdb.io/sheetdb-api/search Illustrates how to use the 'search_or' endpoint to find rows where at least one of the specified conditions is met. This is useful when you need to match any of several criteria, such as finding records where the name is 'Tom' OR the age is '22'. ```URL https://sheetdb.io/api/v1/58f61be4dda40/search_or?name=Tom&age=22 ``` -------------------------------- ### Basic Search with cURL Source: https://docs.sheetdb.io/sheetdb-api/search Demonstrates how to perform a basic search query using cURL to find rows where the 'name' column matches 'tom'. This is a fundamental example for interacting with the SheetDB search API. ```cURL curl -G https://sheetdb.io/api/v1/58f61be4dda40/search \ -d name=tom ``` -------------------------------- ### GET /api/v1/{API_ID}/name Source: https://docs.sheetdb.io/sheetdb-api/read Retrieves the name of the document (spreadsheet). ```APIDOC ## GET /api/v1/{API_ID}/name ### Description Returns the name of the document (spreadsheet). ### Method GET ### Endpoint `/api/v1/{API_ID}/name` ### Response #### Success Response (200) - **Object** - Contains a `name` field with the document's name. #### Response Example ```json { "name": "SheetDB test document" } ``` ``` -------------------------------- ### Get Document Name with SheetDB API Source: https://docs.sheetdb.io/sheetdb-api/read Retrieves the name of the document (spreadsheet) using the SheetDB API. The API endpoint is GET /api/v1/{API_ID}/name. ```javascript fetch('https://sheetdb.io/api/v1/58f61be4dda40/name') .then(response => response.json()) .then(data => console.log(data)); ``` ```php ``` -------------------------------- ### Relational Operators for Numerical Search Source: https://docs.sheetdb.io/sheetdb-api/search Explains and provides examples of using relational operators (>, <, >=, <=) to search for numerical values within a specified range. This allows for filtering data based on numerical comparisons, such as finding rows with an 'id' greater than 3. ```URL https://sheetdb.io/api/v1/58f61be4dda40/search?id=>3 ``` ```URL https://sheetdb.io/api/v1/58f61be4dda40/search?id=<3 ``` ```URL https://sheetdb.io/api/v1/58f61be4dda40/search?id=>=3 ``` ```URL https://sheetdb.io/api/v1/58f61be4dda40/search?id=<=3 ``` -------------------------------- ### GET /api/v1/{API_ID}/count Source: https://docs.sheetdb.io/sheetdb-api/read Retrieves the total number of rows in the document, excluding the header row. ```APIDOC ## GET /api/v1/{API_ID}/count ### Description Returns the number of rows in the document, excluding the first (header) row. ### Method GET ### Endpoint `/api/v1/{API_ID}/count` ### Response #### Success Response (200) - **Object** - Contains a `rows` field with the count of data rows. #### Response Example ```json { "rows": 5 } ``` ``` -------------------------------- ### Retrieve Column Keys from SheetDB API Source: https://docs.sheetdb.io/sheetdb-api/read Fetches an array of all column names (keys) from the first row of a spreadsheet using the SheetDB API. The API endpoint is GET /api/v1/{API_ID}/keys. ```curl curl -G https://sheetdb.io/api/v1/58f61be4dda40/keys ``` ```javascript fetch('https://sheetdb.io/api/v1/58f61be4dda40/keys') .then(response => response.json()) .then(data => console.log(data)); ``` ```php ``` -------------------------------- ### GET /api/v1/{API_ID}/sheets Source: https://docs.sheetdb.io/sheetdb-api/other Retrieves a list of all available sheets (tabs) within the spreadsheet. ```APIDOC ## GET /api/v1/{API_ID}/sheets ### Description Retrieves a list of all available sheets (tabs) within the spreadsheet. ### Method GET ### Endpoint `/api/v1/{API_ID}/sheets` ### Parameters #### Path Parameters - **API_ID** (string) - Required - The unique identifier for the spreadsheet. ### Response #### Success Response (200) - **sheets** (array) - An array of strings, where each string is the name of a sheet. #### Response Example ```json { "sheets": [ "Sheet1", "Sheet2", "large" ] } ``` ``` -------------------------------- ### GET /api/v1/{API_ID}/search Source: https://docs.sheetdb.io/sheetdb-api/search Returns an array of all rows matching the query conditions. Rows that do not meet all specified conditions will be excluded. ```APIDOC ## GET /api/v1/{API_ID}/search ### Description Returns an array of all rows matching the query. If any condition is not met for a row, it will not be included in the result. ### Method GET ### Endpoint /api/v1/{API_ID}/search ### Query Parameters - **field_name** (string) - Optional - The name of the column to search within. - **casesensitive** (boolean) - Optional - Set to `true` to enable case-sensitive search. Defaults to `false`. ### Request Example ``` https://sheetdb.io/api/v1/YOUR_API_ID/search?name=Tom&age=>20 ``` ### Response #### Success Response (200) - **Array of Objects** - Each object represents a row matching the search criteria. - **field_name** (string) - The value of the column in the row. #### Response Example ```json [ { "id": "1", "name": "Tom", "age": "22", "comment": "Example comment" } ] ``` ### Wildcards - The asterisk `*` can represent any string. Wildcards only work when READ and SEARCH permissions are both enabled. ### Negative Search - Use an exclamation mark `!` before the value to exclude rows. Example: `name=!Tom` to get all rows where the name is not Tom. ### Relational Operators - Use `<`, `>`, `<=`, `>=` operators for numerical comparisons. Example: `id=>3` for IDs greater than 3. ### Multiple Queries for the Same Column - Use array notation `[]` for multiple queries on the same column. Example: `id[]=>1&id[]=<3` to search for IDs between 1 and 3 (exclusive of 1 and 3). ### Optional Attributes - Can use optional attributes from the 'Read all data' endpoint, such as `casesensitive`. ``` -------------------------------- ### Count Rows in Spreadsheet with SheetDB API Source: https://docs.sheetdb.io/sheetdb-api/read Returns the total number of rows in the document, excluding the header row, using the SheetDB API. The API endpoint is GET /api/v1/{API_ID}/count. ```javascript fetch('https://sheetdb.io/api/v1/58f61be4dda40/count') .then(response => response.json()) .then(data => console.log(data)); ``` ```php ``` -------------------------------- ### Create Rows using PHP Source: https://docs.sheetdb.io/sheetdb-api/create This PHP code snippet shows how to create rows in a SheetDB spreadsheet using cURL. It constructs a POST request to the SheetDB API endpoint, sending an array of row data within the 'data' parameter. The example includes setting 'id' to 'INCREMENT' for automatic ID generation. ```php [ ['id' => 'INCREMENT', 'name' => 'Mark', 'age' => 18], ['id' => 'INCREMENT', 'name' => 'Susan', 'age' => 22] ] ]; $ch = curl_init('https://sheetdb.io/api/v1/58f61be4dda40'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); $response = curl_exec($ch); if (curl_errno($ch)) { echo 'Curl error: ' . curl_error($ch); } c则ose($ch); $responseData = json_decode($response, true); print_r($responseData); ?> ``` -------------------------------- ### Read Spreadsheet Content with SheetDB API Source: https://docs.sheetdb.io/sheetdb-api/read Fetches data from a spreadsheet using the SheetDB API. Supports filtering by sheet, limiting results, offsetting, sorting by various criteria (including date), casting numbers, and returning a single object. The API endpoint is GET /api/v1/{API_ID}. ```curl curl -G https://sheetdb.io/api/v1/58f61be4dda40 \ -d sort_by=id \ -d sort_order=desc \ -d limit=2 \ -d cast_numbers=age ``` ```javascript fetch('https://sheetdb.io/api/v1/58f61be4dda40?sort_by=id&sort_order=desc&limit=2&cast_numbers=age') .then(response => response.json()) .then(data => console.log(data)); ``` ```php ``` -------------------------------- ### POST /api/v1/{APP_ID}/{API_KEY}/create Source: https://docs.sheetdb.io/global-api/create-new-api This endpoint creates a new API in SheetDB for an existing Google Spreadsheet. Ensure the spreadsheet exists and you have permissions. ```APIDOC ## POST /api/v1/{APP_ID}/{API_KEY}/create ### Description This endpoint creates a new API in SheetDB for an existing Google Spreadsheet. Before using this endpoint, make sure that the Google Spreadsheet already exists in your account and you have permissions to it. ### Method POST ### Endpoint /api/v1/{APP_ID}/{API_KEY}/create ### Parameters #### Path Parameters - **APP_ID** (string) - Required - Your SheetDB Application ID. - **API_KEY** (string) - Required - Your SheetDB API Key. #### Query Parameters None #### Request Body - **url** (string) - Required - A string containing the URL of the Google Spreadsheet for which the new API will be created. - **permissions** (string) - Optional - A comma-separated list of permissions to enable for the API. If not provided, the following permissions are enabled by default: create, read, update, delete, search. Available permissions: create, read, update, delete, search, tabs_create, tabs_delete. Example: "create,tabs_create" ### Request Example ```json { "url": "https://docs.google.com/spreadsheets/d/YOUR_SPREADSHEET_ID/edit?usp=sharing", "permissions": "create,read" } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the operation was successful. - **name** (string) - The name of the created API. - **id** (string) - The unique identifier for the created API. - **url** (string) - The URL for accessing the created API. #### Response Example ```json { "success": true, "name": "Test name", "id": "xxxxxxxxxxxxx", "url": "https://sheetdb.io/api/v1/xxxxxxxxxxxxx" } ``` ``` -------------------------------- ### Create API from Google Spreadsheet (POST) Source: https://docs.sheetdb.io/global-api/create-new-api This endpoint creates a new API in SheetDB for an existing Google Spreadsheet. It requires the spreadsheet's URL and optionally accepts a comma-separated list of permissions. If permissions are not provided, default permissions (create, read, update, delete, search) are applied. ```HTTP POST /api/v1/{APP_ID}/{API_KEY}/create -- Request Body -- { "url": "https://docs.google.com/spreadsheets/d/YOUR_SPREADSHEET_ID/edit", "permissions": "create,read,update,delete,search,tabs_create,tabs_delete" } ``` -------------------------------- ### Create API from JSON Data (POST) Source: https://docs.sheetdb.io/global-api/create-new-api This endpoint creates a new API in SheetDB by first creating a new Google Spreadsheet from provided JSON data. It requires a URL pointing to the JSON data and optionally accepts a title for the new API/Spreadsheet and a comma-separated list of permissions. Default permissions are applied if not specified. ```HTTP POST /api/v1/{APP_ID}/{API_KEY}/create/json -- Request Body -- { "url": "https://example.com/data.json", "title": "My New API", "permissions": "create,read" } ``` -------------------------------- ### Authentication with API Keys Source: https://docs.sheetdb.io/global-api/authentication This section details how to generate and use API keys to authenticate requests to SheetDB's global endpoints. API keys are essential for identifying and authorizing your access to the SheetDB API. ```APIDOC ## Authentication with API Keys ### Description SheetDB's global endpoints require authentication using API keys. You can generate API keys from the SheetDB dashboard. These keys identify and authorize your requests. ### How to Get API Keys 1. Navigate to the API Keys section in your SheetDB dashboard: https://sheetdb.io/app/api-keys. 2. Create a new API key, granting it only the necessary permissions. ### Using API Keys API keys can be included in the URL for authentication. Replace `{APP_ID}` and `{API_KEY}` with your specific credentials. ### Endpoint Example `https://sheetdb.io/api/v1/{APP_ID}/{API_KEY}/list` ### Security Note **Be cautious not to share your API key**, as it grants access to your data. ``` -------------------------------- ### SheetDB API - Multiple Sheets Source: https://docs.sheetdb.io/multiple-sheets This section details how to interact with specific sheets in your SheetDB spreadsheet by using the `sheet` query parameter. If a specified sheet is not found, a 404 error will be returned. ```APIDOC ## GET /api/v1/{sheetdb_id} ### Description Retrieves data from a specific sheet within your SheetDB spreadsheet. ### Method GET ### Endpoint `https://sheetdb.io/api/v1/{sheetdb_id}?sheet={sheet_name}` ### Query Parameters - **sheet** (string) - Required - The name of the sheet to retrieve data from. ### Response #### Success Response (200) - **data** (array) - An array of objects, where each object represents a row in the sheet. #### Response Example ```json { "data": [ { "column1": "value1", "column2": "value2" }, { "column1": "value3", "column2": "value4" } ] } ``` ``` ```APIDOC ## POST /api/v1/{sheetdb_id} ### Description Adds a new row to a specific sheet within your SheetDB spreadsheet. ### Method POST ### Endpoint `https://sheetdb.io/api/v1/{sheetdb_id}?sheet={sheet_name}` ### Query Parameters - **sheet** (string) - Required - The name of the sheet to add data to. ### Request Body - **field_name** (string) - Required/Optional - The value for the corresponding column in the new row. ### Request Example ```json { "column1": "new_value1", "column2": "new_value2" } ``` ### Response #### Success Response (200) - **created** (boolean) - Indicates if the row was successfully created. - **id** (integer) - The ID of the newly created row. #### Response Example ```json { "created": true, "id": 10 } ``` ``` ```APIDOC ## PATCH /api/v1/{sheetdb_id}/{column}/{value} ### Description Updates existing rows in a specific sheet based on a column and its value. ### Method PATCH ### Endpoint `https://sheetdb.io/api/v1/{sheetdb_id}/{column}/{value}?sheet={sheet_name}` ### Path Parameters - **column** (string) - Required - The name of the column to filter by. - **value** (string) - Required - The value in the specified column to match for updating. ### Query Parameters - **sheet** (string) - Required - The name of the sheet to update data in. ### Request Body - **field_name** (string) - Required/Optional - The new value for the corresponding column in the updated row(s). ### Request Example ```json { "column1": "updated_value" } ``` ### Response #### Success Response (200) - **updated** (integer) - The number of rows updated. #### Response Example ```json { "updated": 5 } ``` ``` ```APIDOC ## DELETE /api/v1/{sheetdb_id}/{column}/{value} ### Description Deletes rows from a specific sheet based on a column and its value. ### Method DELETE ### Endpoint `https://sheetdb.io/api/v1/{sheetdb_id}/{column}/{value}?sheet={sheet_name}` ### Path Parameters - **column** (string) - Required - The name of the column to filter by. - **value** (string) - Required - The value in the specified column to match for deletion. ### Query Parameters - **sheet** (string) - Required - The name of the sheet to delete data from. ### Response #### Success Response (200) - **deleted** (integer) - The number of rows deleted. #### Response Example ```json { "deleted": 2 } ``` ``` -------------------------------- ### GET /api/v1/{API_ID}/search_or Source: https://docs.sheetdb.io/sheetdb-api/search Returns an array of rows where at least one of the specified conditions is met. This is useful for OR-based searches. ```APIDOC ## GET /api/v1/{API_ID}/search_or ### Description Returns an array of rows where any of the specified conditions are met. This endpoint performs an OR search. ### Method GET ### Endpoint /api/v1/{API_ID}/search_or ### Query Parameters - **field_name** (string) - Optional - The name of the column to search within. - **casesensitive** (boolean) - Optional - Set to `true` to enable case-sensitive search. Defaults to `false`. ### Request Example ``` https://sheetdb.io/api/v1/YOUR_API_ID/search_or?name=Tom&age=22 ``` ### Response #### Success Response (200) - **Array of Objects** - Each object represents a row matching at least one of the search criteria. - **field_name** (string) - The value of the column in the row. #### Response Example ```json [ { "id": "1", "name": "Tom", "age": "15", "comment": "" }, { "id": "5", "name": "Steve", "age": "22", "comment": "Another user" } ] ``` ``` -------------------------------- ### POST /api/v1/{APP_ID}/{API_KEY}/create/json Source: https://docs.sheetdb.io/global-api/create-new-api This endpoint creates a new API in SheetDB based on provided JSON data. It creates a new Google Spreadsheet with the JSON data and then generates the API. ```APIDOC ## POST /api/v1/{APP_ID}/{API_KEY}/create/json ### Description This endpoint creates a new API in SheetDB based on provided JSON data. The API will create a new Google Spreadsheet with the JSON data, then generate the API for the newly created Spreadsheet. Before using this endpoint, ensure that the JSON data is properly formatted and available at url. ### Method POST ### Endpoint /api/v1/{APP_ID}/{API_KEY}/create/json ### Parameters #### Path Parameters - **APP_ID** (string) - Required - Your SheetDB Application ID. - **API_KEY** (string) - Required - Your SheetDB API Key. #### Query Parameters None #### Request Body - **url** (string) - Required - A string containing the URL of the JSON data to be used for creating the Google Spreadsheet and the new API. - **title** (string) - Optional - A string representing the desired name for both the API and the associated Google Spreadsheet. - **permissions** (string) - Optional - A comma-separated list of permissions to enable for the API. If not provided, the following permissions are enabled by default: create, read, update, delete, search. Available permissions: create, read, update, delete, search, tabs_create, tabs_delete. Example: "create,tabs_create" ### Request Example ```json { "url": "http://example.com/data.json", "title": "My New API", "permissions": "create,read,update" } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the operation was successful. - **name** (string) - The name of the created API. - **id** (string) - The unique identifier for the created API. - **url** (string) - The URL for accessing the created API. #### Response Example ```json { "success": true, "name": "My New API", "id": "yyyyyyyyyyyyy", "url": "https://sheetdb.io/api/v1/yyyyyyyyyyyyy" } ``` ``` -------------------------------- ### GET /api/v1/{API_ID}/cells/{CELL} Source: https://docs.sheetdb.io/sheetdb-api/other Retrieves the contents of a single cell or multiple cells using their coordinates (e.g., A1, B10). Multiple cells can be requested by separating them with a comma. ```APIDOC ## GET /api/v1/{API_ID}/cells/{CELL} ### Description Retrieves the contents of a single cell or multiple cells using their coordinates (e.g., A1, B10). Multiple cells can be requested by separating them with a comma. ### Method GET ### Endpoint `/api/v1/{API_ID}/cells/{CELL}` ### Parameters #### Path Parameters - **API_ID** (string) - Required - The unique identifier for the spreadsheet. - **CELL** (string) - Required - The cell coordinate(s) to retrieve (e.g., `A1` or `A1,A2,B5`). #### Query Parameters - **sheet** (string) - Optional - The name of the sheet (tab) to select. ### Response #### Success Response (200) - **(object)** - An object where keys are cell coordinates and values are the cell contents. #### Response Example ```json { "A1": "id", "A2": "1", "B5": "Steve" } ``` ``` -------------------------------- ### POST /websites/sheetdb_io - Value Input Option Source: https://docs.sheetdb.io/value-render-input-option Controls how input strings are parsed for POST requests (creating data). Allows user-entered or raw input. ```APIDOC ## POST /websites/sheetdb_io ### Description Inserts data into a Google Sheet with options to control how input strings are parsed. ### Method POST ### Endpoint /websites/sheetdb_io ### Query Parameters - **mode** (string) - Optional - Controls how input strings are parsed. Accepted values: `USER_ENTERED`, `RAW`. - `USER_ENTERED`: Parses input as if entered in the Google Sheets UI, inferring types and formats (default). - `RAW`: Inserts input as a plain string without parsing. ### Request Example ``` POST /websites/sheetdb_io?mode=RAW Content-Type: application/json { "column1": "=1+2" } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### Events Source: https://docs.sheetdb.io/handlebars SheetDB triggers a `sheetdb-downloaded` event after all data has been retrieved. You can listen to this event to execute custom JavaScript code. ```APIDOC ## Events ### Description SheetDB emits a custom event named `sheetdb-downloaded` once all data has been successfully fetched and processed by the Handlebars library. This allows you to execute your own JavaScript code immediately after the data is available. ### Method Event Listener ### Endpoint N/A ### Parameters N/A ### Request Example ```javascript window.addEventListener("sheetdb-downloaded", function() { // This code will be executed after all SheetDB data has been retrieved console.log("SheetDB data downloaded and processed."); }); ``` ### Response N/A ``` -------------------------------- ### Execute JavaScript After Data Download (JavaScript) Source: https://docs.sheetdb.io/handlebars This JavaScript code snippet shows how to listen for the custom `sheetdb-downloaded` event. This event is triggered by the Handlebars library after all data from SheetDB has been successfully retrieved, allowing you to execute custom JavaScript logic. ```javascript window.addEventListener("sheetdb-downloaded", function() { // this code will be executed after all sheetdb data has been retrieved }); ``` -------------------------------- ### PATCH /websites/sheetdb_io - Value Input Option Source: https://docs.sheetdb.io/value-render-input-option Controls how input strings are parsed for PATCH requests (updating data). Allows user-entered or raw input. ```APIDOC ## PATCH /websites/sheetdb_io ### Description Updates data in a Google Sheet with options to control how input strings are parsed. ### Method PATCH ### Endpoint /websites/sheetdb_io ### Query Parameters - **mode** (string) - Optional - Controls how input strings are parsed. Accepted values: `USER_ENTERED`, `RAW`. - `USER_ENTERED`: Parses input as if entered in the Google Sheets UI, inferring types and formats (default). - `RAW`: Inserts input as a plain string without parsing. ### Request Example ``` PATCH /websites/sheetdb_io?mode=USER_ENTERED Content-Type: application/json { "column1": "Mar 1 2016" } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### Create Rows using cURL Source: https://docs.sheetdb.io/sheetdb-api/create This snippet demonstrates how to create rows in a SheetDB spreadsheet using a cURL command. It shows the POST request to the API endpoint with sample data for 'id', 'name', and 'age'. The 'id' is set to 'INCREMENT' to automatically assign the next available ID. ```shell curl -X POST -G https://sheetdb.io/api/v1/58f61be4dda40 \ -d id='INCREMENT' \ -d name=Mark \ -d age=18 ``` -------------------------------- ### Update Content Source: https://docs.sheetdb.io/handlebars The `sheetdb_upd()` global function can be used to force a redownload of all content from the API, ensuring you have the latest data. ```APIDOC ## Update Content ### Description To ensure you are always working with the most up-to-date information, you can use the global JavaScript function `sheetdb_upd()`. Calling this function will trigger an immediate redownload of all content from the SheetDB API. ### Method Global Function Call ### Endpoint N/A ### Parameters N/A ### Request Example ```javascript sheetdb_upd(); // Forces a redownload of all SheetDB content ``` ### Response N/A ``` -------------------------------- ### Get Single Cell Value from SheetDB API Source: https://docs.sheetdb.io/sheetdb-api/other Retrieve the content of a single cell or multiple cells from a specified sheet using their coordinates. The response is a JSON object where keys are cell coordinates and values are the cell contents. Supports fetching multiple cells by separating coordinates with a comma. ```json { "A1": "id", "A2": "1", "B5": "Steve" } ``` -------------------------------- ### Create Rows using JavaScript Source: https://docs.sheetdb.io/sheetdb-api/create This JavaScript code snippet illustrates how to create rows in a SheetDB spreadsheet using the Fetch API. It sends a POST request to the SheetDB API endpoint with the 'data' attribute containing an array of row objects. Each object represents a row with column names as keys and their corresponding values. ```javascript fetch('https://sheetdb.io/api/v1/58f61be4dda40', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ "data": [ {"id": "INCREMENT", "name": "Mark", "age": 18}, {"id": "INCREMENT", "name": "Susan", "age": 22} ] }) }) .then(response => response.json()) .then(data => console.log(data)); ``` -------------------------------- ### Query Strings Source: https://docs.sheetdb.io/handlebars Allows displaying different content based on URL query parameters. You can filter data by specifying parameters in the `data-sheetdb-query-string` attribute. ```APIDOC ## Query Strings ### Description Use query strings to dynamically filter and display data based on URL parameters. This feature works similarly to a search function, allowing you to specify criteria directly in the URL. ### Method GET (Implicit through data attributes) ### Endpoint `https://sheetdb.io/api/v1/{YOUR_API_KEY}` ### Parameters #### Query Parameters - **(URL Parameter)** (string) - Required - The parameter to filter by (e.g., `id=1`). #### Data Attributes - **data-sheetdb-url** (string) - Required - The SheetDB API endpoint URL. - **data-sheetdb-query-string** (string) - Required - Comma-separated list of query string parameters to filter by (e.g., `id,name`). ### Request Example ```html

ID: {{id}} - {{name}} ({{age}})

``` ### Response #### Success Response (200) Returns data matching the specified query string parameters. #### Response Example ```json { "data": [ { "id": "1", "name": "John Doe", "age": "30" } ] } ``` ``` -------------------------------- ### Basic Authentication Source: https://docs.sheetdb.io/authentication Authenticate your API requests using Basic authentication with a username and password. Bearer token is recommended. ```APIDOC ## GET /api/v1/{API_ID} ### Description This endpoint retrieves data from your SheetDB API using Basic authentication. ### Method GET ### Endpoint `/api/v1/{API_ID}` ### Parameters #### Path Parameters - **API_ID** (string) - Required - The unique identifier for your SheetDB API. #### Query Parameters None #### Request Body None ### Request Example ```curl curl https://sheetdb.io/api/v1/58f61be4dda40 \ -u username:password ``` ### Response #### Success Response (200) - **data** (array) - An array of objects representing the data from your sheet. #### Response Example ```json { "data": [ { "column1": "value1", "column2": "value2" } ] } ``` ``` -------------------------------- ### POST /api/v1/{API_ID}/import/json Source: https://docs.sheetdb.io/sheetdb-api/other Imports JSON data into an empty spreadsheet. If the spreadsheet is not empty, the data will be appended. ```APIDOC ## POST /api/v1/{API_ID}/import/json ### Description Imports JSON data into an empty spreadsheet. If the spreadsheet is not empty, the data will be appended below. ### Method POST ### Endpoint `/api/v1/{API_ID}/import/json` ### Parameters #### Path Parameters - **API_ID** (string) - Required - The unique identifier for the spreadsheet. #### Request Body - **json** (json) - Required - A JSON array containing the data to import. Example: `[{"id": 1,"name": "Mark"},{"id": 2,"name": "Susan"}]` - **sheet** (string) - Optional - The name of the sheet (tab) to import the data into. ### Request Example ```json { "json": [ {"id": 1, "name": "Mark"}, {"id": 2, "name": "Susan"} ] } ``` ### Response #### Success Response (200) - **created** (integer) - The number of items created. #### Response Example ```json { "created": 1 } ``` ``` -------------------------------- ### Create New Sheet in SheetDB API Source: https://docs.sheetdb.io/sheetdb-api/other Create a new sheet (tab) in the spreadsheet. This method requires the 'name' for the new sheet and 'first_row' which is an array of column names. Availability may depend on the subscription plan. ```curl curl -X POST -H "Content-Type: application/json" \ https://sheetdb.io/api/v1/58f61be4dda40/sheet \ -d '{"name": "New Sheet", "first_row":["id","name"]}' ``` ```javascript fetch('https://sheetdb.io/api/v1/58f61be4dda40/sheet', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ name: 'New Sheet', first_row: ['id', 'name'] }) }) .then(response => response.json()) .then(data => console.log(data)); ``` ```php 'New Sheet', 'first_row' => ['id', 'name']]); $ch = curl_init('https://sheetdb.io/api/v1/58f61be4dda40/sheet'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); $response = curl_exec($ch); if (curl_errno($ch)) { echo 'Error:' . curl_error($ch); } curl_close($ch); echo $response; ?> ``` -------------------------------- ### Render Sanitized HTML from SheetDB using Handlebars Source: https://docs.sheetdb.io/handlebars To render HTML content from spreadsheet cells safely, use the `{{html:column_name}}` syntax. This allows common HTML tags while stripping potentially dangerous elements and attributes to prevent XSS attacks. ```html

Plain text (escaped): {{name}}

Sanitized HTML: {{html:name}}

``` -------------------------------- ### Advanced SheetDB Data Fetching with HTML Attributes Source: https://docs.sheetdb.io/handlebars Customize data retrieval from SheetDB using optional HTML attributes like `data-sheetdb-sort-by`, `data-sheetdb-sort-order`, `data-sheetdb-search`, and `data-sheetdb-search-mode`. These attributes allow for sorting, filtering, and specifying search logic directly in the HTML. ```html

ID: {{id}} - {{name}} ({{age}})

```