Mangum is an adapter that runs ASGI applications — FastAPI, Starlette, Quart, Django and other async Python frameworks — inside AWS Lambda, translating events from Function URLs, API Gateway, Application Load Balancer and CloudFront Lambda@Edge into the ASGI interface.
What it is
Mangum is a Python library that sits between AWS Lambda's event-driven invocation model and the ASGI specification. It receives the event dictionary that Lambda hands to a function, converts it into the scope, receive and send triple an ASGI application expects, and converts the application's response back into the payload Lambda must return to the caller. The README describes it plainly as an adapter for running ASGI applications in AWS Lambda to handle Function URL, API Gateway, ALB, and Lambda@Edge events. It lives in the Python ASGI ecosystem and is distributed on PyPI under the MIT licence.
The concrete problem it solves is that Lambda does not run a web server. There is no long-lived process listening on a socket, so an ASGI framework cannot be started the way it normally is on a container or virtual machine. Mangum replaces both the custom event-parsing glue a team would otherwise write by hand and the standalone ASGI server process that a Lambda deployment has no place to run. Once wrapped, an existing framework application can be invoked directly by AWS event sources without changing the application code itself.
Key capabilities
- Event handlers for API Gateway HTTP APIs, API Gateway REST APIs, Application Load Balancer, Function URLs, and CloudFront Lambda@Edge.
- Compatibility with ASGI application frameworks including Starlette, FastAPI, Quart, and Django.
- Support for binary media types and payload compression in API Gateway using GZip or Brotli.
- Works with existing deployment and configuration tools, including Serverless Framework and AWS SAM.
- Startup and shutdown lifespan events, with the handler accepting a
lifespan argument such as Mangum(app, lifespan="off").
- A single handler object pattern:
handler = Mangum(app) wraps any callable ASGI application.
- Install and upgrade through the
mangum package on PyPI.
Who uses it and how
- Teams with FastAPI or Starlette services that need to ship to Lambda without rewriting routing, dependency injection, or middleware.
- Django projects running under ASGI that want to serve API Gateway or ALB traffic from a Lambda function rather than a container.
- Applications deployed through Serverless Framework or AWS SAM, where the handler is referenced in the infrastructure template and Mangum handles the event translation.
- Services placed behind Function URLs or CloudFront Lambda@Edge, including edge workloads reaching for the same handler pattern as the regional deployments.
- APIs returning images or files where binary media types and GZip or Brotli compression matter at the gateway layer.
Getting started
Install with pip install mangum, then wrap the application and point the Lambda handler at the resulting object, as in handler = Mangum(app, lifespan="off"). The same pattern applies whether app is a bare ASGI callable or a framework instance such as FastAPI().
How it compares
The registry provides no list of paid products that Mangum replaces, and the facts name no competing adapter library. The ASGI frameworks listed — Starlette, FastAPI, Quart, and Django — appear as compatible applications rather than alternatives. Mangum therefore stands alone in this registry as the Lambda-to-ASGI bridge.
When to use it — and when not to
Self-hosting means operating the AWS side: Lambda functions, API Gateway or ALB configuration, IAM permissions, and CloudWatch logging, none of which Mangum configures for you. It is the wrong choice for WSGI applications, which need a different adapter, and for teams whose workload runs on containers, virtual machines, or non-AWS platforms where an ordinary ASGI server is the simpler answer. The README excerpt is short and covers features without deployment walkthroughs or troubleshooting guidance, so users should expect to lean on the linked documentation and their own infrastructure tooling.
project readme (upstream, from github) — read inline
Mangum

Mangum is an adapter for running ASGI applications in AWS Lambda to handle Function URL, API Gateway, ALB, and Lambda@Edge events.
Documentation: https://mangum.fastapiexpert.com/
Features
Installation
pip install mangum
Example
from mangum import Mangum
async def app(scope, receive, send):
await send(
{
"type": "http.response.start",
"status": 200,
"headers": [[b"content-type", b"text/plain; charset=utf-8"]],
}
)
await send({"type": "http.response.body", "body": b"Hello, world!"})
handler = Mangum(app, lifespan="off")
Or using a framework:
from fastapi import FastAPI
from mangum import Mangum
app = FastAPI()
@app.get("/")
def read_root():
return {"Hello": "World"}
@app.get("/items/{item_id}")
def read_item(item_id: int, q: str = None):
return {"item_id": item_id, "q": q}
handler = Mangum(app, lifespan="off")