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

Store User Sessions in Memcached with Python

Use Memcached as a distributed session store in Python web applications with pymemcache, TTL...

python caching sessions distributed-cache
advanced

Compose Asynchronous Pipelines with Java CompletableFuture

Build non-blocking async pipelines in Java using CompletableFuture with thenCompose, thenCombine,...

intermediate

Make Concurrent HTTP Requests with Python and aiohttp

Fetch multiple APIs concurrently using asyncio and aiohttp. Covers connection pooling, rate...

intermediate

Concurrent Async Tasks with asyncio.gather and Task Groups

Execute multiple async operations concurrently in Python using asyncio.gather, asyncio.TaskGroup,...

intermediate

asyncio.Semaphore: Limit Concurrent API Calls in Python

Use asyncio.Semaphore in Python to cap concurrent API calls, database queries, and resource access...

intermediate

Extract Data from HTML Pages with Python and BeautifulSoup

Parse HTML and extract data using BeautifulSoup. Covers CSS selectors, navigation, tables,...

intermediate

Custom GraphQL Scalar Types for Dates, Emails, and JSON

Define custom GraphQL scalars for Date, Email, URL, and JSON fields with serialization, parsing,...

intermediate

Batch and Cache Database Queries with GraphQL DataLoader

Use DataLoader to coalesce individual load requests into batched database calls, solving the N+1...

advanced

Field-Level Auth with Custom GraphQL Directives

Add field-level authorization to GraphQL with custom schema directives. Check roles, permissions,...

intermediate

Structured GraphQL Errors with Extension Codes

Implement structured error handling in GraphQL with custom error classes, extension codes, and...

advanced

Set Up a GraphQL Federation Gateway with Apollo

Compose multiple GraphQL services into a single federated supergraph using Apollo Federation and a...

intermediate

Validate and Sanitize GraphQL Input Types Server-Side

Implement centralized input validation in GraphQL using custom validation functions, Zod schemas,...

beginner

Mock GraphQL Resolvers for Frontend Development

Set up mocked GraphQL resolvers with Apollo Server so frontend teams can develop against a fake API...

intermediate

Detect and Fix N+1 Queries in GraphQL Resolvers

Identify N+1 query problems in GraphQL resolvers using logging, DataLoader, and query analysis...

intermediate

Cursor-based Pagination with GraphQL Relay Connections

Implement Relay-style cursor pagination in GraphQL with edges, nodes, and pageInfo for efficient...

advanced

Real-Time Data with GraphQL WebSocket Subscriptions

Implement GraphQL subscriptions over WebSockets with Apollo Server and PubSub for real-time updates...

intermediate

Prometheus API Monitoring

Monitor API performance and health with Prometheus metrics, custom collectors, and alerting rules.

beginner

Schema-Based Data Validation with Zod in TypeScript

Validate and sanitize incoming data using Zod schemas with TypeScript inference, custom...

intermediate

Configure HTTP Security Headers with Helmet in Node.js

Set security HTTP headers in Express apps with Helmet — CSP, HSTS, X-Frame-Options,...

intermediate

Build HTTP-Triggered Azure Functions with Python

Create HTTP-triggered Azure Functions in Python with binding configuration, async handlers,...

No results found.