API
Call Tables from other applications: the request format and the operations on tables and records.
Cette page n’est pas encore traduite. Tu lis l’original.
Other applications use Tables through one address, /api/. Every call is a POST request with a JSON body that names the operation in schema and its input in data. Authenticate with an API token in the x-token header or the token parameter.
curl -X POST https://tables.yourdomain.com/api/ \
-H 'x-token: YOUR_TOKEN' \
-H 'content-type: application/json' \
-d '{ "schema": "Data|list", "data": { "tableid": "t588bi" } }'IDs
- Each table has an ID such as
t588bi. It is shown in the list of records and in the table settings. - Each column has an ID such as
x01. It is shown next to the column name in the table settings. The columnsid,name,dtcreated,dtupdated,createdbyandupdatedbyexist in every table. - Each record has an ID such as
JasodS1c561f.
Errors
A failed call returns an array of errors, for example:
[{ "error": "401: Unauthorized" }]Tables
Tables|list
Returns all tables and views with their settings and columns. No data.
Tables|read
Returns the settings of one table. data: { "id": "t588bi" }. Only tokens with Super admin privileges can use it.
Records
Data|list
Returns the records of a table or a view, 100 per page.
{ "schema": "Data|list", "data": { "tableid": "t588bi" } }The answer has items, count, page, limit and pages. To filter, sort and page, add parameters to the name of the operation, as in an address:
{ "schema": "Data|list?x03=es&sort=name_desc&limit=20&page=2", "data": { "tableid": "t588bi" } }- A column ID with a value filters by that column.
sortis a column ID followed by_ascor_desc.limitis the number of records per page, up to 100.pageis the page number.
Data|read
Returns one record with all its columns. data: { "tableid": "t118h7", "id": "JasodS1g561f" }. For a relation column x02, x02_id is the ID of the linked record and x02 holds its id and name.
Data|id
Finds the ID of the first record whose columns have the given values.
{ "schema": "Data|id", "data": { "tableid": "t4193w", "filter": { "x01": "CH-100" } } }Returns { "id": "JasooD1c561f" }.
Data|save
Creates a record, or changes it when data.data.id is set. A new record must contain all its required columns; to change a record, send only the columns you want to change. For a relation, send the ID of the linked record; for a Dropdown, the ID of the item.
{
"schema": "Data|save",
"data": {
"tableid": "t588bi",
"data": { "name": "Example Ltd", "x01": "hello@example.com", "x03": "es" }
}
}Returns { "success": true, "value": "<record ID>" }. Saving runs the hooks of the table and, with versioning, keeps the previous version.
Data|remove
Removes a record. data: { "tableid": "t588bi", "id": "<record ID>" }.
Data|sql
Runs a read-only SQL query and returns the rows. Only tokens with Super admin privileges can use it, and only one SELECT query is allowed.
{ "schema": "Data|sql", "data": { "sql": "SELECT name, x04 FROM vt118h7 WHERE x04 > 100" } }The tables and views you can query are described in Database structure.
Views
Views|list
Returns the views with their ID, table, name and icon. To read the records of a view, call Data|list with the ID of the view as tableid.