API Documentation Example

eziwiki is perfect for creating clean, organized API documentation.
Example Structure#
content/
βββ intro.md
βββ authentication/
β βββ _meta.json β { "name": "π Authentication", "order": 1 }
β βββ api-keys.md
β βββ oauth.md
βββ endpoints/
β βββ _meta.json β { "name": "π Endpoints", "order": 2 }
β βββ users.md
β βββ posts.md
β βββ webhooks.md
βββ reference/
βββ _meta.json β { "name": "π Reference", "order": 3 }
βββ errors.md
βββ rate-limits.mdFor API documentation, Search matters more than navigation depth β readers arrive looking for one endpoint or one error code. Code inside fenced blocks is indexed, so searching a field name or status code finds the page that documents it.
Example API Endpoint Page#
---
title: List Users
description: Retrieve a list of users
---
# List Users
Retrieve a paginated list of users.
## Endpoint
\`\`\`
GET /api/v1/users
\`\`\`
## Authentication
Requires a valid API key in the `Authorization` header:
\`\`\`
Authorization: Bearer YOUR_API_KEY
\`\`\`
## Query Parameters
| Parameter | Type | Required | Description |
| --------- | ------- | -------- | --------------------------------------------- |
| `page` | integer | No | Page number (default: 1) |
| `limit` | integer | No | Items per page (default: 20, max: 100) |
| `sort` | string | No | Sort field (default: `created_at`) |
| `order` | string | No | Sort order: `asc` or `desc` (default: `desc`) |
| `status` | string | No | Filter by status: `active`, `inactive` |
## Request Example
\`\`\`bash
curl -X GET "https://api.example.com/v1/users?page=1&limit=20" \\
-H "Authorization: Bearer YOUR_API_KEY"
\`\`\`
\`\`\`javascript
const response = await fetch('https://api.example.com/v1/users?page=1&limit=20', {
headers: {
'Authorization': 'Bearer YOUR_API_KEY'
}
});
const data = await response.json();
\`\`\`
\`\`\`python
import requests
response = requests.get(
'https://api.example.com/v1/users',
params={'page': 1, 'limit': 20},
headers={'Authorization': 'Bearer YOUR_API_KEY'}
)
data = response.json()
\`\`\`
## Response
### Success Response (200 OK)
\`\`\`json
{
"data": [
{
"id": "usr_1234567890",
"email": "alice@example.com",
"name": "Alice Johnson",
"status": "active",
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:30:00Z"
},
{
"id": "usr_0987654321",
"email": "bob@example.com",
"name": "Bob Smith",
"status": "active",
"created_at": "2024-01-14T15:20:00Z",
"updated_at": "2024-01-14T15:20:00Z"
}
],
"pagination": {
"page": 1,
"limit": 20,
"total": 150,
"pages": 8
}
}
\`\`\`
### Response Fields
| Field | Type | Description |
| ------------------- | ------- | ----------------------------------- |
| `data` | array | Array of user objects |
| `data[].id` | string | Unique user identifier |
| `data[].email` | string | User email address |
| `data[].name` | string | User full name |
| `data[].status` | string | User status: `active` or `inactive` |
| `data[].created_at` | string | ISO 8601 timestamp |
| `data[].updated_at` | string | ISO 8601 timestamp |
| `pagination` | object | Pagination metadata |
| `pagination.page` | integer | Current page number |
| `pagination.limit` | integer | Items per page |
| `pagination.total` | integer | Total number of items |
| `pagination.pages` | integer | Total number of pages |
## Error Responses
### 401 Unauthorized
\`\`\`json
{
"error": {
"code": "unauthorized",
"message": "Invalid or missing API key"
}
}
\`\`\`
### 429 Too Many Requests
\`\`\`json
{
"error": {
"code": "rate_limit_exceeded",
"message": "Rate limit exceeded. Try again in 60 seconds."
}
}
\`\`\`
### 500 Internal Server Error
\`\`\`json
{
"error": {
"code": "internal_error",
"message": "An unexpected error occurred"
}
}
\`\`\`
## Rate Limiting
- **Rate Limit**: 100 requests per minute
- **Headers**:
- `X-RateLimit-Limit`: Maximum requests per minute
- `X-RateLimit-Remaining`: Remaining requests
- `X-RateLimit-Reset`: Unix timestamp when limit resets
## Related Endpoints
- [Get User](/api/users/get) - Get a single user by ID
- [Create User](/api/users/create) - Create a new user
- [Update User](/api/users/update) - Update an existing userAuthentication Page Example#
---
title: Authentication
description: Learn how to authenticate API requests
---
# Authentication
All API requests require authentication using an API key.
## Getting an API Key
1. Log in to your dashboard
2. Navigate to Settings β API Keys
3. Click "Create API Key"
4. Copy and securely store your key
β οΈ **Important**: Keep your API key secret. Never commit it to version control.
## Using Your API Key
Include your API key in the `Authorization` header:
\`\`\`
Authorization: Bearer YOUR_API_KEY
\`\`\`
## Example Requests
### cURL
\`\`\`bash
curl -X GET "https://api.example.com/v1/users" \\
-H "Authorization: Bearer YOUR_API_KEY"
\`\`\`
### JavaScript
\`\`\`javascript
const response = await fetch('https://api.example.com/v1/users', {
headers: {
'Authorization': 'Bearer YOUR_API_KEY'
}
});
\`\`\`
### Python
\`\`\`python
import requests
headers = {'Authorization': 'Bearer YOUR_API_KEY'}
response = requests.get('https://api.example.com/v1/users', headers=headers)
\`\`\`
## Environment Variables
Store your API key in environment variables:
\`\`\`bash
# .env
API_KEY=your_api_key_here
\`\`\`
\`\`\`javascript
const apiKey = process.env.API_KEY;
\`\`\`
## Security Best Practices
- β
Use HTTPS for all requests
- β
Store API keys in environment variables
- β
Rotate keys regularly
- β
Use different keys for development and production
- β Never commit API keys to version control
- β Never expose API keys in client-side code
## Error Responses
### 401 Unauthorized
Missing or invalid API key:
\`\`\`json
{
"error": {
"code": "unauthorized",
"message": "Invalid or missing API key"
}
}
\`\`\`
### 403 Forbidden
Valid key but insufficient permissions:
\`\`\`json
{
"error": {
"code": "forbidden",
"message": "Insufficient permissions"
}
}
\`\`\`Benefits for API Docs#
Clear Structure#
Organize endpoints by resource with nested navigation.
Code Examples#
Show examples in multiple languages with syntax highlighting.
Searchable#
Users can quickly find what they need.
Version Control#
Track changes to your API documentation in Git.
Easy Updates#
Update docs as fast as you update your API.