How to document GET endpoints
The GET operation retrieves data from the server for the requested parameter.
What to document for GET endpoints
For each GET endpoint, include:
- Purpose - What data is returned
- Method and URL - For example,
GET /api/v1/users/{id} - Authentication and headers - Token requirements and optional headers
- Path and query parameters - Names, types, defaults, and validation rules
- Pagination and sorting - Structure and supported query options
- Success and error responses - Typical
200,400,401,404payloads
Example: Get users list
- Endpoint summary: Returns a paginated list of users.
- Method:
GET - URL:
/api/v1/users?page=1&limit=20&sort=name - Authentication: Bearer token required
Query parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| page | integer | No | 1 | Page number |
| limit | integer | No | 20 | Items per page (max 100) |
| sort | string | No | createdAt |
Sort field |
Request example
curl -X GET "https://api.example.com/api/v1/users?page=1&limit=20&sort=name" \
-H "Authorization: Bearer <token>"
Success response (200)
{
"page": 1,
"pageSize": 20,
"total": 64,
"items": [
{
"id": "u_101",
"name": "Asha Verma",
"email": "asha.verma@example.com"
}
]
}
Error response (400)
{
"error": {
"code": "INVALID_QUERY_PARAM",
"message": "limit must be between 1 and 100"
}
}