Stop Building API Dashboards From Scratch
Source: Dev.to
The pattern I kept repeating
For every API project I built some version of the same system:
- Log request metadata to a database
- Write queries to aggregate it
- Build a dashboard to visualize it
- Set up alerts when things go wrong
The fourth time I did this, I realized it should be a product.
PeekAPI: one middleware call, full API analytics
PeekAPI is a middleware you add to your API server. Here’s the full setup for each supported language.
Node.js (Express)
import { peekapi } from "@peekapi/sdk-node";
app.use(peekapi({ apiKey: "pk_..." }));
Python (FastAPI)
from peekapi import PeekAPIMiddleware
app.add_middleware(PeekAPIMiddleware, api_key="pk_...")
Go (net/http)
handler := peekapi.Middleware(mux, peekapi.Config{
APIKey: "pk_...",
})
http.ListenAndServe(":8080", handler)
Rust (Actix Web)
App::new()
.wrap(PeekApi::new("pk_..."))
.service(/* your routes */)
Ruby (Rails)
# config/application.rb
config.middleware.use PeekAPI::Middleware, api_key: "pk_..."
PHP (Laravel)
// bootstrap/app.php
->withMiddleware(function (Middleware $middleware) {
$middleware->append(\PeekAPI\Laravel\PeekApiMiddleware::class);
})
Java (Spring Boot)
# application.properties
peekapi.api-key=pk_...
That’s the entire integration for each language—no agents, no config files, no infrastructure to manage.
What you get
- Real‑time request stream – every API call as it happens, with method, path, status, latency, and consumer identity.
- Endpoint analytics – request volume, error rates, and average latency for each route. Spot which endpoints are most used, which are failing, and which are slow.
- Consumer tracking – PeekAPI automatically identifies who’s calling your API from authorization headers or API keys. Consumers are identified by a SHA‑256 hash—raw credentials never leave your server.
- Smart alerts – get notified when error rates spike, latency exceeds thresholds, or an endpoint goes silent. Notifications via email, Slack, Discord, Telegram, or generic webhook.
What it captures (and what it doesn’t)
Captures
- HTTP method
- Path
- Status code
- Response time
- Request/response size
- Hashed consumer identifier
Does NOT capture
- Request/response bodies
- Query parameters
- Raw authentication credentials
This is a deliberate design choice. PeekAPI answers “who, what, when, how fast” — not “what data was in the request.” If you need payload inspection, you’ll need a different tool.
Zero dependencies, by design
Every SDK is zero‑dependency. The Node SDK uses only built‑in modules (https, crypto, fs, os). Python uses only the standard library. The same applies to Go, Rust, Ruby, PHP, and Java.
Why?
- No supply‑chain risk. Your API middleware shouldn’t pull in a tree of transitive dependencies.
- No conflicts. The SDK will never clash with your existing dependency versions.
Built for reliability
- Async buffering – events are collected in memory and flushed in batches (configurable interval and batch size).
- Exponential backoff – if the analytics server is down, the SDK backs off automatically (max 5 consecutive failures).
- Disk persistence – after max flush failures, on non‑retryable errors, or on process shutdown, undelivered events are saved to a JSONL file. Recovered automatically every 60 seconds and on startup.
- Graceful shutdown – SIGTERM/SIGINT handlers persist buffered events to disk, recovered automatically on restart.
If PeekAPI’s servers are unreachable, your API keeps running normally. Analytics are best‑effort and never a single point of failure.
7 SDKs, 18+ frameworks
| Language | Frameworks |
|---|---|
| Node.js | Express, Fastify, Koa, Hapi, NestJS |
| Python | ASGI, WSGI, Django |
| Go | net/http, Gin, Echo, Fiber, Chi |
| Rust | Actix Web, Axum, Rocket |
| Ruby | Rack, Rails |
| PHP | PSR‑15, Laravel |
| Java | Spring Boot, Jakarta Servlet |
Try it
Free tier at – 500 K events/month, no credit card required. SDKs are MIT licensed.
If you have questions about the architecture or feature requests, feel free to leave a comment.