Markdown API Documentation Examples
Good API documentation helps developers understand an endpoint without reading the source code. These Markdown examples show practical ways to document REST APIs, authentication, requests, responses, errors, and common workflows.
The examples below follow a consistent structure — overview, authentication, request, response, and errors — so you can copy, customize, and reuse them for your own API reference pages, whether you're documenting a small internal service or a public developer platform.
REST APIs • Endpoints • Authentication • Requests & Responses • Error Handling • Copy Ready
What Should API Documentation Include?
Most API documentation answers the same questions:
- What does this endpoint do?
- How do I authenticate?
- Which parameters are required?
- What does a successful response look like?
- What errors might occur?
- Are there usage limits or special requirements?
The examples below follow this structure so they're easy to adapt for your own API.
Example 1: Simple Endpoint Documentation
Every endpoint should start with a clear summary before introducing technical details.
# Get User Profile
Returns the profile information for the authenticated user.
## Endpoint
GET /api/users/me
## Authentication
Bearer Token
## Response
Returns the user's profile information.
Why this works
A developer can immediately understand the endpoint's purpose, HTTP method, and authentication requirements before reading the request or response examples.
Example 2: Endpoint with Parameters
Document every parameter that affects the request.
# Search Products
Search products using a keyword.
## Endpoint
GET /api/products
## Query Parameters
| Parameter | Type | Required | Description |
|-----------|------|:--------:|-------------|
| q | string | Yes | Search keyword |
| category | string | No | Filter by category |
| limit | integer | No | Maximum number of results |
Best for
- Search endpoints
- Filtering resources
- Public APIs
Example 3: Authentication Guide
Authentication deserves its own section instead of being hidden inside a paragraph.
# Authentication
Include your API key in the request header.
```http
Authorization: Bearer YOUR_API_KEY
```
Requests without a valid API key will return a `401 Unauthorized` response.
Why this works
Developers usually look for authentication before anything else. Keeping it separate makes it easier to find.
Example 4: Request Example
Show a complete request that developers can adapt.
GET /api/products?category=laptops&limit=5 HTTP/1.1
Host: api.example.com
Authorization: Bearer YOUR_API_KEY
Accept: application/json
A realistic request helps developers verify that they're using the correct headers, method, and endpoint.
Example 5: Successful Response
Examples should reflect actual API responses whenever possible.
{
"id": 421,
"name": "Mechanical Keyboard",
"price": 89.99,
"currency": "USD",
"available": true
}
Why this works
Developers can immediately see the response structure without searching through multiple sections.
Example 6: Error Response
Good documentation prepares developers for failure as well as success.
Status: 404 Not Found
{
"error": "Product not found"
}
Include the status code alongside the response body so developers know what to expect.
Example 7: Response Field Reference
Large responses become easier to understand when each field is explained.
| Field | Type | Description |
|---|---|---|
| id | integer | Product identifier |
| name | string | Product name |
| price | number | Product price |
| available | boolean | Product availability |
This approach works well for APIs with nested JSON responses or many returned properties.
Example 8: Complete Endpoint Documentation
Bringing everything together creates a page that developers can work from without switching between multiple documents.
# Create Product
Creates a new product.
## Endpoint
POST /api/products
## Authentication
Bearer Token
## Request Body
| Field | Type | Required |
|--------|------|:--------:|
| name | string | Yes |
| price | number | Yes |
| category | string | Yes |
## Success Response
201 Created
## Error Responses
- 400 Bad Request
- 401 Unauthorized
- 422 Validation Failed
Why this structure works
Every piece of information follows the same order—from overview to authentication, request, and response—making the documentation predictable and easy to navigate.
How Developers Actually Read API Documentation
Most developers don't read API documentation from top to bottom. They usually arrive with a specific goal, such as creating a resource, authenticating a request, or fixing an error.
Well-organised documentation makes those answers easy to find.
A practical order for most API documentation is:
- Endpoint overview
- Authentication requirements
- Request example
- Parameters or request body
- Successful response
- Error responses
- Notes and limitations
Keeping this order consistent across every endpoint reduces the learning curve and helps developers navigate your documentation more efficiently.
Anatomy of Good API Documentation
Regardless of the API, every endpoint should answer a few essential questions.
What Does This Endpoint Do?#
Start with a short summary.
Good
Creates a new customer account.
Less helpful
Customer Endpoint
A clear summary tells developers immediately whether they're in the right place.
Which HTTP Method Should I Use?#
Always display the method alongside the endpoint.
POST /api/customers
Avoid mentioning the endpoint only inside paragraphs, where it's harder to spot.
How Do I Authenticate?#
Authentication should never be hidden halfway through the page.
Include it near the top using a dedicated section.
## Authentication
Bearer Token required.
If different endpoints use different authentication methods, document each one separately rather than expecting readers to infer the difference.
What Should I Send?#
If an endpoint accepts input, document every field.
| Field | Type | Required | Description |
|---|---|---|---|
| string | Customer email | ||
| name | string | Full name | |
| company | string | Company name |
Developers shouldn't have to inspect example code to discover required fields.
What Will I Get Back?#
Include a realistic response example.
{
"id": 42,
"email": "alex@example.com",
"status": "active"
}
Whenever possible, explain important fields below the example.
Which Errors Can Occur?#
Don't only document successful requests.
List common errors developers are likely to encounter.
| Status | Meaning |
|---|---|
| 400 | Invalid request |
| 401 | Authentication failed |
| 403 | Permission denied |
| 404 | Resource not found |
| 429 | Rate limit exceeded |
| 500 | Internal server error |
Understanding possible failures helps developers troubleshoot integrations more quickly.
Documentation Patterns That Scale Well
As APIs grow, consistency becomes more important than individual page design.
These patterns work well for both small and large documentation projects.
Keep Every Endpoint Consistent#
If one endpoint documents:
- Summary
- Authentication
- Parameters
- Request
- Response
- Errors
then every endpoint should follow the same structure.
Readers quickly learn where to look for information.
Separate Tutorials from Reference Documentation#
A tutorial teaches developers how to complete a task.
Reference documentation explains how an endpoint works.
For example:
Tutorial
Upload your first file.
Reference
POST /api/files
Keeping these separate helps readers find either guided learning or technical details without mixing the two.
Show Complete Requests#
Avoid partial examples that omit important information.
Instead of:
POST /users
Prefer:
POST /api/users HTTP/1.1
Host: api.example.com
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
Complete examples are easier to test and adapt.
Explain Limits and Requirements#
If an endpoint has restrictions, document them clearly.
Examples include:
- Maximum file size
- Supported formats
- Required permissions
- Rate limits
- Pagination limits
- Timeouts
Developers appreciate knowing these constraints before they encounter them.
Common Documentation Mistakes
Documenting Only Successful Requests#
Real-world integrations encounter validation errors, authentication failures, and missing resources.
Showing both successful and failed responses prepares developers for real usage.
Hiding Important Information Inside Paragraphs#
Authentication, endpoints, and required parameters should stand out visually.
Developers often scan documentation before reading it in detail.
Using Placeholder Responses That Never Occur#
Examples should resemble actual API responses.
Unrealistic examples make documentation less trustworthy and harder to apply.
Leaving Response Fields Unexplained#
Large JSON responses become difficult to understand without field descriptions.
A small response table often saves readers from guessing what each property represents.
Forgetting to Update Documentation#
Documentation should be reviewed whenever an endpoint changes.
Before publishing a new version, verify:
- Endpoints still exist.
- Parameters are accurate.
- Response examples match the latest API.
- Deprecated fields are removed or clearly marked.
- Code samples still work.
Accurate documentation builds confidence and reduces support requests.
Frequently Asked Questions
- 1
Should every API endpoint have its own documentation page?
For small APIs, related endpoints can be grouped together. As an API grows, giving each endpoint its own page usually makes documentation easier to navigate, maintain, and link to.
- 2
Should I include example requests and responses?
Yes. Developers often begin by copying a working example before adapting it to their own application. Including both request and response examples reduces trial and error during integration.
- 3
How should I document authentication?
Create a dedicated authentication section near the beginning of the documentation. Include the required authentication method, where credentials should be sent, and an example request showing the correct headers.
- 4
What's the difference between API documentation and API reference?
API documentation covers the broader developer experience, including authentication, tutorials, workflows, and integration guidance. An API reference focuses on the technical details of endpoints, parameters, request bodies, responses, and status codes. Most mature APIs include both.
- 5
Should API documentation include SDK examples?
If your API has official SDKs or client libraries, yes. Language-specific examples help developers integrate more quickly and demonstrate recommended usage patterns.
