Setup your development

Learn how to update your docs locally and and deploy them to the public.

Install ApiTraffic

npm install @apitraffic/express

Configure your API

Add ApiTraffic to your Express application:
const express = require('express');
const apiTraffic = require('@apitraffic/express');

const app = express();

// Configure ApiTraffic
app.use(apiTraffic({
  token: 'your-api-token',
  bucket: 'your-bucket-id',
  interceptOutbound: true
}));

// Your existing routes
app.get('/api/users', (req, res) => {
  res.json({ users: [] });
});

app.listen(3000, () => {
  console.log('Server running on port 3000');
});

Environment Variables

Set up your environment variables:
.env
API_TRAFFIC_TOKEN=your-api-token
API_TRAFFIC_BUCKET=your-bucket-id
API_TRAFFIC_INGEST_HOST=ingest.apitraffic.io
API_TRAFFIC_API_HOST=api.apitraffic.io

Verify Installation

Start your application and make a test request:
curl http://localhost:3000/api/users
Check your ApiTraffic dashboard to see the request data flowing in.

Next Steps