API Endpoints With Sample Call
A two-column API reference section: a hairline list of common endpoints with tone-coded method chips on the left, and a dark terminal-style panel showing a full sample HTTP request and its JSON response on the right. Built for docs pages and developer-facing landing sections.
Docs
Installation
A real shadcn registry command, not a copy-paste stand-in: it fetches this block plus its dependencies and any missing npm packages, and installs them straight into your project.
npx shadcn add https://staaarter.com/r/api-endpoints-sample-call.jsonPrefer not to use the CLI? Copy the source from the Code toggle above into src/components/blocks/devtools/devtools1.tsx instead.
Usage
The file also exports devtools1Demo, 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 { Devtools1, devtools1Demo } from "@/components/blocks/devtools/devtools1"; export default function Page() { return <Devtools1 {...devtools1Demo} />; }
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| heading | string | "API Reference" | Section heading. |
| description | string | undefined | Section intro text below the heading. |
| endpoints | EndpointRow[] | [] | Rows in the bordered endpoint list. |
| windowTitle | string | "request.http" | Filename label shown in the terminal window's title bar. |
| requestLines | string[] | [] | Lines of the sample HTTP request, joined with newlines inside the dark panel's request <pre>. |
| responseLines | string[] | [] | Lines of the sample JSON response, joined with newlines inside the dark panel's response <pre>. |
| className | string | none | Extra classes for the outer section element. |
Types
type EndpointRow = { method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE"; path: string; description: string; };
Behavior notes
- Entirely static; no client-side interactivity. This is a reference display, not a live API console.
- requestLines and responseLines are plain string arrays joined with "\n" and rendered inside <pre><code> blocks; there is no syntax highlighting, JSON parsing, or line numbering.
- Method chip colors are fixed by method name (GET=sky, POST=emerald, PUT/PATCH=amber, DELETE=red) and are not configurable per-row beyond changing the method.
- The dark request/response panel is a deliberate exception to the site's semantic color tokens, matching the repo's established terminal-window convention, and stays dark regardless of site theme.
- The panel is sticky on large screens (lg:sticky lg:top-24) so it stays visible while the endpoint list scrolls; on mobile it stacks below the list.
More DevTools Blocks
View all →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.
queue-monitor
Queue Monitor
Background job queue monitor with processed/pending/failed counts and a per-queue capacity bar.