Document a REST API in Markdown
Markdown is a practical format for lightweight API documentation that lives alongside your code in the repository. This template documents an endpoint with method, path, authentication requirements, request parameters, a curl example, and a sample response. The previewer renders tables and code blocks so you can review the final output before publishing. For larger APIs, consider splitting into per-endpoint files and using a documentation site generator.
Example
## GET /users/:id
Returns a single user by ID.
**Authentication:** Bearer token required
### Path Parameters
| Parameter | Type | Required | Description |
|-----------|--------|----------|--------------|
| id | string | Yes | User UUID |
### Request Example
```bash
curl -H "Authorization: Bearer TOKEN" \
https://api.example.com/users/usr_123
```
### Response 200
```json
{
"id": "usr_123",
"name": "Jane Smith",
"email": "[email protected]",
"createdAt": "2026-01-15T10:30:00Z"
}
```
### Errors
| Code | Meaning |
|------|---------------|
| 401 | Unauthorized |
| 404 | User not found|FAQ
- Should I document my API in Markdown or OpenAPI?
- OpenAPI (Swagger) is machine-readable and generates interactive docs and client SDKs. Markdown is simpler for small APIs and developer guides. Many teams use both: OpenAPI for the spec and Markdown for conceptual guides.
- How do I keep API docs in sync with the code?
- Co-locate documentation next to the code it describes, add a review checklist item for docs on every PR, and consider generating docs from code annotations using tools like JSDoc or TypeDoc.
- How do I render Markdown tables on GitHub?
- GitHub automatically renders pipe-delimited Markdown tables in README and documentation files. Ensure the header separator row (|---|) is present — without it, GitHub treats the table as plain text.
Related Examples
Write a Project README in Markdown
A good README is the front door of every open-source project and sets the tone f...
Write a CONTRIBUTING GuideA contributing guide reduces friction for new contributors by explaining how to ...
Format a REST API ResponseREST APIs return compact JSON that is hard to read at a glance. Paste this examp...