api-observatory-node-sdk-2026
v1.0.0
Published
Backend API monitoring middleware
Downloads
7
Readme
api-monitor
A lightweight Node.js SDK for real-time API monitoring, request/response logging, and performance tracking.
Features
- Express Middleware: Automatically capture incoming requests and outgoing responses.
- Axios Interceptor: Monitor outgoing API calls made by your application.
- Asynchronous Logging: Uses Redis and BullMQ to process logs in the background without affecting app performance.
- Data Masking: Built-in support for masking sensitive fields like passwords, tokens, and cookies.
Installation
npm install api-monitorSetup
1. Initialize Middleware (Express)
const express = require('express');
const { monitor } = require('api-monitor');
const app = express();
app.use(monitor({
apiKey: 'YOUR_API_KEY',
projectId: 'YOUR_PROJECT_ID',
orgId: 'YOUR_ORG_ID'
}));2. Initialize Axios Interceptor
const { createAxiosInterceptor } = require('api-monitor');
const api = createAxiosInterceptor({
apiKey: 'YOUR_API_KEY',
projectId: 'YOUR_PROJECT_ID',
orgId: 'YOUR_ORG_ID'
});
// Use 'api' instead of base axios
api.get('/users').then(res => console.log(res.data));3. Start the Background Worker
The SDK uses a background worker to send logs to the monitoring dashboard. You should run this as a separate process in your production environment.
# In your package.json, add a script:
# "monitor-worker": "node node_modules/api-monitor/dist/queue/worker.js"
npm run monitor-workerConfiguration
| Option | Type | Description |
| --- | --- | --- |
| apiKey | string | Your unique API Key from the dashboard. |
| projectId | string | The ID of the project you are monitoring. |
| orgId | string | Your Organization ID. |
| endpoint | string | (Optional) Custom digestion endpoint URL. |
License
MIT
