API Maker

The framework for AI era

Your code

System APIs

Ready APIs for the jobs every backend has: encryption, secrets, Redis, cache, validation, tokens and events.

API Maker comes with 21 system APIs. Your code calls them with g.sys, and you can open any of them to clients as a REST API under /api/system-api. They have settings and hooks like every other API.

See it live

Step through it, slow it down, or open the full canvas.

api-maker/features/inbuilt-systemLive
  • Call
  • Result
  • Secret / Redis
  • Error
System APIs
21ready
Groups
6of tools
Ways to call
2REST · g.sys
Calls
0in this tour

21 system APIs, ready to use. Encryption, secrets and Redis, cache reset, data validation, events and utilities. Call them as REST APIs, or with g.sys in your code.

How it works

  1. 21 system APIs, ready to use.

    Encryption, secrets and Redis, cache reset, data validation, events and utilities. Call them as REST APIs, or with g.sys in your code.

  2. Encrypt, decrypt and hash, one line each.

    The algorithm and key come from your Secret: AES by default, RC4 or TripleDES. The hash is an HMAC SHA-256, it can not be reversed.

  3. Secrets and Redis at hand.

    Read any key of your encrypted Secret. Set, read and remove Redis keys with a TTL: OTPs, sessions, locks.

  4. Reset a cache when your logic needs it.

    The cache of a table, of a custom API, of system APIs or of third party APIs. You get back how many Redis keys were removed.

  5. Check data without saving it.

    The validation of a save runs against the schema of a table, a custom API or a third party API, and every error comes back.

  6. Events, tokens and external APIs.

    Emit events to their listeners or to WebSockets, get tokens for your users, call external APIs in parallel or in sequence.

What you get

Encrypt, decrypt, hash

Encrypt and decrypt with the algorithm and key of your secret (AES by default, RC4 or TripleDES) or with your own. Hash with HMAC SHA-256.

Secrets and Redis

Read keys of your secret. Get, set and remove Redis keys with a TTL, and set only if absent: OTPs, sessions, locks.

Cache resets

Clear the cache of a table, a custom API or the system APIs. The answer says how many keys were removed.

Validation without saving

Run the validation of a table or a custom API on some data and get every error back.

Tokens

get token signs in API users and the users of your own tables, and returns a token, a refresh token and its expiry.

External APIs, events and more

Call external APIs in parallel or in sequence and pass values from one answer to the next request. Emit events and WebSocket events. Read table metadata, check a connection string, reset the pools of a moved tenant.

An example

A one-time password: kept in Redis, sent with a key from the secretcustom-api.ts
import * as T from 'types';async function main(g: T.IAMGlobal) {    const otp = String(Math.floor(100000 + Math.random() * 900000));    await g.sys.cache.setKey(`otp:${g.req.body.phone}`, otp, 300); // expires in 5 minutes    const smsKey = await g.sys.system.getSecret('sms.apiKey');    const sent = await g.sys.system.callExternalApi({        url: 'https://sms.example.com/v1/messages',        method: 'POST',        headers: { Authorization: `Bearer ${smsKey}` },        body: { to: g.req.body.phone, text: `Your code is ${otp}` },    });    return { sent: sent.statusCode === 200 };}module.exports = main;
A system API over REST, once opened in its settingsrequest
POST /api/system-api/admin/hash-datax-am-authorization: <API user token>{ "name": "Joseph" }

The answer is the HMAC SHA-256 of the body, in hex, in data.

Good to know

  • System APIs other than get token can not be called from outside until their settings give them an access type. From your code they can be called.
  • Encryption and hashing use the keys of your secret: changing them later does not re-encrypt data already stored.

Questions

Which system APIs are there?

encrypt-data, decrypt-data, hash-data, token, call-external-api, get-secret-by-name, get-redis-key, set-redis-key, remove-redis-key, the four reset caches (database, custom APIs, system APIs, third party APIs), get-table-meta, emit-event, emit-event-ws, the three is-valid-data checks (table, custom API, third party API), multi-tenant-instance-updated and is-valid-connection-string.

Can my code run a raw query?

Yes. g.sys.system.executeQuery runs SQL on a SQL instance, or a command on MongoDB.

Can I cache or hook a system API?

Yes. Each system API has settings with enableCaching, its access type and auth providers, and pre and post hooks.