APIFlask
A lightweight web API framework based on Flask.
What it is and what it does
APIFlask is a thin wrapper around Flask that adds structured API development patterns. It lets you declare request and response schemas using either marshmallow or Pydantic, then automatically validates incoming JSON, deserializes it into your schema, and serializes responses back out—all while generating an OpenAPI specification and interactive Swagger UI documentation on the fly. You write decorators like `@app.input()` and `@app.output()` on your route functions, and APIFlask handles the plumbing: validation errors return JSON, successful responses are formatted consistently, and your API docs stay in sync with your code.
It's built on top of Flask's ecosystem (using flask-marshmallow, webargs, apispec, and flask-httpauth) and remains fully compatible with Flask extensions and patterns. The framework is ORM/ODM-agnostic, so you can use it with SQLAlchemy, MongoDB, or any data layer. It supports both synchronous and asynchronous route handlers, and you can choose between multiple documentation UIs (Swagger UI, Redoc, Elements, RapiDoc, RapiPDF).
Use it for:
- Build REST APIs with automatic request validation and OpenAPI docs without writing boilerplate schema code.
- Migrate from plain Flask to a structured API framework while keeping all existing Flask extensions and middleware.
- Generate interactive API documentation (Swagger UI) automatically from your route decorators and schemas.
- Validate incoming JSON against marshmallow or Pydantic schemas and return consistent error responses.
- Implement API authentication using Flask-HTTPAuth with minimal setup code.
- Serialize ORM/ODM model instances directly to JSON responses without manual conversion.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
APIFlask is a lightweight web API framework that extends Flask with automatic request validation, response serialization, and OpenAPI documentation generation using either marshmallow schemas or Pydantic models.
Yes. APIFlask is actively maintained, has no known vulnerabilities, installs with low friction, and solves a real problem—reducing boilerplate in Flask API development while keeping you in the Flask ecosystem. It's suitable for production use (Development Status: Production/Stable) and works with modern Python versions. Choose it if you want Flask's flexibility with structured API patterns and auto-generated docs, without adopting a heavier framework.
Install
apiflask on PyPI
pip
pip install apiflaskuv
uv add apiflaskpoetry
poetry add apiflaskInstalling APIFlask
Before you install
Low friction install with a pure-Python wheel. Depends on seven runtime packages including Flask, marshmallow, Pydantic, and webargs. Actively maintained with a recent release and ongoing commits.
License in practice
MIT license is permissive and imposes no restrictions on commercial or private use, modification, or redistribution.
Quickstart
pip install apiflask
from apiflask import APIFlask, Schema
from apiflask.fields import String
app = APIFlask(__name__)
class PetOut(Schema):
name = String()
@app.get('/pets/<int:pet_id>')
@app.output(PetOut)
def get_pet(pet_id):
return {'name': 'Kitty'}
Requires Python 3.9+ and Flask 2.1+.
Verify before relying
- Performance characteristics under load compared to other Flask-based API frameworks.
- Maturity and stability of Pydantic model adapter relative to marshmallow schemas.
- Real-world async support reliability and any known gotchas with Flask 2.0+ async features.
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 7 — flask, flask-marshmallow, marshmallow, webargs, flask-httpauth, apispec, pydantic |
| Maintenance | actively maintained — 52 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 211,229/month — #9,482 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: apiflask-3.1.1-py3-none-any.whl
Tags
More Application Frameworks packages
FastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
textualTextual is a Python framework for building…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
mcpBuild and connect to Model Context Protocol…
permissive · top 1,000 on PyPI
WerkzeugWerkzeug is a WSGI utility library providing…
permissive · top 1,000 on PyPI
flask-openapi3Builds REST APIs on Flask with automatic…
permissive · top 15,000 on PyPI
FlaskFlask is a lightweight WSGI web application…
permissive · top 1,000 on PyPI
flask-apispecflask-apispec decorates Flask view functions…
permissive · top 15,000 on PyPI
tapipyTapipy is a Python SDK that automatically…
permissive · top 15,000 on PyPI
Flask-APIFlask-API adds browsable web interfaces and…
permissive · top 15,000 on PyPI
Flask-PydanticAdds Pydantic model validation to Flask route…
permissive · top 15,000 on PyPI
flask-marshmallowFlask-Marshmallow integrates Flask and…
permissive · top 5,000 on PyPI
flask-pydantic-specAdds OpenAPI documentation generation and…
unclear · top 15,000 on PyPI
apispec-webframeworksProvides web framework plugins for apispec to…
permissive · top 15,000 on PyPI