Skip to content

Installation

There are two ways to install the Data API:

  • Generate a standalone Data API with the CLI (recommended to get started): the CLI reads your database schema and generates a ready-to-run Express app with all your models.
  • Add Adminmate to your existing Express app: install one npm package and add a few lines of code. Useful when your backend already runs on Express with Sequelize or Mongoose models.
  • Node.js 16 or later
  • A MySQL, PostgreSQL, SQLite or MongoDB database
  • An Adminmate account: sign up for free

Log in and create a new project. Choose a name (you can change it later) and your database type.

You then get a Project ID and a Secret Key. Keep them secret: they link your Data API to your Adminmate project.

Install the Adminmate CLI:

Terminal window
npm i adminmate-cli -g

Then run the command displayed in the Dashboard. It contains your project credentials and looks like this:

Terminal window
adminmate --name "My project" --id <project-id> --sk <secret-key> --db <database-type> --hash <token>

The CLI asks for:

  1. your database connection details (host, port, user, password, database name, and the schema for PostgreSQL);
  2. the master password you want to use to open your back-office.

The Dashboard follows the installation live. Once done, the CLI has generated a new folder:

my-project/
.env credentials and database URL
package.json
server.js the Express app
database.js the database connection
config/
adminmate.js the Adminmate configuration
models/ one file per table / collection
controllers/ empty, for your own code
middlewares/ empty, for your own code

Install the dependencies and start the Data API:

Terminal window
cd my-project
npm install
npm start

The Data API listens on port 3020 by default (set the PORT environment variable to change it). Go back to the Dashboard: your back-office opens at https://app.adminmate.io/<your-project-slug>.

2b. Add Adminmate to an existing Express app

Section titled “2b. Add Adminmate to an existing Express app”

Install the package matching your database:

Terminal window
# MySQL, PostgreSQL or SQLite (Sequelize)
npm install adminmate-express-sequelize
# MongoDB (Mongoose)
npm install adminmate-express-mongoose

Add Adminmate right after the creation of your Express app, before your own routes and authentication middlewares:

const express = require('express');
const Adminmate = require('adminmate-express-mongoose'); // or 'adminmate-express-sequelize'
const User = require('./models/user'); // your models
const app = express();
app.use(Adminmate.init({
projectId: process.env.AM_PROJECT_ID,
secretKey: process.env.AM_SECRET_KEY,
authKey: process.env.AM_AUTH_KEY,
masterPassword: process.env.AM_MASTER_PWD,
models: [
{ slug: 'users', model: User },
// one line per model you want to manage in Adminmate
]
}));
// ...your own middlewares and routes
  • AM_PROJECT_ID and AM_SECRET_KEY are given by the Dashboard.
  • AM_AUTH_KEY must be a long random string, for example generated with openssl rand -hex 32.
  • AM_MASTER_PWD is the password you will type to open your back-office. Choose a strong one.

Restart your server. Adminmate only adds routes under /adminmate/api, so it does not interfere with the rest of your app.

In the Dashboard, enter the URL where your Data API is reachable (for example http://localhost:3020) and your master password. Adminmate checks the connection and opens your back-office.

You can add other environments later (staging, production…) from Settings › Environments.

Et voilà! Next step: configure your back-office.