cloudparts

HTTP API frameworks

Map each method and path to a function, and turn its typed parameters and return value into validated requests, JSON responses and an OpenAPI document.

How they work

An HTTP API framework exposes many endpoints, one per resource and verb, such as GET /orders/{id} and POST /orders. The newer ones read each handler’s declared parameter types. FastAPI takes path, query, header and body parameters from Python type hints and Pydantic models; ASP.NET Core minimal APIs bind route values, query strings, headers, JSON bodies and form values to typed parameters. From the same declarations they validate input, serialize output and, in FastAPI’s case, describe every endpoint in OpenAPI for Swagger UI, ReDoc and client generators.

Older designs keep these jobs apart. Flask is a microframework that leaves validation and documentation to plug-ins. Django REST Framework, built on Django, was one of the first to generate API documentation automatically. Falcon hands each function a request and a response object, so nothing can be declared in the signature. In TypeScript, NestJS repeats types in decorators because the types are gone after compilation. Starlette sits lower still: routing, requests and responses, with validation left to you.

Pick an HTTP API framework for resource-shaped APIs, file uploads, webhooks and anything where each URL should mean one thing. Most can also host a GraphQL endpoint as one more route.

Technologies

What all api frameworks have in common →

Worth exploring

All resources →
WebsiteOpenAPI.ToolsPhil Sturgeon and APIs You Won’t Hate, with community contributorsAn open-source directory of more than 300 tools for working with OpenAPI descriptions, sorted into 23 categories such as mock servers (about 25, including Prism, Microcks, WireMock and Specmatic), SDK generators, linters, documentation, gateways, testing and monitoring, and filterable by language and by which OpenAPI versions each supports. Entries arrive by pull request on GitHub; sponsors get priority placement and a badge in their categories, so the order isn’t a ranking.

Sources

Improve this page on GitHub