API Response Examples
A stack of API documentation cards, one per example: a color-coded HTTP status badge and method/path header, a small monospace list of response headers, and the JSON response body in a dark code panel with a one-click copy button. Includes both success and error response shapes, so it doubles as documentation for how failures look, not just the happy path.
Docs
Installation
A real shadcn registry command, not a copy-paste stand-in: it fetches this block plus its button, badge dependencies and any missing npm packages, and installs them straight into your project.
npx shadcn add https://staaarter.com/r/api-response-examples.jsonPrefer not to use the CLI? Copy the source from the Code toggle above into src/components/blocks/devtools/devtools28.tsx instead.
Usage
The file also exports devtools28Demo, 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 { Devtools28, devtools28Demo } from "@/components/blocks/devtools/devtools28"; export default function Page() { return <Devtools28 {...devtools28Demo} />; }
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| heading | string | "Example responses" | Section heading. |
| description | string | "Sample requests and responses for the endpoints you'll hit most often, including how errors come back." | Section intro text below the heading. |
| examples | ApiExample[] | none | Example cards, rendered in order. |
| className | string | none | Extra classes for the outer section element. |
Types
type ApiHeader = { name: string; value: string }; type ApiExample = { method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE"; path: string; status: number; statusText: string; headers: ApiHeader[]; /** Pretty-printed JSON body shown verbatim in the code panel and copied as-is. */ body: string; };
Behavior notes
- Status badge color is derived from the numeric status field at render time: >= 500 is red, >= 400 (and < 500) is amber, anything else is emerald. It reacts to whatever status you pass in, it does not require you to also pick a variant.
- The copy button is real: it calls navigator.clipboard.writeText with that card's exact body string and swaps its icon to a checkmark for two seconds. Each card tracks its own copied state independently, so copying one card's body does not affect another card's button.
- The body is rendered as a plain preformatted string, there is no client-side JSON.parse or re-formatting of it; whatever string you pass in body is exactly what's shown and copied, so make sure it's already pretty-printed the way you want it displayed.
- This block needs "use client" only for the clipboard interaction; nothing about the layout itself requires it.
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.