# System APIs from Code

> Every system API of API Maker called from your code with g.sys.system and g.sys.cache - encryption, hashing, tokens, secrets, plain queries, indexes, events, validations, external APIs and Redis - each with its page and its code in eight languages.

Source: https://docs.apimaker.dev/v4/examples/sys/system/system.html

Your code calls every [system API](https://docs.apimaker.dev/v4/docs/apis-all/overview.html#system-apis) through `g.sys.system` and `g.sys.cache`, whatever the settings of the API say about HTTP callers. Each API has one page : the HTTP call first, then **From code** with the code in eight languages.

## g.sys.system

| Method | What it does | Page |
|---|---|---|
| `encrypt`, `decrypt` | Encrypt and decrypt a value with the transfer key of the secret, or your own | [Encrypt](https://docs.apimaker.dev/v4/docs/apis-all/system-apis/system-generated-encrypt-data-api.html#from-code) · [Decrypt](https://docs.apimaker.dev/v4/docs/apis-all/system-apis/system-generated-decrypt-data-api.html#from-code) |
| `hash` | The hash a hashed column stores, to look a row up | [Hash data](https://docs.apimaker.dev/v4/docs/apis-all/system-apis/system-generated-hash-data-api.html#look-up-a-hashed-column) |
| `getToken` | The token of an API user, or of a person | [Get token](https://docs.apimaker.dev/v4/docs/apis-all/system-apis/system-generated-token-api.html#from-code) |
| `getSecret` | A key of a secret, or several | [Get secret](https://docs.apimaker.dev/v4/docs/apis-all/system-apis/system-generated-get-secret-by-name-api.html#from-code) |
| `executeQuery` | A plain query of the database : SQL, or a command of MongoDB | [Examples](https://docs.apimaker.dev/v4/examples/sys/system/executeQuery.html) · [Execute plain query](https://docs.apimaker.dev/v4/docs/apis-all/system-apis/system-generated-execute-plain-query-api.html) |
| `callExternalApi` | Call another API over HTTP : one call, several in parallel or in sequence, files | [Examples](https://docs.apimaker.dev/v4/examples/sys/system/callExternalApi.html) · [Call external API](https://docs.apimaker.dev/v4/docs/apis-all/system-apis/system-generated-call-external-api.html#from-code) |
| `getTableMeta` | The columns of a table, as its database has them | [Get table meta](https://docs.apimaker.dev/v4/docs/apis-all/system-apis/system-generated-get-table-meta-api.html#from-code) |
| `createIndexes`, `dropIndexes`, `getIndexes` | Indexes in the same words on every database | [Create](https://docs.apimaker.dev/v4/docs/apis-all/system-apis/system-generated-create-indexes-api.html#from-code) · [Drop](https://docs.apimaker.dev/v4/docs/apis-all/system-apis/system-generated-drop-indexes-api.html#from-code) · [Get](https://docs.apimaker.dev/v4/docs/apis-all/system-apis/system-generated-get-indexes-api.html#from-code) |
| `emitEvent`, `emitEventWS` | Run the listeners of an event, or tell WebSocket clients | [Emit event](https://docs.apimaker.dev/v4/docs/apis-all/system-apis/system-generated-emit-event-api.html#from-code) · [Emit WebSocket event](https://docs.apimaker.dev/v4/docs/apis-all/system-apis/system-generated-emit-event-ws-api.html#from-code) |
| `isValidDataForTable`, `isValidDataForCustomAPI` | Check data against a schema, or the body of a custom API, before you use it | [For a table](https://docs.apimaker.dev/v4/docs/apis-all/system-apis/system-generated-is-valid-data-for-table-api.html#from-code) · [For a custom API](https://docs.apimaker.dev/v4/docs/apis-all/system-apis/system-generated-is-valid-data-for-custom-api.html#from-code) |
| `isValidConnectionString` | Try a connection string before you save it | [Is valid connection string](https://docs.apimaker.dev/v4/docs/apis-all/system-apis/system-generated-is-valid-connection-string-api.html#from-code) |
| `multiTenantInstanceUpdated` | Tell every server that the connection of a tenant changed | [Multi tenant instance updated](https://docs.apimaker.dev/v4/docs/apis-all/system-apis/system-generated-multi-tenant-instance-updated-api.html#from-code) |

## g.sys.cache

| Method | What it does | Page |
|---|---|---|
| `getKey`, `setKey`, `removeKey` | Keys of your own in Redis, with a time to live | [Get](https://docs.apimaker.dev/v4/docs/apis-all/system-apis/system-generated-get-redis-key-api.html#from-code) · [Set](https://docs.apimaker.dev/v4/docs/apis-all/system-apis/system-generated-set-redis-key-api.html#from-code) · [Remove](https://docs.apimaker.dev/v4/docs/apis-all/system-apis/system-generated-remove-redis-key-api.html#from-code) |
| `resetCacheDB`, `resetCacheCustomApis`, `resetCacheSystemApis` | Drop the cached answers of a table, a custom API or a system API | [Database](https://docs.apimaker.dev/v4/docs/apis-all/system-apis/system-generated-reset-redis-cache-db-api.html#from-code) · [Custom API](https://docs.apimaker.dev/v4/docs/apis-all/system-apis/system-generated-reset-redis-cache-custom-api.html#from-code) · [System API](https://docs.apimaker.dev/v4/docs/apis-all/system-apis/system-generated-reset-redis-cache-system-api.html#from-code) |

## Good to know

- A call answers `data`, and throws the errors : the caller of your API gets them. In the languages other than TypeScript, `full` gives the whole response envelope (`g.sys.system.full` in Python…) : see the page of your [language](https://docs.apimaker.dev/v4/docs/languages/index.html).
- Every call takes the [request headers](https://docs.apimaker.dev/v4/docs/apis-all/header/requestHeader.html) of its HTTP form, such as `x-am-tenant-username`.
