[READ-ONLY] Mirror of https://github.com/okikio/docs.
README.md

HTTP API design #

An HTTP API gives clients a way to request data or change system state. Its contract includes inputs, authorization, response formats, failure behavior, and retry rules. Use these guides to define that contract and trace a request from the client to its observable result.

This section contains ten topic guides. Their examples illustrate decisions to review for your own service; they are not a complete production implementation.

What You'll Learn #

Choose a guide for the behavior you need to define:

Core Topics #

  1. Versioning - How to evolve your API without breaking existing clients
  2. Error Handling - Standardized approaches to communicating failures
  3. Authentication - Securing your API with modern authentication methods
  4. Filtering - Enabling clients to query exactly the data they need
  5. Pagination - Efficiently handling large datasets
  6. Rate Limiting - Protecting your infrastructure from abuse
  7. Content Negotiation - Supporting multiple data formats
  8. Idempotency - Making operations safe to retry
  9. Caching - Leveraging HTTP caching for performance
  10. Observability - Logging, monitoring, and debugging in production

REST Fundamentals #

REST (Representational State Transfer) is an architectural style described in Roy Fielding's dissertation. HTTP is a protocol often used to implement it. RFC 9110 defines HTTP semantics, including methods, status codes, and representation metadata; it does not define REST.

The Six Constraints #

Roy Fielding's original dissertation defined REST with six architectural constraints:

  1. Client-Server - Separation of concerns between UI and data storage
  2. Stateless - Each request contains all information needed to understand it
  3. Cacheable - Responses must define themselves as cacheable or not
  4. Uniform Interface - Consistent way to interact with resources
  5. Layered System - Client can't tell if connected directly to server
  6. Code on Demand (optional) - Servers can extend client functionality

Getting Started #

If you're new to API design, we recommend starting with these guides in order:

  1. Start with Error Handling to understand how to communicate problems
  2. Move to Authentication to learn about securing your API
  3. Then Versioning to plan for evolution
  4. Finally Caching to make it fast

For specific challenges:

Standards and Specifications #

These guides reference and build upon established web standards:

  • HTTP semantics — RFC 9110
  • HTTP caching — RFC 9111
  • HTTP/1.1 message syntax — RFC 9112
  • HTTP/2 — RFC 9113
  • HTTP/3 - RFC 9114 (QUIC-based HTTP)
  • URI - RFC 3986 (Uniform Resource Identifiers)
  • JSON - RFC 8259 (JavaScript Object Notation)
  • OAuth 2.0 - RFC 6749 (Authorization framework)
  • JWT - RFC 7519 (JSON Web Tokens)
  • Problem Details — RFC 9457, which replaces RFC 7807

Beyond This Guide #

API design is a vast topic. After mastering these fundamentals, consider exploring:

  • GraphQL for query flexibility
  • gRPC for high-performance RPC
  • WebSockets for real-time bidirectional communication
  • Server-Sent Events for server-push updates
  • Webhooks for event-driven integrations

Choose a protocol from the interaction your clients need, then document its connection, authorization, retry, and failure behavior.