StackPractices

api

Practical resources about api for software engineers.

102 results

Building Robust APIs

APIs are the contract between systems. Whether you are exposing a public REST endpoint, designing an internal GraphQL schema, or integrating with a third-party service, the patterns you choose determine reliability, performance, and developer experience.

Here you will find recipes for handling CORS, implementing pagination, versioning endpoints, managing rate limits, and documenting APIs with OpenAPI. Each example includes runnable code in multiple languages so you can adapt it to your stack immediately.

intermediate

Test API Contracts with Consumer-Driven Contracts

How to prevent breaking changes between microservices using consumer-driven contract testing with...

testing api-testing consumer-driven-contracts contract-testing
intermediate

API Mocking for Testing

Build reliable tests by mocking external APIs with WireMock, MockServer, and MSW to eliminate...

intermediate

Gateway Routing Pattern

Route requests to multiple backend services through a single entry point that handles cross-cutting...

intermediate

Adapter Pattern for Integrating External REST APIs

Use the Adapter pattern to normalize responses from external REST APIs into a consistent internal...

intermediate

Backend for Frontend (BFF) Pattern

Give each client type its own backend that aggregates downstream services and shapes data to that...

intermediate

Chain of Responsibility for Request Processing Middleware

Pass requests along a chain of handlers where each handler decides whether to process the request...

intermediate

Decorator Pattern for HTTP Request Pipelines

Use the Decorator pattern to compose cross-cutting concerns like logging, metrics, and retries into...

intermediate

GraphQL Batched Resolver Pattern

Resolve nested GraphQL fields in a single batched request to eliminate N+1 queries and reduce...

intermediate

GraphQL DataLoader Pattern

Coalesce individual load requests into batched calls with per-request caching to prevent N+1...

intermediate

GraphQL Error Extension Pattern

Attach structured metadata to GraphQL errors using extension codes for predictable client-side...

advanced

GraphQL Interface Polymorphism Pattern

Model polymorphic types with GraphQL interfaces to share field contracts across different object...

advanced

GraphQL Schema Stitching Pattern

Merge multiple independent GraphQL schemas into a single unified schema that clients can query as...

intermediate

Token Bucket Rate Limiter: Smooth Traffic with Token Buckets

How to implement token bucket rate limiting for API protection — bucket refill, burst handling,...

beginner

API Changelog Template

A template for documenting API changes including breaking changes, new features, deprecations, and...

beginner

API Deprecation Notice Template

A template for communicating API deprecations, breaking changes, and sunset timelines to consumers.

beginner

API Error Handling Guideline

A guideline for standardizing error responses, status codes, and error payloads across REST and...

intermediate

API Rate Limiting Policy Template

A template for defining API rate limits per consumer tier, including burst allowances, quota...

intermediate

SLA Definition Template

A template for defining and documenting Service Level Agreements including uptime targets, response...

intermediate

API Performance Budget Template

A template for setting and tracking API latency and throughput performance budgets.

beginner

API Documentation Template

A reusable template for documenting REST and GraphQL APIs with endpoints, schemas, errors, and...

No results found.