skillfed

apispec

A pluggable API specification generator. Currently supports the OpenAPI Specification (f.k.a. the Swagger specification).

apispec v6.10.0 15.1M downloads/30d#1,199 on PyPI1,218
Permissive license Active released

What it is and what it does

apispec is a code-driven OpenAPI specification generator that converts Python code into machine-readable API documentation. It works by introspecting your code—particularly route handlers, schemas, and security definitions—and synthesizing them into valid OpenAPI 2 or 3 documents that can be exported as JSON or YAML. The package is framework-agnostic at its core but ships with built-in support for marshmallow schema serialization, and integrates with web frameworks through optional plugins.

Typical usage involves instantiating an APISpec object with your target OpenAPI version, registering plugins for your framework and schema library, then feeding it your application's routes and models. It parses docstring annotations (YAML-formatted operation metadata) and automatically generates schema definitions, security schemes, and endpoint documentation. This keeps your spec in sync with your code rather than maintaining separate documentation files.

Use it for:

  • Generate interactive API documentation (Swagger UI, ReDoc) from Flask or other framework route definitions without manual YAML
  • Maintain OpenAPI specs that stay synchronized with marshmallow schema changes during development
  • Export API contracts for client code generation or third-party API integration testing
  • Publish machine-readable API definitions for API gateways, monitoring tools, or developer portals
  • Validate request/response schemas at runtime by embedding OpenAPI definitions in your application

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Generates OpenAPI specification documents from Python code, supporting versions 2 and 3 of the OpenAPI standard with framework-agnostic design and built-in marshmallow integration.

Yes. apispec is production-stable (Development Status 5), actively maintained, has no known vulnerabilities, and solves a real problem—keeping API documentation synchronized with code. The single dependency and low install friction make it a safe addition. Install it if you need OpenAPI specs for a Python web service and want to avoid manual YAML maintenance.

Install

apispec on PyPI

pip

pip install apispec

uv

uv add apispec

poetry

poetry add apispec

Installing apispec

Before you install

Low install friction with a single runtime dependency (packaging). Active maintenance with recent releases; last commit 2026-08-03 and 1218 GitHub stars indicate ongoing support.

License in practice

MIT licensed under permissive terms, allowing free use, modification, and distribution with minimal restrictions.

Quickstart

pip install apispec

from apispec import APISpec
spec = APISpec(
    title="My API",
    version="1.0.0",
    openapi_version="3.0.2"
)
print(spec.to_dict())

Requires Python 3.10 or later.

Verify before relying

  • Whether the package supports automatic extraction of endpoint documentation from all major Python web frameworks beyond Flask
  • Performance characteristics when generating specs for large APIs with hundreds of endpoints
  • Extent of marshmallow schema inference capabilities and any limitations in complex nested structures

Package facts

License not declared (permissive)
Python support supports the current Python release (>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies 1 — packaging
Maintenance actively maintained — 161 days since the last release
Last repo commit
First released
Downloads 15,080,134/month — #1,199 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: apispec-6.10.0-py3-none-any.whl

Keywords: apispec, swagger, openapi, specification, oas, documentation, spec, rest, api

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14

Tags

openapi spec generatorswagger documentationapi specificationrest api docsopenapi 3 pythonapi schema generatormarshmallow openapi
api-documentationopenapischema-generation

More Documentation packages