Web Frameworks & APIs

starlette

The quiet engine running underneath some of Python's fastest websites.

Install it: pip install starlette

What does it do?

Starlette is a lightweight toolkit for building web services that can juggle many things at once — websites, real-time chat, background tasks — without waiting for one to finish before starting the next. It’s less a full framework you build a site directly in and more a set of well-designed building blocks other frameworks assemble into something bigger. FastAPI, in fact, is built directly on top of Starlette, borrowing its core machinery for handling requests and adding extra features on top.

See it in action

This code creates a simple web service that answers with a greeting message, meant to be run by another program that handles the actual traffic.

from starlette.applications import Starlette
from starlette.responses import JSONResponse
from starlette.routing import Route

async def homepage(request):
    return JSONResponse({"message": "Hello, world!"})

app = Starlette(routes=[Route("/", homepage)])

Why would a non-developer care?

You’ve likely never heard of Starlette by name, yet if you’ve used a fast, responsive app built with FastAPI, you’ve benefited from what it does under the hood. Good infrastructure being invisible is usually a sign it’s working well.

Real-world examples

Because FastAPI wraps Starlette, any company using FastAPI — Netflix and Uber among them, by their own public accounts — is indirectly relying on Starlette to handle the actual request traffic. Without a solid foundation like this, building fast async web tools would mean each framework reinventing the same low-level plumbing from scratch.

Who uses it

Framework builders and advanced developers who want fine control over async web behavior without writing the low-level plumbing themselves.

How it compares to alternatives

Starlette occupies a similar layer to aiohttp but with a more modern, composability-focused design; it’s roughly the ASGI equivalent of what Werkzeug is to WSGI-based frameworks like Flask.

Fun fact

Starlette was created by Tom Christie, who also created Django REST Framework, one of the most widely used tools for building APIs on top of Django.

New to Python and want to actually try libraries like this yourself?

Find a beginner-friendly course

Related libraries