Skip to content
Verified

JavaScript Framework

The runtime, the CLI, and the five app data methods they share with an API key.

The Xuda JS Framework is not a CPI module you call, it is a browser runtime (the xuda() constructor, the xu-* attributes, the xu script API) and a local CLI (xuda-cli dev, sync, clean-readmes), both of which run outside any account credential. What they share with the rest of this API section is one thing: app data. The same five dbs_* methods a framework app or a JavaScript program calls at runtime through xu.dbs_read(...) are reachable directly with an account API key, so your own backend can read and write a project's tables without going through the runtime at all.

Reading and writing a table

dbs_read, dbs_create, dbs_update and dbs_delete all take the table's _id (never its display name) as table_id, dbs_restore takes the same table_id plus an array of row ids to bring a soft-deleted row back, and get_table_counts reads active and archived row counts. dbs_read takes an optional from/to row range, a row_id for a single row, a sortModel and a query object for filtering.

curl -s https://xuda.ai/cpi/dbs_read \
  -H 'content-type: application/json' \
  -d '{"api_key":"YOUR_API_KEY","app_id":"YOUR_APP_ID","table_id":"YOUR_TABLE_ID","from":0,"to":50}'
const res = await fetch('https://xuda.ai/cpi/dbs_read', {
  method: 'POST',
  headers: { 'content-type': 'application/json' },
  body: JSON.stringify({
    api_key: 'YOUR_API_KEY',
    app_id: 'YOUR_APP_ID',
    table_id: 'YOUR_TABLE_ID',
    from: 0,
    to: 50,
  }),
});
const { code, data } = await res.json();
import requests

res = requests.post(
    'https://xuda.ai/cpi/dbs_read',
    json={'api_key': 'YOUR_API_KEY', 'app_id': 'YOUR_APP_ID', 'table_id': 'YOUR_TABLE_ID', 'from': 0, 'to': 50},
)
Same methods, two callers

Inside a project, a javascript or api program reaches these through xu.dbs_create(...), xu.dbs_read(...) and so on, with app_id attached automatically. From outside, your own code calls the identical methods over /cpi with an API key. See JavaScript for the in-project side.

Everything else on this list is not an API method

get_app_system_api_methods, create_app_session, the create_*_api_key family and get_plugin_setup all appear in the framework's own runtime and CLI code, but every one of them is either private: true (session or dashboard-only) or not registered in cpi_methods at all, an in-process function the runtime calls directly rather than a dispatched method. The five dbs_* methods and get_table_counts are the only six with Availability: API key.

Methods