apig-wsgi
Wrap a WSGI application in an AWS Lambda handler function for running on API Gateway or an ALB.
What it is and what it does
apig-wsgi is a thin adapter that lets you run existing WSGI applications on AWS Lambda by converting API Gateway and ALB events into WSGI environ dicts and wrapping responses back into the appropriate format. It handles both event format versions automatically, manages binary content encoding, and exposes Lambda context and request metadata through WSGI environ keys so your application can access AWS-specific details if needed.
The package has no runtime dependencies and installs cleanly. It's designed for teams deploying WSGI applications to serverless without rewriting the application layer. Configuration is minimal: you create a lambda_handler by passing your WSGI app to make_lambda_handler(), then deploy that function to Lambda. The package handles format detection, multi-value headers on format version 1, and conditional base64 encoding of binary responses.
Use it for:
- Deploy a WSGI application behind an ALB in Lambda for cost-effective serverless HTTP handling.
- Run a WSGI app on a Lambda Function URL with automatic binary response support.
- Support both API Gateway REST and HTTP APIs with a single handler that auto-detects the event format.
- Access Lambda context and API Gateway request metadata from within your WSGI application.
- Wrap an existing WSGI application for Lambda without modifying application code.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Wraps a WSGI application to run as an AWS Lambda handler on API Gateway, Lambda Function URLs, or ALBs, automatically detecting event format versions and handling binary responses.
Yes. This is a mature, actively maintained bridge for running WSGI applications on AWS Lambda. It has no dependencies, low install friction, clean MIT licensing, and zero known vulnerabilities. Install it if you're deploying a WSGI application to Lambda.
Install
apig-wsgi on PyPI
pip
pip install apig-wsgiuv
uv add apig-wsgipoetry
poetry add apig-wsgiInstalling apig-wsgi
Before you install
Low friction install with no runtime dependencies. Active maintenance with recent releases; last commit 2026-08-13.
License in practice
MIT license permits commercial and private use with minimal restrictions; suitable for most projects.
Quickstart
pip install apig-wsgi
from apig_wsgi import make_lambda_handler
lambda_handler = make_lambda_handler(app)
Requires Python 3.9 or later. Your WSGI application must be deployable to AWS Lambda with appropriate IAM permissions.
Verify before relying
- Whether binary response support requires additional AWS configuration beyond what the package handles automatically.
- Performance characteristics and cold-start overhead compared to native Lambda frameworks.
- Specific Django and Flask compatibility versions beyond general WSGI support.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 340 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 141,923/month — #11,230 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: apig_wsgi-2.20.0-py3-none-any.whl
Keywords: API Gateway, APIG, AWS, Lambda
Tags
More Dynamic Content packages
MarkupSafe provides a text object that escapes…
permissive · top 100 on PyPI
Jinja2Jinja2 is a templating engine that renders…
permissive · top 100 on PyPI
soupsieveSoupsieve is a CSS selector library designed to…
permissive · top 100 on PyPI
WerkzeugWerkzeug is a WSGI utility library providing…
permissive · top 1,000 on PyPI
FlaskFlask is a lightweight WSGI web application…
permissive · top 1,000 on PyPI
MakoMako compiles Python-embedded templates into…
permissive · top 1,000 on PyPI
aws-lambda-contextProvides the AWS Lambda Context class for type…
permissive · top 15,000 on PyPI
awslambdaricImplements the AWS Lambda Runtime API to make…
permissive · top 5,000 on PyPI
mangumMangum adapts ASGI applications to run on AWS…
permissive · top 5,000 on PyPI
awsgi2Bridges WSGI-compatible web frameworks to AWS…
permissive · top 15,000 on PyPI
serverless-wsgiBridges Python WSGI applications (Flask,…
permissive · top 15,000 on PyPI
zappaZappa packages and deploys Python WSGI and ASGI…
permissive · top 15,000 on PyPI
a2wsgiConverts between WSGI and ASGI applications…
permissive · top 5,000 on PyPI
WebObWebOb provides request and response objects…
permissive · top 5,000 on PyPI
microversion-parseParses and validates OpenStack microversion…
permissive · top 15,000 on PyPI
aws-sam-translatorTransforms AWS Serverless Application Model…
permissive · top 1,000 on PyPI