API Reference

SuperDocs provides specialized components for documenting REST APIs. This page demonstrates how to use them to create beautiful, interactive API documentation.


APIEndpoint

Display an API endpoint with method badges, authentication indicators, and descriptions.

<APIEndpoint
method="GET"
path="/users/{id}"
description="Retrieve a user by their unique ID."
auth="bearer"
baseUrl="https://api.example.com"
/>
GET /users/{id}
Bearer

Retrieve a user by their unique ID.

Supported Methods

GET /users

List all users

POST /users
Bearer

Create a new user

PUT /users/{id}
Bearer

Update a user

PATCH /users/{id}
API Key

Partially update a user

DELETE /users/{id}
Bearer

Delete a user

Deprecated Endpoint

<APIEndpoint method="GET" path="/v1/users" description="Old endpoint" deprecated />
GET /v1/users
Deprecated

This endpoint is deprecated. Use /users instead.

PropTypeDescription
methodstringHTTP method: GET, POST, PUT, PATCH, DELETE, OPTIONS, HEAD
pathstringThe API path with placeholders like {id}
descriptionstringBrief description of the endpoint
deprecatedbooleanMark endpoint as deprecated
authstringAuthentication type: bearer, api-key, basic, or none
baseUrlstringBase URL for the API

ParamTable & Param

Document request parameters in a structured table with type-colored badges and icons.

<ParamTable type="path">
<Param name="id" type="string" required>
The unique identifier of the user.
</Param>
</ParamTable>
<ParamTable type="query" expandable>
<Param name="limit" type="integer" default="10">
Maximum number of results to return.
</Param>
<Param name="offset" type="integer" default="0">
Number of results to skip.
</Param>
<Param name="status" type="string" enum={["active", "pending", "inactive"]}>
Filter by user status.
</Param>
</ParamTable>

Path Parameters

id required
string

The unique identifier of the user.

limit
integer = 10

Maximum number of results to return.

offset
integer = 0

Number of results to skip.

status
string

Filter by user status.

Allowed values:
activependinginactive

Parameter Types

Header Parameters

Authorization required
string

Bearer token for authentication.

X-Request-ID
string

Optional request tracking ID.

Body Parameters

email required
string

User’s email address.

role deprecated
string

User role (deprecated, use permissions instead).

Allowed values:
adminuserguest
ComponentPropTypeDescription
ParamTabletitlestringSection title (auto-generated from type)
ParamTabletypestringParameter type: path, query, header, body, cookie
ParamTableexpandablebooleanMake the section collapsible
ParamTabledefaultOpenbooleanDefault state for expandable (default: true)
ParamnamestringParameter name
ParamtypestringData type (string, integer, boolean, array, object, etc.)
ParamrequiredbooleanWhether the parameter is required
ParamdefaultstringDefault value
ParamdeprecatedbooleanMark as deprecated
Paramenumstring[]List of allowed values

ResponseField

Document API response fields with support for nested structures.

Simple Fields

<ResponseField name="id" type="string">
The user's unique identifier.
</ResponseField>
<ResponseField name="email" type="string" required>
The user's email address.
</ResponseField>
<ResponseField name="name" type="string" nullable>
The user's display name (may be null).
</ResponseField>
<ResponseField name="created_at" type="datetime">
ISO 8601 timestamp of when the user was created.
</ResponseField>
id string

The user’s unique identifier.

email string

The user’s email address.

name string nullable

The user’s display name (may be null).

created_at datetime

ISO 8601 timestamp of when the user was created.

Nested Fields (Expandable)

<ResponseField name="data" type="object" expandable>
<ResponseField name="user" type="object" expandable>
<ResponseField name="id" type="string">User ID</ResponseField>
<ResponseField name="email" type="string">Email address</ResponseField>
</ResponseField>
<ResponseField name="permissions" type="array">
List of user permissions.
</ResponseField>
</ResponseField>
PropTypeDescription
namestringField name
typestringData type (color-coded)
nullablebooleanWhether the field can be null
requiredbooleanMark as required field
deprecatedbooleanMark as deprecated
expandablebooleanMake collapsible for nested content
defaultOpenbooleanDefault state for expandable (default: true)

APIPlayground

Interactive API testing component that lets users make real API requests. Features include:

  • Authentication support - Bearer tokens, API keys, and Basic auth
  • Code generation - Generate code snippets in cURL, JavaScript, Python, and Go
  • Request builder - Add parameters, headers, and request bodies
  • Response viewer - See response body and headers with syntax highlighting
<APIPlayground
method="GET"
path="/users"
baseUrl="https://jsonplaceholder.typicode.com"
auth="bearer"
defaultHeaders={{ "Content-Type": "application/json" }}
/>
GET /users

With Authentication

POST /posts
Authorization
Bearer Token
PropTypeDescription
methodstringHTTP method: GET, POST, PUT, PATCH, DELETE
pathstringAPI endpoint path
baseUrlstringBase URL for the API (editable by users)
authstringAuth type: bearer, api-key, basic, or none
defaultHeadersobjectDefault headers to include

OpenAPI Support

SuperDocs can automatically generate API documentation from OpenAPI/Swagger specifications.

OpenAPISpec Component

Renders all endpoints from an OpenAPI spec file:

import { parseOpenAPIFile } from 'superdocs-theme-default/utils/openapi';
// In your .astro file frontmatter:
const spec = await parseOpenAPIFile('./api-spec.yaml');
// In your template:
<OpenAPISpec spec={spec} showPlayground />

OpenAPIEndpoint Component

Render a single endpoint from a spec:

<OpenAPIEndpoint spec={spec} method="GET" path="/users/{id}" showPlayground />
ComponentPropTypeDescription
OpenAPISpecspecobjectParsed OpenAPI spec
OpenAPISpectagstringFilter endpoints by tag
OpenAPISpecshowPlaygroundbooleanShow interactive playground
OpenAPISpecbaseUrlstringOverride base URL
OpenAPIEndpointspecobjectParsed OpenAPI spec
OpenAPIEndpointmethodstringHTTP method
OpenAPIEndpointpathstringEndpoint path

Complete API Documentation Example

Here’s a full example of documenting an API endpoint with all features:

Get User by ID

GET /users/{id}
Bearer

Retrieve detailed information about a specific user.

Path Parameters

id required
string

The unique identifier of the user (UUID format).

include
string

Related resources to include in the response.

Allowed values:
postscommentsprofile
fields
string

Comma-separated list of fields to return.

Response

{
"id": "usr_abc123",
"email": "john@example.com",
"name": "John Doe",
"avatar_url": "https://example.com/avatar.jpg",
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-06-20T14:45:00Z"
}

Try It

GET /users/1
Authorization
Bearer Token

Create User

POST /users
Bearer

Create a new user account.

Body Parameters

email required
string

A valid email address. Must be unique.

password required
string

Password (minimum 8 characters).

name
string

Optional display name.

role
string = user

User role assignment.

Allowed values:
adminuserguest

Example Request

Terminal window
curl -X POST https://api.example.com/users \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_TOKEN" \
-d '{"email": "john@example.com", "password": "securepass123", "name": "John Doe"}'

Try It

POST /posts
Authorization
Bearer Token

Delete User

DELETE /users/{id}
Bearer

Permanently delete a user account.

Irreversible Action

Deleting a user will permanently remove all associated data including posts, comments, and files. This action cannot be undone.

Path Parameters

id required
string

The unique identifier of the user to delete.

Response

Returns 204 No Content on success.