Database API
This guide explains how to use the Database API to perform CRUD operations on your database tables. The API uses PostgREST-style query parameters for filtering, which provides a powerful and flexible way to query data.
Overview
The Database API provides four main operations:
All operations use the same endpoint pattern:
Filter Syntax
Filters are passed as query parameters where:
- The parameter name is the column name
- The parameter value is the operator and value in the format
operator.value
Supported Operators
Pattern Matching
For like and ilike operators, use * as a wildcard (it gets converted to % in SQL):
*value- Ends with “value”value*- Starts with “value”*value*- Contains “value”
Combining Multiple Filters
Multiple filters are combined with AND logic:
Select (Read) Rows
Read data from a table with optional filtering, ordering, and pagination.
TypeScript
Python
cURL
Select Query Parameters
Insert Rows
Insert one or more rows into a table.
TypeScript
Python
cURL
Update Rows
Update rows that match filter conditions.
Safety Feature: Filters are required by default to prevent accidental bulk updates. To update all rows intentionally, you must pass force=true.
TypeScript
Python
cURL
Delete Rows
Delete rows that match filter conditions.
Safety Feature: Filters are required by default to prevent accidental bulk deletes. To delete all rows intentionally, you must pass force=true.
TypeScript
Python
cURL
Common Filter Examples
Filter by Status
Filter by Date/Time
Filter by Numeric Values
Filter by Text (Pattern Matching)
Complex Filters
Pagination
Use limit and offset for pagination:
TypeScript
Python
Additional Operations
List Tables
Get a list of all tables in the database:
TypeScript
Python
Get Table Schema
Get column information for a specific table:
TypeScript
Python
Check Database Status
Check if a serverless database is running or suspended:
TypeScript
Python
Error Handling
TypeScript
Python
Best Practices
-
Always use filters for UPDATE and DELETE - The API requires filters by default to prevent accidental bulk modifications. Only use
force=truewhen you explicitly intend to affect all rows. -
Use specific column selection - Instead of selecting all columns (
*), specify only the columns you need with theselectparameter for better performance. -
Implement pagination - For large datasets, use
limitandoffsetto paginate results rather than fetching all rows at once. -
Handle 503 errors gracefully - Serverless databases may be suspended. Implement retry logic for 503 errors as the database wakes up.
-
Use appropriate operators - Choose the right operator for your use case:
- Use
ilikefor case-insensitive text searches - Use
infor checking against multiple values - Use
is.nullinstead ofeq.nullfor NULL checks
- Use
-
Validate input - Always validate and sanitize any user input before using it in filter values to prevent injection attacks.
