All twelve blocks, at a glance
Every block Nahnu Code and API Block registers, grouped the way you will actually reach for them, plus the shortcode that drops each one anywhere the block editor cannot reach: a widget, a page builder, or classic editor content.
Code
1 blockSyntax-highlighted snippets for 20 plus languages, bundled Prism.js, auto light and dark, collapsible preview, copy button, line numbers.
class User:
# Represents an application user.
def __init__(self, name, email):
self.name = name
self.email = email
self.created_at = datetime.utcnow()
def to_dict(self):
return dict(name=self.name, email=self.email)
[nahnu_code_block block="code-block" language="python" title="user.py" code="class User:
# Represents an application user.
def __init__(self, name, email):
self.name = name
self.email = email
self.created_at = datetime.utcnow()
def to_dict(self):
return dict(name=self.name, email=self.email)"]API reference
6 blocksMethod, path, summary, version, deprecation notice, auth flag, operation-ID anchor, related endpoints.
Create a new invoice for a customer.
Creates an invoice in a draft state for the given customer. Call finalize to send it.
[nahnu_code_block block="endpoint" method="POST" path="/v1/invoices" summary="Create a new invoice for a customer." description="Creates an invoice in a draft state for the given customer. Call finalize to send it." version="v2" operationId="createInvoice" authRequired="true"]
[{"method":"GET","path":"/v1/invoices/{id}","label":"Retrieve an invoice"},{"method":"POST","path":"/v1/invoices/{id}/finalize","label":"Finalize an invoice"}]
[/nahnu_code_block]Type, location, format, defaults, validation, nested objects, and linkable type references, one row per field.
[nahnu_code_block block="parameters" title="Parameters"]
[{"name":"customer","type":"string","required":true,"location":"query","description":"Identifier of the customer to bill."},{"name":"amount","type":"integer","required":true,"location":"query","description":"Amount to charge, in cents."},{"name":"currency","type":"string","required":false,"location":"query","default":"usd","description":"Three letter ISO currency code."},{"name":"address","type":"object","required":false,"location":"query","description":"Billing address to print on the invoice.","children":[{"name":"line1","type":"string","required":false,"description":"Street address."},{"name":"city","type":"string","required":false,"description":"City."}]}]
[/nahnu_code_block]Tabbed examples per language: cURL, JS, Python, PHP, with synced language selection across the page.
curl https://api.example.com/v1/invoices \n -u sk_live_dummy: \n -d customer=cus_8f2a \n -d amount=4200 \n -d currency=usd
{
"id": "in_123",
"customer": "cus_8f2a",
"amount": 4200,
"currency": "usd",
"status": "draft"
}
const invoice = await client.invoices.create({
customer: "cus_8f2a",
amount: 4200,
currency: "usd"
});
{
id: "in_123",
customer: "cus_8f2a",
amount: 4200,
currency: "usd",
status: "draft"
}
[nahnu_code_block block="request-response"]
[{"language":"bash","label":"cURL","requestCode":"curl https://api.example.com/v1/invoices \\n -u sk_live_dummy: \\n -d customer=cus_8f2a \\n -d amount=4200 \\n -d currency=usd","responseCode":"{\n \"id\": \"in_123\",\n \"customer\": \"cus_8f2a\",\n \"amount\": 4200,\n \"currency\": \"usd\",\n \"status\": \"draft\"\n}"},{"language":"javascript","label":"JavaScript","requestCode":"const invoice = await client.invoices.create({\n customer: \"cus_8f2a\",\n amount: 4200,\n currency: \"usd\"\n});","responseCode":"{\n id: \"in_123\",\n customer: \"cus_8f2a\",\n amount: 4200,\n currency: \"usd\",\n status: \"draft\"\n}"}]
[/nahnu_code_block]Real bodies grouped by status code in an accordion, plus a "Show Schema" toggle for a type-shape view.
The created Invoice object.
200 application/json
| Header | Type | Description |
|---|---|---|
Request-Id |
string | Unique identifier for this API request. |
{
"id": "in_123",
"customer": "cus_8f2a",
"amount": 4200,
"currency": "usd",
"status": "draft"
}
| Name | Type | Required | Description |
|---|---|---|---|
id |
string | Required | Unique invoice identifier. |
customer |
string | Required | Customer this invoice bills. |
amount |
integer | Required | Amount due, in cents. |
status |
string | Required | draft, open, paid, or void. |
402 application/json
{
"error": {
"type": "card_error",
"code": "card_declined",
"message": "Your card was declined."
}
}
[nahnu_code_block block="response-body" returns="The created Invoice object."]
[{"status":"200","contentType":"application/json","body":"{\n \"id\": \"in_123\",\n \"customer\": \"cus_8f2a\",\n \"amount\": 4200,\n \"currency\": \"usd\",\n \"status\": \"draft\"\n}","schema":[{"name":"id","type":"string","required":true,"description":"Unique invoice identifier."},{"name":"customer","type":"string","required":true,"description":"Customer this invoice bills."},{"name":"amount","type":"integer","required":true,"description":"Amount due, in cents."},{"name":"status","type":"string","required":true,"description":"draft, open, paid, or void."}],"headers":[{"name":"Request-Id","type":"string","description":"Unique identifier for this API request."}]},{"status":"402","contentType":"application/json","body":"{\n \"error\": {\n \"type\": \"card_error\",\n \"code\": \"card_declined\",\n \"message\": \"Your card was declined.\"\n }\n}","schema":[],"headers":[]}]
[/nahnu_code_block]A color-coded quick-scan table of every status the endpoint returns, with an optional example per row.
| Code | Meaning | Description |
|---|---|---|
| 200 | OK | The invoice was created. |
| 402 | Card Declined | The card on file was declined. |
| 404 | Not Found | The customer does not exist. |
[nahnu_code_block block="status-codes"]
[{"code":"200","meaning":"OK","description":"The invoice was created.","example":""},{"code":"402","meaning":"Card Declined","description":"The card on file was declined.","example":""},{"code":"404","meaning":"Not Found","description":"The customer does not exist.","example":""}]
[/nahnu_code_block]Bearer, API key, Basic, or OAuth 2.0, the exact header a client sends, with its own copy button.
Authorization: Bearer YOUR_API_KEY
Send this header on every request. Keys are issued per environment, live and test.
[nahnu_code_block block="auth" scheme="bearer" headerName="Authorization" placeholder="YOUR_API_KEY" description="Send this header on every request. Keys are issued per environment, live and test."]Interactive
1 blockA real request, edited and sent from the visitor's own browser. Never proxied through your WordPress server.
[nahnu_code_block block="try-it" method="POST" url="https://api.example.com/v1/invoices" headers="Authorization: Bearer YOUR_API_KEY" body="{ customer: cus_8f2a, amount: 4200, currency: usd }"]Supporting
4 blocksYour API's own error taxonomy, distinct from HTTP status, each with an optional example error body.
[nahnu_code_block block="error-codes"]
[{"type":"invalid_request_error","code":"parameter_missing","description":"A required parameter was not provided.","example":""},{"type":"card_error","code":"card_declined","description":"The card was declined by the issuing bank.","example":""}]
[/nahnu_code_block]Webhook or event names your resource emits, each with a description and expandable example payload.
[nahnu_code_block block="events"]
[{"name":"invoice.created","description":"Occurs whenever a new invoice is created.","example":""},{"name":"invoice.paid","description":"Occurs whenever an invoice is paid.","example":""}]
[/nahnu_code_block]Base URLs: production, sandbox, regional. Maps to OpenAPI's servers array.
-
Production
https://api.example.com -
Sandbox
https://sandbox.api.example.com
[nahnu_code_block block="servers"]
[{"url":"https://api.example.com","description":"Production"},{"url":"https://sandbox.api.example.com","description":"Sandbox"}]
[/nahnu_code_block]Every block, outside the block editor too
A shortcode for a widget or page builder, or a template tag for a theme file. Both render exactly the same block, with the same theming, as if it were placed in the block editor.
- Attributes pass straight through:
block="endpoint" method="POST" - Per-instance color overrides, e.g.
accentColor="#ff5500", without touching the site-wide palette
[nahnu_code_block block="endpoint" method="POST" path="/v1/invoices"] // with a one-off accent color: [nahnu_code_block block="endpoint" method="POST" path="/v1/invoices" accentColor="#ff5500"]
nahnu_code_block_the( 'endpoint', [ 'method' => 'POST', 'path' => '/v1/invoices', ] );
Block slugs, for hand-authoring or the build API
Every slug below works with nahnu_code_block_build_block_markup(), no nahnu-code-block/ prefix needed.
| Block | Slug | Category | Key attributes |
|---|---|---|---|
| Code Block | code-block | Code | language, code, lineNumbers |
| Endpoint | endpoint | API reference | method, path, summary, deprecated |
| Parameters | parameters | API reference | parameters[] |
| Request / Response | request-response | API reference | examples[] |
| Response Body | response-body | API reference | returns, headers[], responses[] |
| Status Codes | status-codes | API reference | codes[] |
| Authentication | auth | API reference | scheme, headerName |
| Try It Console | try-it | Interactive | method, url, headers[] |
| Error Codes | error-codes | Supporting | errors[] |
| Events | events | Supporting | events[] |
| API Navigation | api-navigation | Supporting | (auto-scanned, no attributes) |
| Servers | servers | Supporting | servers[] |
Start with the blocks you need today
Add one, or all twelve. Every block works on its own.