Nahnu Code & API Block gives the block editor everything a developer-facing site needs to document code and APIs: a polished syntax-highlighted code block, and a matching family of blocks purpose-built for API reference pages — endpoints, parameter tables, tabbed request/response examples, status code tables, authentication headers, and a live try-it console.
The code block
- Syntax highlighting for 20+ languages, powered by Prism.js and bundled with the plugin (no external CDN requests).
- Automatic light/dark mode: follows the visitor’s OS preference, and can also follow a dark-mode class or attribute your theme or another plugin already sets on
<html> or <body> (filterable).
- An optional per-block toggle button so visitors can flip a single code block between light and dark themes manually.
- Long snippets collapse to a configurable preview height with a “View all code” button that opens the complete snippet in a modal.
- One-click Copy button, optional line numbers.
The API-documentation blocks
- Endpoint — HTTP method badge, path, a short summary plus an optional longer description, version badge, an optional deprecation notice, an “Auth Required” indicator, an “Operation ID” for a stable deep-link anchor, a “See also” list of related endpoints, and a copy-link icon for deep-linking directly to this endpoint.
- Parameters — a name / type / location (query, path, header, cookie, body) / format / default value / example value / allowed values / validation range and pattern / nullable / read-only or write-only / required-optional / deprecated / description table, with support for nested object parameters (e.g. an
address parameter with its own line1, city, etc.), linkable type references (e.g. “array of ProgramResponseDto” linking to another Parameters block set up as that named schema), and a copy-link icon on each row for deep-linking to a specific parameter.
- Request / Response — tabbed code examples per language (cURL, JavaScript, Python, PHP, and more), each with Request and Response sub-tabs. Language selection is synced and remembered across every Request/Response block on the same page.
- Response Body — a “Returns” description, optional response headers shown as a persistent table, and one or more real response bodies grouped by status code, shown as an expandable accordion with syntax highlighting and its own copy button per response. An optional “Show Schema” toggle switches a response between its real example and a lightweight type-shape table. Complements the Status Codes block: Status Codes is the quick-scan summary table, Response Body is the rich single-response view.
- Status Codes — a table of the HTTP status codes your API returns, color-coded by class (2xx/3xx/4xx/5xx), with an optional collapsible example response body.
- Authentication — shows the exact header a client needs to send (Bearer token, API key, Basic auth, or OAuth 2.0), with a copy button.
- Try It Console — a live request form visitors can edit (URL, headers, body) and send directly from their own browser to see a real response. This performs a genuine client-side request; it never proxies or issues the call from your WordPress server.
- Error Codes — document your API’s error types and codes (e.g.
invalid_request_error / parameter_missing), distinct from HTTP status codes, each with an optional expandable example error body.
- Events — list the webhook/event names a resource can emit (e.g.
customer.created), each with a description, an optional expandable example payload, and a copy-link icon.
- API Navigation — auto-generates a jump-list of every Endpoint block on the current page. No manual list to keep in sync as you add or reorder endpoints; scans this page only, never your whole site.
- Servers — list an API’s base URLs (production, sandbox, regional) each with a label and a copy button. Maps onto OpenAPI’s
servers array, including server variable templating like {region}.
See every block with a live, interactive demo at wpcodeapiblock.com/all-blocks, or browse the full block-by-block reference at wpcodeapiblock.com/docs/main/blocks.
All blocks share the same visual language and the same light/dark theming, so a full API reference page looks consistent throughout. Site-wide colors can be set visually under Settings → Nahnu Code Block — no code required — and any single block can still override just its own colors for one-off branding.
Using blocks outside the block editor
Every block can also be rendered from a [nahnu_code_block block="..."] shortcode (for widgets, page builders, or classic-editor content) or directly from PHP via nahnu_code_block_render() (for theme templates) — see INTEGRATION.md. Both support the same per-instance color overrides as the settings page.
External services and data
Nahnu Code & API Block does not connect to any external service, API, or CDN at runtime, and does not collect, transmit, or store any personal data. The Prism.js syntax-highlighting library is bundled with the plugin files (MIT licensed) rather than loaded from a third-party server. The Try It Console block is the one exception worth being explicit about: when a site visitor clicks “Send request” on that block, their own browser makes a direct HTTP request to whatever URL is shown in that block (which the page author configured, and the visitor can edit). That request comes from the visitor’s browser, not from your WordPress server, and nothing about it is seen by this plugin’s author or by Nahnu.