All APIs at a glance¶
Everything API Maker serves sits behind one base URL and the same token header. This page is the map ; every operation has its own page with examples.
This page opens the Build tab : the APIs, then your code, its languages, schema and data and SSR websites. Running them is in the Operate tab.
The URL of a table¶
| Segment | Meaning |
|---|---|
/api/schema or /api/gen |
The family : schema APIs apply the schema of the table, generated APIs are schemaless. |
user-path |
The API path of the admin or developer account which owns the instance (admin for the first admin). It is shown on the profile of the account. |
instance |
The name of the instance (the database server) in API Maker. For a tenant of a multi-tenant instance : instance::tenant. |
database |
The database on that server. |
table |
The table or collection. |
Generated (/api/gen) or schema (/api/schema) ?
Both families offer the same operations on the same URL pattern. The schema APIs read the schema of the table : values are converted to their types, validated, encrypted, defaulted and numbered before they reach the database. The generated APIs are schemaless : they pass your data as it is, so a number sent as "22" stays a string. Use the schema APIs for the tables your application writes to, and the generated APIs for quick reads and for tables without a schema.
Instances, databases and tables¶
APIs & Logic → Instance API (DB API) has four panels, left to right : instances, databases, tables, APIs. Pick one in each and the next panel fills.
- Instances : a connection to a database server (MongoDB, MySQL with TiDB and Percona, MariaDB, SQL Server, PostgreSQL, Oracle). Its name is part of every URL and can not change later. Its connection string is a key of the secret.
- Databases and tables : what the connection sees, with their settings and schemas.
- APIs : the operations below, each with its settings and Test API.
Every button of these panels is on the table designer page : adding an instance, making, editing and deleting databases and tables, and keeping the schemas in step.
The operations of a table¶
17 on a MongoDB collection, 14 on a table of the SQL databases.
The paths below follow /api/schema/<user-path>/<instance>/<database>/<table> (and the same under /api/gen). [/:primaryKey] names another column to use as the key.
| Operation | Method and path | Body | Page |
|---|---|---|---|
| Get all | GET / |
query params | Get all |
| Get all by stream | GET /stream |
query params | Get all by stream |
| Get by id | GET /get-by-id/:id[/:primaryKey] |
Get by id | |
| Save single or multiple | POST /save-single-or-multiple |
one object or an array | Save single or multiple |
| Master save | POST /master-save |
objects with nested related objects | Master save |
| Update by id | PUT /update-by-id/:id[/:primaryKey] |
the fields to change | Update by id |
| Update many | PUT /update-many |
{ find, updateData } |
Update many |
| Replace by id MongoDB | PUT /replace-by-id/:id[/:primaryKey] |
the whole document | Replace by id |
| Array operations MongoDB | PUT /array-operations |
{ find, operations } |
Array operations |
| Remove by id | DELETE /:id[/:primaryKey] |
Remove by id | |
| Remove by query | POST /query/delete |
{ find } |
Remove by query |
| Query for get data | POST /query |
{ find, select, sort, skip, limit, deep, getTotalCount } |
Query for get data |
| Query for get data by stream | POST /query-stream |
same as query | Query for get data by stream |
| Aggregate MongoDB | POST /aggregate |
a pipeline array | Aggregate |
| Count | POST /count |
{ find } |
Count |
| Distinct | GET /distinct/:field[/:order] |
Distinct | |
| Distinct with query | POST /distinct/:field[/:order] |
{ find } |
Distinct with query |
- MongoDB gets all 17. MySQL, MariaDB, SQL Server, PostgreSQL, Oracle, TiDB and Percona get 14 : replace by id, array operations and aggregate are MongoDB only.
- The schema operations exist for a table only once it has an active schema. The generated ones are always there.
- Their id in settings, groups, hooks and WebSocket subscriptions is
SCHEMA_GET_ALL,GEN_POST_BULK_INSERT… : the full list is under API ids.
Shared by every read¶
| Query params | find, skip, limit, sort, select, deep, getTotalCount, and any column name as a filter. In the body for the query APIs. |
| Request headers | Tokens, x-am-response-case, x-am-content-type-response, x-am-response-object-type, x-am-cache-control, x-am-get-encrypted-data, x-am-internationalization, x-am-tenant-username… |
| Response format | { success, statusCode, data, totalCount, errors, warnings, logs, meta } |
Your own APIs¶
| Family | Method and path | Page |
|---|---|---|
| Custom API | ANY /api/custom-api/<user-path>/<path> : the method and path of its settings |
Custom APIs |
| Pre and post hooks | run around every API of the account | Pre hook · Post hook |
| Events | emitted by an API hit or by code, with listeners | Events |
| WebSocket events | pushed to subscribed clients | WebSocket events |
| Schedulers | intervals and cron | Schedulers |
| Utility classes | shared code, import * as x from 'utils/X' |
Utility classes |
System APIs¶
All under /api/system-api/<user-path>/…, all POST, and all available in code as g.sys.system.* or g.sys.cache.*.
| Group | APIs |
|---|---|
| Security | /token · /encrypt-data · /decrypt-data · /hash-data · /get-secret-by-name |
| Redis and cache | /get-redis-key · /set-redis-key · /remove-redis-key · /reset-redis-cache-db · /reset-redis-cache-custom-apis · /reset-redis-cache-system-apis |
| Databases | /get-table-meta · /create-indexes · /drop-indexes · /get-indexes · /multi-tenant-instance-updated · /execute-plain-query · executeQuery from code |
| Events | /emit-event · /emit-event-ws |
| Validation | /is-valid-data-for-table · /is-valid-data-for-custom-api · /is-valid-connection-string |
| Outside | /call-external-api |
From your code¶
Every API above is a method of the global object g : g.sys.db.getAll, g.sys.db.gen.queryGen, g.sys.system.encrypt, g.sys.cache.setKey… with the same headers and query params, and an example for each one.
API ids¶
The ids used in groups, settings, hooks, events and WebSocket subscriptions.
Schema APIs
- SCHEMA_GET_ALL
- SCHEMA_GET_ALL_STREAM
- SCHEMA_GET_BY_ID
- SCHEMA_POST_BULK_INSERT
- SCHEMA_MASTER_SAVE
- SCHEMA_ARRAY_OPERATIONS
- SCHEMA_UPDATE_MANY
- SCHEMA_PUT_UPDATE_BY_ID
- SCHEMA_PUT_REPLACE_BY_ID
- SCHEMA_DEL_DELETE_BY_ID
- SCHEMA_POST_QUERY
- SCHEMA_POST_QUERY_STREAM
- SCHEMA_POST_QUERY_DELETE
- SCHEMA_POST_AGGREGATE
- SCHEMA_POST_COUNT
- SCHEMA_GET_DISTINCT
- SCHEMA_POST_DISTINCT_QUERY
Generated APIs
- GEN_GET_ALL
- GEN_GET_ALL_STREAM
- GEN_GET_BY_ID
- GEN_POST_BULK_INSERT
- GEN_MASTER_SAVE
- GEN_ARRAY_OPERATIONS
- GEN_UPDATE_MANY
- GEN_PUT_UPDATE_BY_ID
- GEN_PUT_REPLACE_BY_ID
- GEN_DEL_DELETE_BY_ID
- GEN_POST_QUERY
- GEN_POST_QUERY_STREAM
- GEN_POST_QUERY_DELETE
- GEN_POST_AGGREGATE
- GEN_POST_COUNT
- GEN_GET_DISTINCT
- GEN_POST_DISTINCT_QUERY
System APIs
- EXECUTE_PLAIN_QUERY
- ENCRYPT_DATA
- DECRYPT_DATA
- HASH_DATA
- GET_TOKEN
- CALL_EXTERNAL_API
- GET_SECRET
- GET_REDIS_KEY
- SET_REDIS_KEY
- REMOVE_REDIS_KEY
- CUSTOM_USER_CACHING
- RESET_REDIS_CACHE_DB
- RESET_REDIS_CACHE_CUSTOM_APIS
- RESET_REDIS_CACHE_SYSTEM_APIS
- GET_TABLE_META
- CREATE_INDEXES
- DROP_INDEXES
- GET_INDEXES
- EMIT_EVENT
- EMIT_EVENT_WS
- IS_VALID_DATA_FOR_TABLE
- IS_VALID_DATA_FOR_CUSTOM_API
- MULTI_TENANT_INSTANCE_UPDATED
- IS_VALID_CONNECTION_STRING