API Documenter
Generate comprehensive API documentation for the selected code or endpoint.
Documentation Format
REST API Endpoint
markdown
## [METHOD] /api/endpoint/path
Brief description of what this endpoint does.
### Request
**Authentication**: Required/Optional (specify type)
**Headers**
| Header | Type | Required | Description |
|--------|------|----------|-------------|
| Content-Type | string | Yes | application/json |
| Authorization | string | Yes | Bearer token |
**Path Parameters**
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| id | integer | Yes | Resource ID |
**Query Parameters**
| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| page | integer | No | 1 | Page number |
| limit | integer | No | 20 | Items per page |
**Request Body**
```json
{
"field": "value",
"nested": {
"field": "value"
}
}
Response
Success (200 OK)
json
{
"data": [],
"metadata": {
"total": 100,
"page": 1
}
}
Error Responses
- •
400 Bad Request- Invalid parameters - •
401 Unauthorized- Missing or invalid token - •
404 Not Found- Resource not found - •
500 Internal Server Error- Server error
Examples
cURL
bash
curl -X POST https://api.example.com/endpoint \
-H "Authorization: Bearer token" \
-H "Content-Type: application/json" \
-d '{"field": "value"}'
Go
go
// Example usage
Notes
- •Rate limit: 100 requests/minute
- •Caching: 5 minutes
- •Additional context or warnings
code
## For Go Functions/Packages
Generate godoc-compatible documentation:
```go
// PackageName provides functionality for X.
//
// This package implements Y and supports Z.
// It is designed for A use case.
package packagename
// FunctionName does X and returns Y.
//
// Parameters:
// - param1: description of param1
// - param2: description of param2
//
// Returns:
// - type: description of return value
// - error: description of error conditions
//
// Example:
//
// result, err := FunctionName(arg1, arg2)
// if err != nil {
// log.Fatal(err)
// }
// fmt.Println(result)
func FunctionName(param1 type1, param2 type2) (type3, error)
Guidelines
- •Be clear and concise
- •Include all parameters and return values
- •Document error conditions
- •Provide realistic examples
- •Note any side effects or state changes
- •Include performance characteristics if relevant
- •Document thread-safety for concurrent usage
- •Add warnings for gotchas or common mistakes