APIFlask

3.1.0 · active · verified Thu Apr 16

APIFlask is a lightweight Python web API framework built on top of Flask. It enhances Flask with modern API features such as automatic request validation, response formatting, OpenAPI specification generation, and interactive API documentation (Swagger UI, Redoc, Elements, etc.). It is ORM/ODM-agnostic and offers flexible data schema support through both Marshmallow schemas and Pydantic models. The current stable version is 3.1.0, and it maintains an active release cadence, closely following Flask's development.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart initializes an APIFlask application, defines a simple Marshmallow schema for responses, and sets up a GET endpoint that returns a JSON message. APIFlask automatically generates OpenAPI documentation available at `/docs` by default.

from apiflask import APIFlask
from apiflask.fields import String
from apiflask.schemas import Schema

app = APIFlask(__name__, title='My Awesome API', version='1.0.0')

class MessageSchema(Schema):
    message = String(required=True, example='Hello from APIFlask')

@app.get('/')
@app.output(MessageSchema)
def index():
    return {'message': 'Hello from APIFlask'}

# To run: flask --app your_app_file_name run

view raw JSON →