Skip to content

Quick Start

Get APIForge running in your application in under 5 minutes.

Node.js — Express.js

Requirements

  • Node.js 22.5 or higher (uses the built-in node:sqlite module)
  • An Express.js application (v4 or v5)

Installation

bash
npm install apiforgejs

Add the middleware

js
const express = require('express')
const { apiforge } = require('apiforgejs')

const app = express()

app.use(apiforge())

app.get('/users/:id', (req, res) => {
  res.json({ id: req.params.id })
})

app.listen(3000)
// Dashboard → http://localhost:4242
js
const express = require('express')
const { apiforge } = require('apiforgejs')

const app = express()

app.use(apiforge({
  cloudUrl: 'https://api.apiforge.fr',
  apiKey:   process.env.APIFORGE_API_KEY,
  service:  'my-api',
}))

app.listen(3000)

ESM projects

js
import { apiforge } from 'apiforgejs'

Python — FastAPI / Starlette

Requirements

  • Python 3.11 or higher
  • A FastAPI or Starlette application

Installation

bash
pip install apiforgepy

Add the middleware

python
from fastapi import FastAPI
from apiforgepy import ApiForgeMiddleware

app = FastAPI()

app.add_middleware(ApiForgeMiddleware)

@app.get("/users/{user_id}")
def get_user(user_id: int):
    return {"id": user_id}

# Dashboard → http://localhost:4242
python
import os
from fastapi import FastAPI
from apiforgepy import ApiForgeMiddleware

app = FastAPI()

app.add_middleware(
    ApiForgeMiddleware,
    cloud_url=os.environ["APIFORGE_CLOUD_URL"],
    api_key=os.environ["APIFORGE_API_KEY"],
    service="my-api",
)

PHP — Laravel

Requirements

  • PHP 8.2 or higher
  • Laravel 10 or higher
  • pdo_sqlite extension (apt install php8.x-sqlite3 on Debian/Ubuntu)

Installation

bash
composer require apiforge/apiforgephp

Add the middleware

The service provider is auto-discovered. Register the middleware in bootstrap/app.php (Laravel 11+) or app/Http/Kernel.php (Laravel 10):

php
// bootstrap/app.php
->withMiddleware(function (Middleware $middleware) {
    $middleware->append(\ApiForge\Laravel\ApiForgeMiddleware::class);
})

// Dashboard → http://localhost:8000/_apiforge
php
// app/Http/Kernel.php
protected $middleware = [
    // ...
    \ApiForge\Laravel\ApiForgeMiddleware::class,
];

// Dashboard → http://localhost:8000/_apiforge
php
// .env
// APIFORGE_CLOUD_URL=https://api.apiforge.fr
// APIFORGE_API_KEY=af_...

// bootstrap/app.php — same registration, mode is detected from env vars
->withMiddleware(function (Middleware $middleware) {
    $middleware->append(\ApiForge\Laravel\ApiForgeMiddleware::class);
})

PHP dashboard location

In PHP/Laravel, the local dashboard is served at /_apiforge on your app's port — no separate HTTP server is started.


Open the local dashboard

Once your server receives its first requests, open:

txt
http://localhost:4242
txt
http://localhost:8000/_apiforge

You'll see:

  • Health Score — a 0–100 score summarizing your API's health
  • Latency per endpoint — P50, P90, P99 in real time
  • Error rate by route — 2xx / 4xx / 5xx breakdown
  • Automatic insights — plain-language alerts, no configuration needed

First metrics

The dashboard aggregates data every 60 seconds by default. Send a few requests to your API, wait one minute, and refresh — your first metrics will appear.

Cloud mode

In cloud mode the local dashboard is not started. Metrics are sent to the APIForge SaaS and displayed in the cloud dashboard. See Cloud Mode.

What's next

Released under the MIT License.