Spanish Total.js
Slovenčina
Dokumentácia Pre AI agentov
Obsah

Read and write data from a script

Use an API token to list, find and create records from a shell script or another application.

.md Web

Táto stránka ešte nie je preložená. Čítaš originál.

Na tejto stránke

This recipe uses the API with curl. The same requests work from any language.

1. Create a token

Create an API token named after your script, and copy it. In the examples, it is in the variable TOKEN, and the table IDs are those of your own tables:

TOKEN='paste-your-token-here'
URL='https://tables.yourdomain.com/api/'

2. List customers from Spain

curl -s -X POST "$URL" -H "x-token: $TOKEN" -H 'content-type: application/json' \
    -d '{ "schema": "Data|list?x03=es&sort=name_asc", "data": { "tableid": "t588bi" } }'

3. Find a record by a value

curl -s -X POST "$URL" -H "x-token: $TOKEN" -H 'content-type: application/json' \
    -d '{ "schema": "Data|id", "data": { "tableid": "t4193w", "filter": { "x01": "CH-100" } } }'

4. Create a record

curl -s -X POST "$URL" -H "x-token: $TOKEN" -H 'content-type: application/json' \
    -d '{ "schema": "Data|save", "data": { "tableid": "t588bi", "data": { "name": "Example Ltd", "x01": "hello@example.com" } } }'

The answer has the ID of the new record in value.

5. Update it

Send the ID in data.data.id and only the columns to change:

curl -s -X POST "$URL" -H "x-token: $TOKEN" -H 'content-type: application/json' \
    -d '{ "schema": "Data|save", "data": { "tableid": "t588bi", "data": { "id": "RECORD_ID", "x04": false } } }'
Vyrobené v Európe