Starlette

A lightweight ASGI framework/toolkit for building async web services and apps in Python

Framework
PyPI
v1.7.0
12,639 stars
BSD 3-Clause License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
94 /100 Excellent
Development Activity 100
Maintenance 100
Community 76
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
78 /100 Good
Architecture 85
Code Quality 85
Innovation 70
Learning Curve 72

Starlette is a lightweight ASGI framework and toolkit for building high-performance async web services in Python. It provides the core primitives every ASGI app needs — routing, request/response objects, middleware, WebSockets, background tasks, and a test client — without imposing a large amount of structure on top, making it usable either directly or as the foundation other frameworks build on.

FastAPI is the most visible consumer of Starlette, using it for all of the underlying HTTP/WebSocket handling while layering in validation and OpenAPI generation; but Starlette itself is designed to be used standalone for services that need async performance without a full-featured framework’s opinions.

What You Get

  • ASGI-native routing with path parameters, mounting, and WebSocket routes
  • Request/Response objects, form/multipart parsing, and streaming responses
  • A composable middleware stack (CORS, GZip, sessions, trusted host, etc.)
  • Native async WebSocket support and background task scheduling
  • A TestClient built on httpx for synchronous-style testing of async apps
  • Static file serving and Jinja2 templating integration

Common Use Cases

  • Building lightweight async microservices or internal APIs without a heavier framework
  • Serving as the ASGI foundation underneath higher-level frameworks (as FastAPI does)
  • Building real-time services that need native WebSocket routing and handling
  • Adding async middleware (CORS, auth, sessions) to an existing ASGI application

Under The Hood

Architecture - applications.py assembles a Starlette app from a middleware stack (middleware/), a Router (routing.py) that dispatches ASGI scope/receive/send calls to endpoint callables or classes (endpoints.py), with request parsing (requests.py, formparsers.py) and response construction (responses.py) as thin, composable layers around the raw ASGI interface. Tech Stack - Pure-Python, dependency-light (optional extras for httpx, jinja2, python-multipart, itsdangerous depending on features used), built and packaged via modern pyproject.toml/uv tooling, deployed under any ASGI server (Uvicorn, Hypercorn, Daphne). Code Quality - A large, well-organized tests/ directory (26+ files) covers routing, middleware, WebSockets, static files, and exception handling individually, and the project enforces type checking (py.typed) and consistent style across a 300+ contributor codebase. API Design - The Starlette(routes=[...]) constructor and decorator-free route definitions keep the surface small and explicit; because it’s intentionally low-level, using it directly requires more boilerplate than a batteries-included framework, but that same minimalism is what makes it easy to build other frameworks on top of.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers