API Usage Analytics
An API analytics dashboard section: a four-up stats row (total requests, average latency, error rate, active users) each with a trend arrow and percentage, followed by a table of endpoint-level usage broken down by method, request volume, latency, and error rate. Built for API product pages and internal ops dashboards.
Docs
Installation
A real shadcn registry command, not a copy-paste stand-in: it fetches this block plus its badge dependencies and any missing npm packages, and installs them straight into your project.
npx shadcn add https://staaarter.com/r/api-usage-analytics.jsonPrefer not to use the CLI? Copy the source from the Code toggle above into src/components/blocks/devtools/devtools23.tsx instead.
Usage
The file also exports devtools23Demo, the exact props behind the preview above. Spread it to get a working section in one line, then replace it with your own data.
import { Devtools23, devtools23Demo } from "@/components/blocks/devtools/devtools23"; export default function Page() { return <Devtools23 {...devtools23Demo} />; }
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| heading | string | "API Usage Analytics" | Section heading. |
| description | string | undefined | Section intro text below the heading. |
| stats | StatCard[] | [] | Cards in the four-up stats row. |
| endpoints | EndpointRow[] | [] | Rows in the endpoint usage table. |
| className | string | none | Extra classes for the outer section element. |
Types
type StatCard = { label: string; value: string; trendDirection: "up" | "down"; trendPercent: string; isGood: boolean; }; type EndpointRow = { method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE"; path: string; requests: string; avgLatency: string; errorRate: string; };
Behavior notes
- Entirely static; no client-side interactivity, no live polling, no sorting or filtering on the table.
- A stat card's arrow direction (trendDirection) and its color (isGood) are set independently, so a metric where "up" is bad (like average latency climbing) can still render a red up-arrow, while a metric where "down" is good (like error rate falling) renders a green down-arrow. The demo data includes one of each to show this isn't just up-is-always-green.
- trendPercent is a plain caller-supplied string (e.g. "+12.4%" or "-0.21pt"), not computed from any underlying numbers, so its sign and the arrow icon must be kept consistent by whoever supplies the data.
- Method chip colors on the endpoint table are fixed by method name (GET = sky, POST = emerald, PUT/PATCH = amber, DELETE = red), matching the convention used elsewhere in this category.
More DevTools Blocks
View all →api-endpoints-sample-call
API Endpoints With Sample Call
Reference list of API endpoints paired with a live sample request and response panel.
cicd-pipeline-status
CI/CD Pipeline Status
Recent CI/CD pipeline runs with per-stage status chips and overall run badges.
code-diff-viewer
Code Diff Viewer
Unified code diff panel with a file header change summary and colored addition/deletion lines.
keyboard-shortcuts-reference
Keyboard Shortcuts Reference
Grouped keyboard shortcut reference with keycap-styled key combos.
performance-waterfall
Performance Waterfall
Network request waterfall chart with cascading timing bars colored by duration.
service-health-board
Service Health Board
Infrastructure status board with a live summary strip and per-service uptime, latency, and health.