StackPractices

api

Practical resources about api for software engineers.

101 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

Stream LLM Output with Server-Sent Events (SSE)

Stream LLM responses to clients in real-time using Server-Sent Events with FastAPI, OpenAI...

beginner

OpenAPI Docs with Swagger UI and Redoc: A Practical Guide

A practical guide to documenting REST APIs with OpenAPI. Generate interactive Swagger UI and Redoc...

intermediate

Implement API Logging and Audit Trails

Set up thorough request/response logging and audit trails for APIs with structured output,...

intermediate

API Rate Limiting

Protect APIs from abuse and ensure fair resource usage with token bucket, sliding window, and leaky...

intermediate

Implement API Rate Limiting with Redis

Protect APIs from abuse using token bucket and sliding window algorithms with Redis, including...

intermediate

API Versioning

How to version REST and GraphQL APIs to maintain backward compatibility while evolving your...

beginner

Call a REST API: Python, JavaScript, Java & Go Examples

How to make HTTP requests to a REST API and handle the JSON response in Python, JavaScript, Java,...

intermediate

Cursor-Based Pagination with PostgreSQL

Implement efficient cursor-based pagination for large datasets in PostgreSQL, avoiding OFFSET...

intermediate

Express.js Middleware Composition Patterns

Build maintainable Express applications using middleware composition patterns for authentication,...

intermediate

Go REST API with Gin and Middleware

Build production-ready REST APIs in Go using the Gin framework with custom middleware for logging,...

intermediate

Implement a GraphQL API

Build a production-ready GraphQL API with type-safe schemas, resolvers, and query optimization in...

intermediate

Build a GraphQL API with Apollo Server and TypeScript

How to build a production-ready GraphQL API using Apollo Server, TypeScript, and DataLoader to...

intermediate

gRPC API with Protocol Buffers

Implement a gRPC API with Protocol Buffers. Covers service definition, code generation,...

intermediate

Build gRPC Services in TypeScript with Protocol Buffers

Build production-ready gRPC services in TypeScript using Protocol Buffers. Covers unary, streaming,...

intermediate

Handle CORS Correctly

How to configure Cross-Origin Resource Sharing (CORS) headers correctly for APIs, SPAs, and...

intermediate

Handle API Errors with RFC 7807 and HTTP Status Codes

Patterns for consistent, predictable API error handling across multiple languages and frameworks.

intermediate

Idempotent API Endpoints

How to design and implement idempotent API endpoints that safely handle retries, duplicate...

beginner

Input Validation

How to validate user input safely using schemas, type checking, and sanitization across Python,...

intermediate

JavaScript Fetch Retry Logic with Exponential Backoff

Retry failed HTTP requests in JavaScript with exponential backoff

beginner

Logging

How to implement structured, level-based logging across Python, JavaScript, and Java with what...

No results found.