API Maker

The backend engine for the AI era

Chapters

What you will learn

  • Sign in, and what a new account holds
  • The default secret: a connection string and the password of the API user
  • A token from the token API, as an app gets it
  • The first write, and what the schema does on a save
  • Read back with deep populate, and a refusal with four errors
  • The rest of the sample: custom APIs and utility classes to learn from
In the docsYour first API in 10 minutes
Transcript895 words · click a time to play from there

Intro

Here is your first API, in ten minutes. A new account comes with a sample shop. Point it at a MongoDB, get a token, and then save, read, and break your first rows, with every check of a real backend.

A first API, the usual way

A first API usually means a lot of setup. You pick a framework, and scaffold a project. You add an ORM and a database driver. You write checks for every field. You add a token library. And you deploy a server, before the first row is saved. With API Maker, a new account already has its APIs. A connection string and a password are the whole setup. And every check comes from the schema.

In this video: the sign in, the sample of a new account, a connection string, a token, a category and a product, a read back, a refusal, and the rest of the sample.

Before you start

First, API Maker has to run. It can run on your computer, with API Maker Launchpad, in video fifty five. Or it can run on a server, with one command, in video sixty one. Both print the address of the admin panel, and how to sign in. At Calm Home, Sara Lindqvist, a backend engineer, gets her own account. The root user made it for her.

Sign in

The admin panel opens on its login card. Sara types her email, her password, and the letters of the captcha. She signs in, and sees her dashboard, with the same four panels as every account.

The sample

A new account is not empty. It has an instance named mongodb, and a database shop, with the schemas of five tables: categories, customers, products, orders, and their items. It has custom APIs to learn from, and hooks, an event, a migration script, and a utility class. Only one thing is missing: a MongoDB for the instance.

Step one: the secret

Open Security, then Secret Management, and the secret named Default. There are two values to set. The API user default has no password yet, so give it one. And set the connection string of the sample instance: the MongoDB of Sara, with her own login. Save it. The secret stays on this server. It never goes to Git. Open Instance API, and the instance mongodb. It has no database yet.

MongoDB makes one at the first write. Click Edit, and Test Instance. The connection works. There is nothing else to change.

Step two: a token

Now let us call it as an app does. Every call needs a token. The token API takes the API user and its password, and answers with a token, a refresh token, and how long the token lasts: three days. An app sends it in the header x-am-authorization.

Step three: the first write

Here is the first write: a category, through the schema API of its table. The address names the account, sara, then the instance, the database, and the table. We get two hundred and one: it is saved. API Maker made its id, and the schema made its slug from the name. And MongoDB made the database shop with it.

A product

In the panel, API Testing signs every call for you. Pick mongodb, then shop, which is there now, then products, and Save single or multiple. Type a product: a name with spaces around it, a currency in small letters, a price in cents, and its category, by the id of the first write. Send. We get two hundred and one. The name is trimmed, and the currency is in capitals.

status and is active got their defaults, and so did the dates. It has a product number from its counter, a public id, and a slug. All of it comes from the schema, without code.

Read it back

Now read it back, with Get all. In the query params, select four fields, and add deep, with only the name of the field, category. The schema knows where it points. Send. We get the product, with its category inside it, read in the same call.

A refusal

And now a refusal. Type a product with a name of one letter, a currency that the schema does not list, a price below zero, and a discount. Send. We get four hundred, with all four problems in one answer, each with its field. The last one is the message of a validator function in the schema: a discount needs an approver. Nothing was saved.

The rest of the sample

The sample has more to read. Open Custom API. The examples under default each show a feature, with comments: deep populate, find and join, caching, an upload, and a sign in. Most are No Access, so only code of the account calls them. And under APIs and Logic, Utility Classes has DefaultUtils, with helpers that every piece of code can use.

Where next

Where next? Connect your own databases, in video two. Write your own custom API, in video fourteen. Replace the default API user and group with small ones, in video twenty four. And let the security report check the account, in video twenty seven.

Recap

To sum up. A new account comes with a sample shop. You set a connection string and a password, in the secret. You get a token, from the token API. Rows are saved, and checked by their schema. They are read back with their relations. And every error comes in one answer. Next: call your APIs from a web app or a mobile app. API Maker. Build faster, spend smarter, deliver better.