Skip to main content

APIMAN

Test and Release PyPI version Codecov coverage Python support License

APIMAN integrates OpenAPI documentation and schema-based request validation into Python web applications without requiring a framework rewrite.

Features

  • Integrations for Starlette, Flask, Django, Bottle, Tornado, and Falcon
  • OpenAPI 2.0, OpenAPI 3.0.x, and OpenAPI 3.1.x specification validation
  • Built-in Swagger UI and ReDoc endpoints
  • Specifications from docstrings, YAML strings, dictionaries, YAML files, or JSON files
  • Validation for query, header, cookie, path, JSON, XML, and form request data
  • Synchronous and asynchronous validation APIs

Installation

pip install -U apiman

Install the web framework you use separately, for example:

pip install starlette uvicorn

Quick start

from starlette.applications import Starlette
from starlette.requests import Request
from starlette.responses import JSONResponse

from apiman.starlette import Apiman

app = Starlette()
apiman = Apiman()
apiman.init_app(app)


@app.route("/hello", methods=["GET"])
async def hello(request: Request):
    """
    summary: Say hello
    parameters:
      - name: name
        in: query
        required: true
        schema:
          type: string
    responses:
      "200":
        description: Successful response
    """
    apiman.validate_request(request)
    return JSONResponse({"message": f"Hello, {request.query_params['name']}!"})

Run the application and open:

  • Swagger UI: http://localhost:8000/apiman/swagger/
  • ReDoc: http://localhost:8000/apiman/redoc/
  • OpenAPI document: http://localhost:8000/apiman/specification/

Documentation

The full guide covers framework setup, specification sources, reusable schemas, request validation, and project maintenance:

APIMAN documentation

The documentation can also be built locally:

make docs

Development

APIMAN supports Python 3.9 through 3.12. This project uses uv and Ruff:

make install   # create/sync .venv
make lint      # Ruff + mypy
make test      # lint + tests + coverage
make test-all  # Python 3.9-3.12 via Nox
make docs      # strict MkDocs build
make build     # sdist and wheel

make format rewrites Python files and is intentionally separate from the read-only quality checks.

Compatibility Notes

APIMAN validates assembled specifications with bundled OpenAPI 2.0, 3.0.x, and 3.1.x schemas. Header parameter names are matched case-insensitively; query, cookie, and path parameter names remain case-sensitive.

Request validation supports JSON, XML, form, query, header, cookie, and path inputs. Repeated query and form values are accepted for array schemas. Repeated values for scalar schemas remain invalid.

Use apiman.reset() to clear collected route/schema caches and apiman.reload(...) to clear caches and collect routes again through the active framework adapter.

The built-in Swagger UI and ReDoc templates use pinned jsDelivr CDN versions, not @latest. Serving those endpoints requires browser access to jsDelivr unless you customize the templates to serve local assets.

License

APIMAN is licensed under the BSD 3-Clause License.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

apiman-0.5.5.tar.gz (34.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

apiman-0.5.5-py3-none-any.whl (34.2 kB view details)

Uploaded Python 3

File details

Details for the file apiman-0.5.5.tar.gz.

File metadata

  • Download URL: apiman-0.5.5.tar.gz
  • Upload date:
  • Size: 34.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for apiman-0.5.5.tar.gz
Algorithm Hash digest
SHA256 df620db7ff73fc862bfcf2f67236dd46426a6536757b147a6679af459078f498
MD5 8d6c7897a26b7c014a54490e5daa75e2
BLAKE2b-256 ed4d321af0e01033023c16ae8759458653197b1eac542e39fa20b2c37c668d8d

See more details on using hashes here.

Provenance

The following attestation bundles were made for apiman-0.5.5.tar.gz:

Publisher: test-and-release.yml on strongbugman/apiman

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file apiman-0.5.5-py3-none-any.whl.

File metadata

  • Download URL: apiman-0.5.5-py3-none-any.whl
  • Upload date:
  • Size: 34.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for apiman-0.5.5-py3-none-any.whl
Algorithm Hash digest
SHA256 f95f85bad296926ed5cd0c90042c3b0c03efd65b5dffae1e09895f0fca55f90d
MD5 f180bdad5415f150641b01928a77108f
BLAKE2b-256 19821e68cca7fd2656612f766f37b3a04d2f69c4737e67cce8e756023a018762

See more details on using hashes here.

Provenance

The following attestation bundles were made for apiman-0.5.5-py3-none-any.whl:

Publisher: test-and-release.yml on strongbugman/apiman

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.5.5 This release

2 files

0.5.4

2 files

0.5.3

2 files

0.5.2

2 files

0.5.1

2 files

0.5.0

2 files

0.4.0

2 files

0.3.3

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.5

2 files

0.2.4

2 files

0.2.3

1 file

0.2.2

1 file

0.2.1

1 file

0.1.1

1 file

0.1.0

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page