# Fastify API monitoring and traffic logging - ApiTraffic

> Fastify API traffic monitoring: every request logged with its latency, queries and firewall verdict. Installs as a Fastify plugin, no agent. Free trial.

Source: https://www.apitraffic.io/fastify

Fastify · First-party SDK

# Fastify API monitoring that sees every request.Including the half that isn’t human.

A plugin registration, not a wrapper. Encapsulation intact, hooks intact, one record per request.

Source: [Imperva 2026 Bad Bot Report](https://www.imperva.com/blog/bad-bot-report-2026-bots-agentic-age/)

[Start your free trial](https://app.apitraffic.io/signup?src=framework-fastify)

`npm i @apitraffic/node`

```
const fastify = require('fastify')({ logger: true });
const apitraffic = require('@apitraffic/node');

await fastify.register(apitraffic.fastify({
  token: process.env.API_TRAFFIC_TOKEN,
  bucket: process.env.API_TRAFFIC_BUCKET,
}));

fastify.get('/users/:id', async (request) => {
  return { id: request.params.id };
});

await fastify.listen({ port: 3000 });
```

Register at the root so every encapsulated plugin context is covered.

Fastify 4 and 5 · Node 20+ · types included · [Fastify setup guide](/docs/integrations/fastify) · [read the middleware source](https://github.com/apitraffic/apitraffic-node)

Fastify

## What this looks like in Fastify

### Hooks fire in a specific order, and it changes what you see

Register us as a plugin and we attach at the lifecycle points that carry the full picture - the request as parsed, the reply as sent, and the time between them. You do not wire onRequest, preHandler and onResponse yourself and hope they agree.

### Encapsulation hides things from tooling that assumes globals

Fastify scopes plugins deliberately. We register at the root so every encapsulated context is covered, rather than instrumenting one branch of your plugin tree and quietly missing the rest.

### Schema-fast routes make overhead visible

Fastify is chosen by people who measure. Nothing that matters runs on your request path - metadata goes to a buffer and ships in batches off the event loop, with no synchronous work between your handler and the response.

API traffic monitoring

## Every Fastify request, with its queries and its verdict attached

One pass through one middleware: the payload, every query and outbound call it caused, and the firewall's decision - on one record, watched for incidents, drift and regressions.

Pricing

## Simple, published pricing

Every plan and what it includes, read live from our billing system - with a free trial and no credit card to start.

### Solo

**$79**per month

[Start free trial](https://app.apitraffic.io/signup?src=pricing-solo&plan=price_1UUP2PGd1hpzf7btIBNo2B7n)Retention: 30 days of request history

Replaces a request logger, an APM, an alerting tool and a WAF

Usage & limits

- 1M requests · Captured requests (then $0.08 per 1,000 requests)
- 5 buckets · Buckets

- 2 environments · Environments
- 1 seat · Team members

Logging & search

- 30 days · Retention window

Firewall

- 2 policies · WAF policies per account

Alerts & drift

- 1 channel · Alert channels

Integrations

- 1 repository · Linked repositories

Most Popular

### Team

**$249**per month

[Start free trial](https://app.apitraffic.io/signup?src=pricing-team&plan=price_1UUP5XGd1hpzf7btNbVtj7rG)Retention: 180 days of request history

Replaces a request logger, an APM, an alerting tool and a WAF

Usage & limits

- 5M requests · Captured requests (then $0.05 per 1,000 requests)
- 20 buckets · Buckets

- 5 environments · Environments
- 20 seats · Team members

Logging & search

- 180 days · Retention window

Firewall

- 10 policies · WAF policies per account

Alerts & drift

- Unlimited · Alert channels

Integrations

- 5 repositories · Linked repositories

### Business

**$799**per month

[Start free trial](https://app.apitraffic.io/signup?src=pricing-business&plan=price_1UUP6EGd1hpzf7btkWE96uu3)Retention: 365 days of request history

Replaces a request logger, an APM, an alerting tool and a WAF

Usage & limits

- 25M requests · Captured requests (then $0.03 per 1,000 requests)
- 100 buckets · Buckets

- 20 environments · Environments
- Unlimited · Team members

Logging & search

- 365 days · Retention window

Firewall

- Unlimited · WAF policies per account

Compliance

- Compliance

Alerts & drift

- Unlimited · Alert channels

Integrations

- Unlimited · Linked repositories

[Compare all plan features](#compare)

Every plan starts with a 7-day free trial - no credit card to begin, and nothing is charged unless you choose a plan.

**One bill instead of four:** logging, APM, alerting and a firewall on every plan. On Team, that is less than $0.05 per 1,000 captured requests, with all four included.

Prices in the currency shown, excluding tax. Overage is billed per unit and rounded to the cent on the invoice.

FAQ

## Fastify API monitoring questions

Install @apitraffic/node and register apitraffic.fastify() with fastify.register(), passing your ingest token and bucket. Every request is then recorded, with no agent or sidecar to run.

Fastify 4 and 5, on Node 20 or later. TypeScript types are included.

No network call to ApiTraffic happens between your handler and your response: the SDK records each request in-process and returns immediately, and payloads are batched, compressed and sent in the background. If ApiTraffic is unreachable, your API keeps serving requests.

The method, the endpoint it matched (so /users/42 and /users/43 group as one), the status, timing, headers and bodies, and the firewall verdict, plus the queries and outbound calls it made when APM is on. Credential headers and secret-looking fields are masked in your process before anything is sent.

**Cloudflare decides whether a request gets in. We record what happened after it did.**

Those are different jobs, and the gap between them is where most API incidents live. Your edge sees strangers - unknown IPs, bad signatures, known-bad patterns - and it’s good at that. What it can’t see is a legitimate, authenticated key behaving unlike itself: enumerating IDs one at a time, pulling fifty times its normal volume on a Sunday, or walking endpoints it has never touched before. That traffic passes every edge check, because it’s a customer.

Keep Cloudflare. We’re the layer inside your app where the caller has a name, a history, and a bill. [The full comparison](/vs/cloudflare-waf) says what each one does better.

**Datadog is a much broader product.** If you need to monitor a Kafka cluster, build custom dashboards for forty services, and correlate across your whole estate, use Datadog - we’re not that, and we’re not trying to be.

We answer one question well: who called your API, and what happened. Because logging, timing, and screening run in one middleware, you get one record per request with the trace and the security verdict already on it. Nothing to correlate by request ID across three products and three clocks at 2am.

The other difference is structural. There’s no host agent to deploy, so there’s no per-host meter and no bill that grows every time you add a container.

What we don’t do: infrastructure monitoring, RUM, log ingestion from things that aren’t your API, or 800 integrations. [The full comparison](/vs/datadog) covers pricing and running both.

**No. The middleware fails open.**

If our collector is unreachable, requests complete exactly as they would without us. Telemetry queues into a bounded in-memory buffer and is dropped once that buffer is full - it never grows without limit, and it never blocks a response. You lose visibility for the duration of the outage. You don’t lose traffic.

Enforcement is a separate question, and the answer is better than fail-open usually implies. Verdicts are evaluated in your process against the policy you last synced, not by calling us - so a rule that was live when the connection dropped is still live now. During an outage you stop receiving policy changes; you do not stop being protected. The kill switch works the same way: `API_TRAFFIC_WAF_ENABLED=false` takes effect without a deploy and without reaching us, which is the case that matters when we are the problem.

**Yes, through the proxy URL - and the SDKs are Node because that is where we can go deepest.**

For any other stack, generate a proxy URL for your bucket: the same URL as your API call with only the hostname changed. Calls sent through it land in your request log, searchable, grouped by endpoint and watched by alerting, from any language and with no code to install.

The SDKs add what only an in-process middleware can see: your route definitions (`/users/:id` as one endpoint instead of forty thousand paths), the outbound calls your app makes, the queries behind each request, and a firewall that inspects the parsed request. That is why the first-party SDKs are for Node frameworks.

**You decide what is kept, and the secrets are masked before you configure anything.**

From the very first request, credential headers - `Authorization`, cookies, API key and CSRF headers - and secret-looking keys in bodies and query strings are masked inside your process, before anything is sent.

On top of that, redaction rules mask your own fields, either in your app so the value never leaves your server or on our side just before storage. Exclusion rules keep a route out entirely, or log its requests without their bodies. Everything you see afterwards - the request log, share links, embeds, the API and the MCP server - sees only the redacted value.

**Keep them. Application logs are what your code chose to say. We record what actually crossed the wire.**

The difference shows up on the requests you didn’t write a log line for: the ones that 404’d before reaching a handler, the ones that failed auth, the ones hitting a route someone shipped last quarter and forgot. Those don’t appear in your app logs precisely because your code never ran - and they’re disproportionately the ones worth looking at.

There’s also no correlation step. The timing and the verdict are already on the record; you’re not grepping a log drain and joining it to something else by hand.

The middleware is [public on GitHub](https://github.com/apitraffic/apitraffic-node) if you’d rather read it than take our word for what it does on the request path.

**ApiTraffic tells you - alerts are on every plan.**

Every endpoint is compared with its own normal, and a change has to be a multiple of normal, big in real terms and statistically real before anyone is told. Related alerts become one incident, sent to Slack, email, PagerDuty, Jira or a webhook following your routing. Each alert says why it was grouped, traffic alerts link straight to the requests behind them, and an alert that needs its own owner can be split into an incident of its own. Drift detection adds breaking API changes, certificate monitoring warns you before the certificate of a host your API calls expires, and deploy markers let you see which release changed what. [How alerting works](/monitoring)

Other frameworks

[Express](/express)[NestJS](/nestjs)[Koa](/koa)[Hapi](/hapi)[Meteor](/meteor)[Sails](/sails)[LoopBack](/loopback)[Strapi](/strapi)[AdonisJS](/adonisjs)

## Know what your API did - before your customers tell you.

One npm install and one line of code. Your first requests arrive in minutes, with their queries, their firewall verdict and a baseline for every endpoint already building.

[Start your free trial](https://app.apitraffic.io/signup?src=framework-fastify-closing)

Free trial · No credit card · Set up in minutes
