~linuxgoose/engineering-templates

ref: f066b4677fc7a0877df86c3588c22c1221a4242d engineering-templates/templates/api-documentation.md -rw-r--r-- 2.5 KiB
f066b467Jordan Robinson add technology radar tech stack review 3 months ago

#API Documentation

#API Overview

Name: [API name]
Version: [Version]
Base URL: [URL]
Status: [Active/Deprecated/Beta]
Last Updated: [Date]

#Authentication

  • Authentication method (OAuth2, API key, JWT, etc.)
  • How to obtain credentials
  • Token expiration and refresh
  • Example authentication headers

#Rate Limiting

  • Rate limit thresholds (requests per minute/hour)
  • How limits are enforced
  • Rate limit headers returned
  • Handling 429 responses
  • Quota considerations

#Error Handling

  • Standard error response format
  • HTTP status codes used
  • Common error codes and meanings
  • Retry logic recommendations
  • Troubleshooting guide
{
  "error": {
    "code": "ERROR_CODE",
    "message": "Human-readable message",
    "details": {}
  }
}

#Versioning Strategy

  • How versions are managed (URL path, header, query param)
  • Deprecation policy and timeline
  • Breaking change notifications
  • Backward compatibility guarantees

#Endpoints

#Endpoint: [METHOD] /resource/{id}

Description: [What this endpoint does]
Authentication: [Required/Optional/None]
Rate Limit: [Tier if applicable]

Request

Method: [GET/POST/PUT/DELETE/PATCH]
Path: /v1/resource/{id}
Query Parameters:
  - param1 (string, required): Description
  - param2 (integer, optional): Description

Headers:
  - Authorization: Bearer {token}
  - Content-Type: application/json

Body:
{
  "field1": "value",
  "field2": 123
}

Response

Success (200):
{
  "id": "resource-123",
  "field1": "value",
  "field2": 123,
  "createdAt": "2025-01-15T10:30:00Z"
}

Error (400):
{
  "error": {
    "code": "INVALID_REQUEST",
    "message": "Missing required field: field1"
  }
}

Status Codes:

  • 200: Success
  • 400: Bad request
  • 401: Unauthorized
  • 403: Forbidden
  • 404: Not found
  • 429: Rate limit exceeded
  • 500: Server error

Examples:

curl -X GET https://api.example.com/v1/resource/123 \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIs..." \
  -H "Content-Type: application/json"

#Webhooks (if applicable)

  • Supported events
  • Payload format
  • Retry logic
  • Signing/verification
  • Example webhook payloads

#Pagination

  • Pagination style (offset/limit, cursor, keyset)
  • Maximum page size
  • Default page size
  • Example paginated response

#Filtering & Sorting

  • Supported filter operators
  • Sortable fields
  • Query syntax examples

#SDK & Client Libraries

  • Available SDKs
  • Installation instructions
  • Links to repositories

#Changelog

  • Version history
  • Breaking changes
  • New features
  • Bug fixes
  • Deprecations