API Reference Template (Markdown)
A structured template for documenting REST APIs. Includes base URL, authentication, endpoints with parameters, and response examples.
# API Reference
## Base URL
`https://api.example.com/v1`
## Authentication
All requests require an `Authorization: Bearer <token>` header.
## Endpoints
### GET /resource
Fetch a list of resources.
**Query Parameters**
| Name | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| `page` | integer | No | Page number (default 1) |
| `limit` | integer | No | Items per page (default 20) |
**Response**
```json
{
"data": [],
"total": 0,
"page": 1
}
```
### POST /resource
Create a new resource.
**Request Body**
```json
{
"name": "string",
"description": "string"
}
```
**Status Codes**
| Code | Meaning |
| :--- | :--- |
| 200 | Success |
| 400 | Bad request |
| 401 | Unauthorized |
Writing Good API Docs
Good API documentation answers three questions for every endpoint: what does it do, what parameters does it take, and what does it return.
Tables for parameters are the clearest format. Include the name, type, whether it's required, and a short description. Mark optional parameters clearly.
Include real response examples. A JSON example is more useful than a description of the response shape. Developers copy-paste examples into their code — make sure yours work.
Document status codes. Don't just show the happy path. Document 400, 401, 404, and 500 responses so developers know how to handle errors.
Related Documentation Templates
README Template — Project overview
Technical Spec Template — Design documents
ADR Template — Architecture decisions
Error Reference Template — Error code catalog