Staaarter

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.

By Staaarter Team
DevTools
Docs
Live preview

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.json

Prefer 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

PropTypeDefaultDescription
headingstring"API Usage Analytics"Section heading.
descriptionstringundefinedSection intro text below the heading.
statsStatCard[][]Cards in the four-up stats row.
endpointsEndpointRow[][]Rows in the endpoint usage table.
classNamestringnoneExtra 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.