Sign in →

Developer Hub

Everything developers need to integrate with Aforo — SDKs, code samples, the API simulator, live event stream, and integration diagnostics.

Updated 2026-06-15Suggest edits

Developer Hub

The Developer Hub is where your customers (and your team) get everything needed to integrate with your API products — from quick-start code snippets to live event testing.

Integration Tiers

The Developer Hub organizes integrations into five tiers:

TierMethodWho Uses It
0 — GatewayAuto-capture via your API gateway pluginTeams already running Kong, Apigee, AWS, Azure, or MuleSoft
1 — MiddlewareExpress/Fastify/Django/Spring middlewareServer-side apps with request lifecycle access
2 — SDK@aforo/metering / aforo-meteringApplications without a gateway or middleware
3 — RESTDirect HTTP POST to usage-ingestorAny language, maximum flexibility
4 — File UploadBatch CSV/JSON uploadHistorical data migration, offline systems

Gateway Plugins

Aforo ships production-ready plugins for all major API gateways:

GatewayPlugin FileDetection
Kongkong-plugin-aforo-meteringLua log phase
Apigeeapigee-shared-flow-aforo-meteringJavaScript shared flow
AWS API Gatewayaws-lambda-aforo-meteringCloudWatch Logs Lambda
Azure APIMazure-apim-policy-aforo-meteringOutbound policy fragment
MuleSoftmulesoft-policy-aforo-meteringAnypoint custom policy

All plugins:

  • Auto-detect MCP tools/call JSON-RPC requests and extract tool_name + agent_id
  • Buffer events locally and batch-flush to usage-ingestor
  • Include exponential backoff with 3 retries
  • Handle gateway restarts without losing buffered events

SDK — Node.js

npm install @aforo/metering
import { AforoClient } from '@aforo/metering'

const aforo = new AforoClient({
  tenantId: process.env.AFORO_TENANT_ID,
  apiKey: process.env.AFORO_API_KEY,
  productId: 'prod_my_api',
})

// Wrap your route handler
app.use(aforo.middleware())

// Or record events directly
await aforo.ingest({
  customerId: req.user.customerId,
  metricId: 'api-calls',
  quantity: 1,
})

SDK — Python

pip install aforo-metering
from aforo_metering import AforoClient

aforo = AforoClient(
    tenant_id=os.getenv("AFORO_TENANT_ID"),
    api_key=os.getenv("AFORO_API_KEY"),
    product_id="prod_my_api"
)

# FastAPI middleware
app.add_middleware(aforo.middleware())

# Or record directly
await aforo.ingest(
    customer_id=request.user.customer_id,
    metric_id="api-calls",
    quantity=1
)

MCP Server SDKs

For MCP Server products, use the dedicated MCP metering SDKs:

// Node.js MCP SDK
import { billing } from '@aforo/mcp-metering'

server.tool("search", schema, billing.wrapToolHandler(async (args) => {
  // your tool implementation
  return { results: [...] }
}))

The SDK automatically records tool name, agent ID, execution duration, and status.

API Simulator

The API Simulator (Developer Hub → API Simulator) is a request builder for exercising any Aforo endpoint against live services without leaving the console:

  • Pick an endpoint from the reference tree, then fill path parameters ({id}, {customerId}) and query parameters in dedicated inputs — a live URL preview shows exactly what will be sent. Send stays disabled until every required path parameter is filled, so you never accidentally fire a request with a {placeholder} still in the URL.
  • Set the tenant id, extra headers, and a JSON body; your bearer token is injected automatically.
  • Run the request and inspect the status code, timing, and response body.
  • On a 4xx/5xx, an inline troubleshooting panel maps the status to the likely cause and fix (missing token, unfilled path parameter, wrong verb, rate limit, …).

The environment toggle controls write safety:

ModeBehavior
SandboxRead-only — only GET requests run. Write verbs (POST/PUT/PATCH/DELETE) are blocked, so there's no data impact.
ProductionWrites are allowed, but each one asks for confirmation — naming the method and the live URL — before it fires.

The simulator runs against live services; there is no isolated sandbox host yet, which is why Sandbox mode enforces read-only rather than implying isolation.

For the customer-facing try-it sandbox with multi-language code samples and saved request collections, see Sandbox Config.

Live Event Stream

Watch your usage events arrive in real time:

  • Connect via SSE to /v1/ingest/stream
  • Events appear within 2 seconds of ingestion
  • Filter by customer, product, or event type
  • Diagnose integration issues without reading logs

Integration Diagnostics

The Integration Diagnosis tool checks your integration health:

✓ Auth token valid
✓ Events received in last 24 hours
✓ No schema errors detected
⚠ 3 events with missing customerId field
✗ Last event 6 hours ago — expected frequency: 1/minute

Run a diagnostic:

Webhook Sources

If your data originates from third-party webhooks (Stripe, Twilio, SendGrid, GitHub, Slack), configure a Webhook Source to ingest those events as Aforo usage events:

  1. Go to Developer Hub → Webhook Sources
  2. Select a template or create custom
  3. Configure JSONPath extraction rules
  4. Copy the Aforo webhook receiver URL
  5. Paste it as the webhook destination in the third-party service