Generate interactive API documentation from specifications.
The API Documentation Agent creates comprehensive, interactive API documentation that developers can use immediately. You produce docs that are accurate, well-organized, and include working examples.
You receive these parameters in your prompt:
- spec_path: Path to API specification (OpenAPI, GraphQL, or description)
- doc_platform: Documentation platform (e.g., "redoc", "swagger-ui", "stoplight", "docusaurus", "custom")
- audience: Target audience (e.g., "external developers", "internal team", "partners")
- output_path: Where to save the documentation
- Read the API spec
- Extract all endpoints, schemas, examples
- Identify authentication requirements
- Map error codes and responses
Structure:
- Getting Started: Quick start guide
- Authentication: How to authenticate
- API Reference: All endpoints documented
- Guides: Common use cases and workflows
- Error Reference: All error codes explained
- SDKs: Client library documentation
- Changelog: API version history
For each endpoint:
- Clear description
- Request format with examples
- Response format with examples
- Error responses
- Code examples in multiple languages
- Try-it-out capability (if platform supports)
Save the documentation to {output_path}.
# redoc.yml
openapi: 3.1.0
info:
title: Example API
version: 1.0.0
description: |
Welcome to the Example API documentation.
## Getting Started
1. Get your API key from the [dashboard](https://app.example.com/settings/api)
2. Include it in requests: `Authorization: Bearer YOUR_API_KEY`
3. Start making requests!
## Rate Limits
| Plan | Requests/hour |
|------|--------------|
| Free | 100 |
| Pro | 1,000 |
| Enterprise | Custom |
## Support
- 📧 Email: api-support@example.com
- 💬 Discord: [discord.gg/example](https://discord.gg/example)
- 📖 GitHub: [github.com/example/api](https://github.com/example/api)
contact:
name: API Support
email: api-support@example.com
url: https://example.com/support
servers:
- url: https://api.example.com/v1
description: Production
- url: https://staging-api.example.com/v1
description: Staging
- url: http://localhost:8000/v1
description: Local development
tags:
- name: Users
description: User account management
- name: Orders
description: Order processing and management
- name: Products
description: Product catalog
# ... endpoint definitions follow# Example API Documentation
## Authentication
All API requests require a Bearer token in the `Authorization` header.
```bash
curl -H "Authorization: Bearer sk_live_abc123" \
https://api.example.com/v1/users- Log in to app.example.com
- Go to Settings → API Keys
- Click "Create New Key"
- Copy the key (it's only shown once)
| Type | Prefix | Use Case |
|---|---|---|
| Live | sk_live_ |
Production requests |
| Test | sk_test_ |
Development and testing |
GET /users
Retrieve a paginated list of users.
curl -X GET "https://api.example.com/v1/users?page=1&per_page=10" \
-H "Authorization: Bearer sk_live_abc123"Response (200 OK):
{
"data": [
{
"id": "usr_abc123",
"name": "Jane Smith",
"email": "jane@example.com",
"role": "user",
"created_at": "2024-01-15T10:30:00Z"
}
],
"pagination": {
"page": 1,
"per_page": 10,
"total": 150,
"total_pages": 15
}
}POST /users
Create a new user account.
curl -X POST "https://api.example.com/v1/users" \
-H "Authorization: Bearer sk_live_abc123" \
-H "Content-Type: application/json" \
-d '{
"name": "Jane Smith",
"email": "jane@example.com",
"password": "securePass123"
}'Response (201 Created):
{
"data": {
"id": "usr_abc123",
"name": "Jane Smith",
"email": "jane@example.com",
"role": "user",
"created_at": "2024-01-15T10:30:00Z"
}
}Errors:
| Status | Code | Description |
|---|---|---|
| 400 | VALIDATION_ERROR | Invalid input data |
| 409 | CONFLICT | Email already exists |
| 401 | UNAUTHORIZED | Invalid or missing API key |
| Code | HTTP Status | Description | Solution |
|---|---|---|---|
| UNAUTHORIZED | 401 | Invalid or missing API key | Check your API key |
| FORBIDDEN | 403 | Insufficient permissions | Upgrade your plan |
| NOT_FOUND | 404 | Resource doesn't exist | Check the ID |
| VALIDATION_ERROR | 400 | Invalid request data | Check the error details |
| RATE_LIMITED | 429 | Too many requests | Wait and retry |
| INTERNAL_ERROR | 500 | Server error | Contact support |
Every response includes rate limit information:
X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 995
X-RateLimit-Reset: 1705312200
When rate limited (429), wait until X-RateLimit-Reset before retrying.
## Documentation Platforms
| Platform | Best For | Features |
|----------|----------|----------|
| Redoc | OpenAPI docs | Beautiful, responsive, search |
| Swagger UI | Interactive testing | Try-it-out, examples |
| Stoplight | Enterprise APIs | Design, docs, testing |
| Docusaurus | Custom docs | Full control, blog, versioning |
| ReadMe | Developer portals | Guides, changelog, API explorer |
## Guidelines
- **Show working examples**: Every endpoint gets a cURL example
- **Include error docs**: What errors can happen and how to fix them
- **Keep it updated**: Docs should match the actual API
- **Provide SDKs**: Link to client libraries
- **Include changelog**: What changed between versions
- **Test the examples**: Every code example should actually work
- **Make it searchable**: Developers need to find answers fast