skillfed

APIFlask

A lightweight web API framework based on Flask.

apiflask v3.1.1 211.2K downloads/30d#9,482 on PyPI1,131
Permissive license MIT Active released

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 apiflask

uv

uv add apiflask

poetry

poetry add apiflask

Installing 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

Development Status :: 5 - Production/StableEnvironment :: Web EnvironmentFramework :: FlaskIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.9Topic :: Internet :: WWW/HTTP :: Dynamic ContentTopic :: Internet :: WWW/HTTP :: WSGITopic :: Internet :: WWW/HTTP :: WSGI :: ApplicationTopic :: Software Development :: Libraries :: Application Frameworks

Tags

flask api framework with validationautomatic openapi documentationmarshmallow pydantic schema validationrest api with flaskjson request response serializationswagger ui api docsflask http authentication
rest-apiopenapi-generationschema-validation

More Application Frameworks packages