Back to templates

Template details

Responder

A familiar HTTP Service Framework for Python.

About this template

Responder is a Python web framework that brings the familiar request/response style of Flask and Falcon to ASGI, powered by Starlette, for building small, expressive HTTP services. Created by Kenneth Reitz, it is published on PyPI under the Apache-2.0 license and supports Python 3.11 and newer.

What is Responder?

Responder is an open-source HTTP service framework for Python that turns sync or async view functions into an ASGI web service with routing, validation, OpenAPI documentation, and production middleware. Each view receives a mutable req request object and a resp response object; you read from one and write to the other, with outputs supported as resp.text, resp.html, resp.media, resp.file(), and resp.problem(). Install it with pip install "responder[orjson]", run the built-in uvicorn runner with python app.py, and the quickstart service listens on http://127.0.0.1:5042.

Key Features

  • Familiar request/response API — Every view is def view(req, resp) with mutable request and response objects; both sync and async views work, and returning a dict from a view is also accepted.
  • Typed contracts with Pydantic — Body, query, header, and cookie parameters are validated through Pydantic models, and return-type annotations produce documented response bodies in the OpenAPI schema.
  • Generated OpenAPI and clients — Passing openapi="3.1.0", title, version, and docs_route="/docs" serves Swagger UI at /docs and the schema at /schema.yml; the responder client CLI generates client code for Python, JavaScript, TypeScript, Ruby, and PHP.
  • Built-in auth and security — responder.ext.auth includes BearerAuth, JWT and OAuth2 helpers, signed and server-side sessions, CSRF protection via API(csrf=True), and route policies such as api.policy("writer", auth.requires("items:write")).
  • Streaming SSE and NDJSON — @api.sse and @api.ndjson endpoints validate and serialize each item as it is yielded, support heartbeats, and include the item schema in OpenAPI so generated clients expose lazy iterators instead of buffering.
  • Production operations — Request IDs, structured access logs, health checks, Prometheus metrics, in-memory or Redis rate limiting, 100 MiB request body caps by default, and streaming multipart uploads that spool to disk.
  • Composition and deployment — Mount Flask, Django, WSGI, ASGI apps, or plain routers under one API; run with the built-in uvicorn runner or optional Granian server; WebSockets and trusted proxy-header rewriting are supported.

Who is it for?

  • Python developers who know Flask or Falcon — They keep the same mental model of req and resp while moving to ASGI, Starlette routing, and uvicorn.
  • Teams building small internal APIs and microservices — They get typed contracts, OpenAPI docs, auth, rate limiting, and health checks without adopting a large framework.
  • Researchers, teachers, and hobbyists — The quickstart is a few lines, and examples like tarot.py, fortunes.py, and websocket_chat.py make it approachable for prototypes, experiments, and teaching.

What can you do with Responder?

  • Build a documented REST API — Define Pydantic request and response models, apply bearer-token auth with scope policies, and get Swagger UI at /docs plus validated Problem Details errors for 401, 403, and 422.
  • Stream real-time or bulk data — Serve typed Server-Sent Events with heartbeats or NDJSON exports where every event is validated as it is yielded and clients consume a lazy iterator.
  • Ship a production service — Enable request IDs, structured logs, Prometheus metrics, health checks, rate limiting, and capped request bodies, then run with uvicorn or Granian behind a trusted reverse proxy.
  • Compose multiple apps — Mount an existing Flask, Django, WSGI, or ASGI application, or even a marimo notebook, under a single Responder API with shared middleware.

How does Responder work?

Install with pip install "responder[orjson]", create an api = responder.API() instance, decorate views with @api.get("/path"), and run with python app.py or the responder run app.py CLI. Responder reads route decorators, type hints, and Pydantic models to validate requests, serialize responses, and build the OpenAPI schema automatically.

Alternatives

  • Flask — A WSGI-based Python microframework with a similar request/response shape but without ASGI support or built-in OpenAPI generation.
  • Falcon — A minimalist Python web framework focused on speed, without Responder's batteries-included auth, streaming, and documentation tooling.

FAQ

Is Responder free?

Yes. Responder is open-source software on PyPI under the Apache-2.0 license. The recommended install is pip install "responder[orjson]" on standard GIL-enabled CPython; free-threaded CPython builds (3.14t and 3.15t) should install the base package.

What Python versions does Responder support?

Responder supports Python 3.11 and newer. When orjson is unavailable, it falls back to the standard-library JSON encoder, so no application code changes are required.

Does Responder generate OpenAPI documentation?

Yes. Passing openapi="3.1.0" with a title, version, and docs_route="/docs" makes Responder build the schema from routes, type hints, Pydantic models, auth helpers, and framework behavior. The documentation UI appears at /docs, the schema at /schema.yml, and the responder client CLI generates clients for five languages.

What is the default request body limit?

Request bodies are capped at 100 MiB by default in Responder 9; pass API(max_request_size=None) for the legacy unlimited behavior. Framework-generated errors use RFC 9457-style application/problem+json responses, covering things like 413 body-cap violations and 429 rate limits.

Does Responder support streaming?

Yes. The @api.sse decorator serves server-sent events with heartbeat intervals and per-event metadata, and @api.ndjson streams newline-delimited JSON. Each yielded item is validated and serialized as it is produced.

screenshot of Responder on template0.com