# All APIs at a Glance

> Every API of API Maker on one page - the 17 operations of a table under /api/schema and /api/gen with their method and URL, the custom, system and third party APIs, the query params and headers they share, and how to call them from your code.

Source: https://docs.apimaker.dev/v1/docs/apis-all/overview.html

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.

> Diagram : The API families : one base URL, one token, five HTTP families and the code API Maker runs for you

## The URL of a table

> Diagram : Anatomy of a database API URL : /api/schema/admin/mysql8/inventory/customers/get-by-id/42

| 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](/v1/docs/features/multi-tenant.html) instance : `instance::tenant`. |
| `database` | The database on that server. |
| `table` | The table or collection. |

!!! info "Generated (`/api/gen`) or schema (`/api/schema`) ?"
    Both families offer the same operations on the same URL pattern. The **schema APIs** read the [schema](/v1/docs/schema/schema.html) 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 { #instances }

`API Info → DB API` has four panels, left to right : instances, databases, tables, APIs. Pick one in each and the next panel fills.

| Panel | What it holds |
|---|---|
| Instances | A connection to a database server : MongoDB, MySQL (TiDB, Percona), MariaDB, SQL Server, PostgreSQL, Oracle. **Add New** takes the database type, a unique **Instance Name** (used in every URL and in code, it can not change later), the **Connection String** picked among the keys of the [secret](/v1/docs/secrets/secrets.html) and **Max Pool Connections** ; Oracle adds the username, the password and the privilege. Saving tests the connection first : an instance which can not connect is not saved. |
| Databases | The databases the connection sees, with their [settings](/v1/docs/settings/databaseSettings.html). **Bulk Schema Creation** generates the schema of every table at once ; **Compact Database** reclaims space on MongoDB. |
| Tables | The tables or collections, with their [schema](/v1/docs/schema/schema.html), their indexes and their [settings](/v1/docs/settings/collectionSettings.html). **Structure changed** appears when the columns of a table differ from its schema : click to compare and update. |
| APIs | The operations below, each with its [settings](/v1/docs/settings/apiSettings.html) and **Test API**, which opens the [API testing page](/v1/docs/features/developer-tools.html#api-testing-page) on it. |

- **Connection String Sandbox** : another string for the code which runs in the sandbox, when the sandbox reaches the database through another address. Empty, the main one is used.
- **Is Multi Tenant Structure Instance** and **Connection String Multi Tenant** make a [multi-tenant](/v1/docs/features/multi-tenant.html) instance ; **Select tenant** then loads the databases of one tenant.

## The 17 operations of a table

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 (schema · gen) |
|---|---|---|---|
| Get all | GET `/` | query params | [schema](/v1/docs/apis-all/schema-apis/auto-generated-schema-based-get-all-api.html) · [gen](/v1/docs/apis-all/generated-apis/auto-generated-get-all-api.html) |
| Get all by stream | GET `/stream` | query params | [schema](/v1/docs/apis-all/schema-apis/auto-generated-schema-based-get-all-by-stream-api.html) · [gen](/v1/docs/apis-all/generated-apis/auto-generated-get-all-by-stream-api.html) |
| Get by id | GET `/get-by-id/:id[/:primaryKey]` | | [schema](/v1/docs/apis-all/schema-apis/auto-generated-schema-based-get-by-id-api.html) · [gen](/v1/docs/apis-all/generated-apis/auto-generated-get-by-id-api.html) |
| Save single or multiple | POST `/save-single-or-multiple` | one object or an array | [schema](/v1/docs/apis-all/schema-apis/auto-generated-schema-based-save-single-or-multiple-api.html) · [gen](/v1/docs/apis-all/generated-apis/auto-generated-save-single-or-multiple-api.html) |
| Master save | POST `/master-save` | objects with nested related objects | [schema](/v1/docs/apis-all/schema-apis/auto-generated-schema-based-master-save-api.html) · [gen](/v1/docs/apis-all/generated-apis/auto-generated-master-save-api.html) |
| Update by id | PUT `/update-by-id/:id[/:primaryKey]` | the fields to change | [schema](/v1/docs/apis-all/schema-apis/auto-generated-schema-based-update-by-id-api.html) · [gen](/v1/docs/apis-all/generated-apis/auto-generated-update-by-id-api.html) |
| Update many | PUT `/update-many` | `{ find, updateData }` | [schema](/v1/docs/apis-all/schema-apis/auto-generated-schema-based-update-many-api.html) · [gen](/v1/docs/apis-all/generated-apis/auto-generated-update-many-api.html) |
| Replace by id MongoDB | PUT `/replace-by-id/:id[/:primaryKey]` | the whole document | [schema](/v1/docs/apis-all/schema-apis/auto-generated-schema-based-replace-by-id-api.html) · [gen](/v1/docs/apis-all/generated-apis/auto-generated-replace-by-id-api.html) |
| Array operations MongoDB | PUT `/array-operations` | `{ find, operations }` | [schema](/v1/docs/apis-all/schema-apis/auto-generated-schema-based-array-operations-api.html) · [gen](/v1/docs/apis-all/generated-apis/auto-generated-array-operations-api.html) |
| Remove by id | DELETE `/:id[/:primaryKey]` | | [schema](/v1/docs/apis-all/schema-apis/auto-generated-schema-based-remove-by-id-api.html) · [gen](/v1/docs/apis-all/generated-apis/auto-generated-remove-by-id-api.html) |
| Remove by query | POST `/query/delete` | `{ find }` | [schema](/v1/docs/apis-all/schema-apis/auto-generated-schema-based-remove-by-query-api.html) · [gen](/v1/docs/apis-all/generated-apis/auto-generated-remove-by-query-api.html) |
| Query for get data | POST `/query` | `{ find, select, sort, skip, limit, deep, getTotalCount }` | [schema](/v1/docs/apis-all/schema-apis/auto-generated-schema-based-query-for-get-data-api.html) · [gen](/v1/docs/apis-all/generated-apis/auto-generated-query-for-get-data-api.html) |
| Query for get data by stream | POST `/query-stream` | same as query | [schema](/v1/docs/apis-all/schema-apis/auto-generated-schema-based-query-for-get-data-by-stream-api.html) · [gen](/v1/docs/apis-all/generated-apis/auto-generated-query-for-get-data-by-stream-api.html) |
| Aggregate MongoDB | POST `/aggregate` | a pipeline array | [schema](/v1/docs/apis-all/schema-apis/auto-generated-schema-based-aggregate-api.html) · [gen](/v1/docs/apis-all/generated-apis/auto-generated-aggregate-api.html) |
| Count | POST `/count` | `{ find }` | [schema](/v1/docs/apis-all/schema-apis/auto-generated-schema-based-count-api.html) · [gen](/v1/docs/apis-all/generated-apis/auto-generated-count-api.html) |
| Distinct | GET `/distinct/:field[/:order]` | | [schema](/v1/docs/apis-all/schema-apis/auto-generated-schema-based-distinct-api.html) · [gen](/v1/docs/apis-all/generated-apis/auto-generated-distinct-api.html) |
| Distinct with query | POST `/distinct/:field[/:order]` | `{ find }` | [schema](/v1/docs/apis-all/schema-apis/auto-generated-schema-based-distinct-with-query-api.html) · [gen](/v1/docs/apis-all/generated-apis/auto-generated-distinct-with-query-api.html) |

- **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](/v1/docs/schema/schema.html). 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](#api-ids).

## Shared by every read

| | |
|---|---|
| [Query params](/v1/docs/apis-all/query-params/query-params.html) | `find`, `skip`, `limit`, `sort`, `select`, `deep`, `getTotalCount`, and any column name as a filter. In the body for the query APIs. |
| [Request headers](/v1/docs/apis-all/header/requestHeader.html) | 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](/v1/docs/apis-all/response-format.html) | `{ 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](/v1/docs/apis-all/custom-apis/user-created-custom-api.html) |
| Pre and post hooks | run around every API of the account | [Pre hook](/v1/docs/apis-all/hooks/preHook-api.html) · [Post hook](/v1/docs/apis-all/hooks/postHook-api.html) |
| Events | emitted by an API hit or by code, with listeners | [Events](/v1/docs/apis-all/events/user-created-events-api.html) |
| WebSocket events | pushed to subscribed clients | [WebSocket events](/v1/docs/pages/web-socket-event-page.html) |
| Schedulers | intervals and cron | [Schedulers](/v1/docs/apis-all/schedulers/user-created-schedulers-api.html) |
| Utility classes | shared code, `import * as x from 'utils/X'` | [Utility classes](/v1/docs/utility-class/utility-class.html) |

## 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`](/v1/docs/apis-all/system-apis/system-generated-token-api.html) · [`/encrypt-data`](/v1/docs/apis-all/system-apis/system-generated-encrypt-data-api.html) · [`/decrypt-data`](/v1/docs/apis-all/system-apis/system-generated-decrypt-data-api.html) · [`/hash-data`](/v1/docs/apis-all/system-apis/system-generated-hash-data-api.html) · [`/get-secret-by-name`](/v1/docs/apis-all/system-apis/system-generated-get-secret-by-name-api.html) |
| Redis and cache | [`/get-redis-key`](/v1/docs/apis-all/system-apis/system-generated-get-redis-key-api.html) · [`/set-redis-key`](/v1/docs/apis-all/system-apis/system-generated-set-redis-key-api.html) · [`/remove-redis-key`](/v1/docs/apis-all/system-apis/system-generated-remove-redis-key-api.html) · [`/reset-redis-cache-db`](/v1/docs/apis-all/system-apis/system-generated-reset-redis-cache-db-api.html) · [`/reset-redis-cache-custom-apis`](/v1/docs/apis-all/system-apis/system-generated-reset-redis-cache-custom-api.html) · [`/reset-redis-cache-system-apis`](/v1/docs/apis-all/system-apis/system-generated-reset-redis-cache-system-api.html) · [`/reset-redis-cache-third-party-apis`](/v1/docs/apis-all/system-apis/system-generated-reset-redis-cache-third-party-api.html) |
| Databases | [`/get-table-meta`](/v1/docs/apis-all/system-apis/system-generated-get-table-meta-api.html) · [`/create-indexes`](/v1/docs/apis-all/system-apis/system-generated-create-indexes-api.html) · [`/drop-indexes`](/v1/docs/apis-all/system-apis/system-generated-drop-indexes-api.html) · [`/get-indexes`](/v1/docs/apis-all/system-apis/system-generated-get-indexes-api.html) · [`/multi-tenant-instance-updated`](/v1/docs/apis-all/system-apis/system-generated-multi-tenant-instance-updated-api.html) · `executeQuery` from [code](/v1/examples/sys/system/executeQuery.html) |
| Events | [`/emit-event`](/v1/docs/apis-all/system-apis/system-generated-emit-event-api.html) · [`/emit-event-ws`](/v1/docs/apis-all/system-apis/system-generated-emit-event-ws-api.html) |
| Validation | [`/is-valid-data-for-table`](/v1/docs/apis-all/system-apis/system-generated-is-valid-data-for-table-api.html) · [`/is-valid-data-for-custom-api`](/v1/docs/apis-all/system-apis/system-generated-is-valid-data-for-custom-api.html) · [`/is-valid-data-for-third-party-api`](/v1/docs/apis-all/system-apis/system-generated-is-valid-data-for-third-party-api.html) |
| Outside | [`/call-external-api`](/v1/docs/apis-all/system-apis/system-generated-call-external-api.html) |

## From your code

Every API above is a method of the [global object `g`](/v1/docs/pre-defined-terms/global-object-g.html) : `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](/v1/examples/index.html).

```typescript linenums="1"
import * as T from 'types';
import * as db from 'db-interfaces';

async function main(g: T.IAMGlobal) {
    const products = await g.sys.db.getAll<db.mongodb.shop.IProducts>({
        instance: 'mongodb', database: 'shop', collection: 'products',
        queryParams: { find: { status: 'ACTIVE' }, limit: 10, deep: [{ s_key: 'category' }] },
    });
    return products;
}
module.exports = main;
```

## API ids { #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
- RESET_REDIS_CACHE_TP_APIS
- GET_TABLE_META
- EMIT_EVENT
- EMIT_EVENT_WS
- IS_VALID_DATA_FOR_TABLE
- IS_VALID_DATA_FOR_CUSTOM_API
- IS_VALID_DATA_FOR_THIRD_PARTY_API
