$npx skillfedfor your agent

spectree

Generate OpenAPI document and validate request & response with Python annotations.

Worth itPyPI Python ModulesReleased Dec 2025374.2K downloads / moApache-2.0Pure Python

Decision gist · record as of 2026-08-14

pure-Python wheel — spectree-2.0.1-py3-none-any.whl
v2.0.1 · released 2025-12-16 · Python >=3.10 · 1 runtime deps: pydantic

Yes. SpecTree is actively maintained, has no known vulnerabilities, and installs with minimal friction. It solves a real problem—keeping API documentation synchronized with code—and does so without requiring separate YAML files. The single pydantic dependency is lightweight and widely used. It's most valuable if you're building REST APIs with one of the four supported frameworks and want automatic OpenAPI generation with request/response validation.AI-flagged interpretation of the facts on this page — verify before relying

Before you install

  • Requires Python 3.10 or later.
  • Requires one of the supported web frameworks (Flask, Quart, Falcon, or Starlette) to be installed separately.
  • Low install friction with a single runtime dependency (pydantic).

License · maintenance · safety

Apache-2.0 (permissive) — Licensed under Apache-2.0 (permissive), allowing commercial and private use with minimal restrictions.

last release 2025-12-16 (241 days) · last repo commit 2026-08-10 · 362 stars

0 known vulnerabilities (OSV.dev, 2026-08-14) · 374,170 downloads/mo, #7,148 on PyPI

Verify before relying

pip install spectree

from spectree import SpecTree, Response
from pydantic import BaseModel

api = SpecTree('flask')

class QueryModel(BaseModel):
    name: str

@api.validate(query=QueryModel, resp=Response(HTTP_200=None))
def hello(query: QueryModel):
    return {'message': f'Hello {query.name}'}

api.register(app)
# API docs at /apidoc/redoc, /apidoc/swagger, or /apidoc/scalar
  • Whether offline mode (spectree[offline]) works reliably with all supported frameworks and UI options.
  • Performance characteristics when validating large request/response payloads or high request volumes.
  • Compatibility with frameworks beyond the four explicitly listed (Flask, Quart, Falcon, Starlette).
Same gist for agents: .md · .json

What it is and what it does

SpecTree is a Python library that bridges type annotations and OpenAPI specification generation. It uses pydantic models to define request and response schemas, then automatically generates OpenAPI documents and serves them via interactive UI (Redoc, Swagger, or Scalar). The library works as a decorator-based validator that intercepts HTTP requests to your web application, validates query parameters, JSON bodies, headers, and cookies against your pydantic models, and validates responses before they're sent to clients.

The library is framework-agnostic at its core but provides integrations for Flask, Quart, Falcon, and Starlette. You define your data structures once as pydantic BaseModels, decorate your route handlers with @api.validate(), and SpecTree handles both validation and documentation generation. Failed validations return 422 status with structured error details. It supports security schemes (API keys, OAuth2), deprecated endpoints, tags, and custom response codes.

Use it for

  • Build REST APIs with automatic OpenAPI documentation by decorating endpoints with pydantic model validators.
  • Validate incoming query strings, JSON payloads, headers, and cookies against strict schemas without manual parsing.
  • Generate interactive API documentation (Swagger UI, Redoc, or Scalar) that stays in sync with your code.
  • Enforce response validation to catch serialization errors before they reach clients.
  • Define API security schemes (API keys, OAuth2) and enforce them per-endpoint or globally.
  • Skip boilerplate YAML configuration by deriving OpenAPI specs directly from Python type annotations.

Worth the install?

AI-flagged interpretation of the facts on this page. Verify before relying on it.

Worth it

Yes.

SpecTree is actively maintained, has no known vulnerabilities, and installs with minimal friction. It solves a real problem—keeping API documentation synchronized with code—and does so without requiring separate YAML files. The single pydantic dependency is lightweight and widely used. It's most valuable if you're building REST APIs with one of the four supported frameworks and want automatic OpenAPI generation with request/response validation.

Install

spectree on PyPI

Before you install

Low install friction with a single runtime dependency (pydantic). Actively maintained with recent commits and modern Python support (3.10+). No known vulnerabilities.

Requires Python 3.10 or later. Requires one of the supported web frameworks (Flask, Quart, Falcon, or Starlette) to be installed separately.

License in practice

Licensed under Apache-2.0 (permissive), allowing commercial and private use with minimal restrictions.

Quickstart

pip install spectree

from spectree import SpecTree, Response
from pydantic import BaseModel

api = SpecTree('flask')

class QueryModel(BaseModel):
    name: str

@api.validate(query=QueryModel, resp=Response(HTTP_200=None))
def hello(query: QueryModel):
    return {'message': f'Hello {query.name}'}

api.register(app)
# API docs at /apidoc/redoc, /apidoc/swagger, or /apidoc/scalar

Verify before relying

  • Whether offline mode (spectree[offline]) works reliably with all supported frameworks and UI options.
  • Performance characteristics when validating large request/response payloads or high request volumes.
  • Compatibility with frameworks beyond the four explicitly listed (Flask, Quart, Falcon, Starlette).

Package facts

LicenseApache-2.0 permissive
Python supportSupports the current Python release >=3.10
Install frictionLow. Pure-Python wheel
Runtime dependencies
1 package
pydantic
MaintenanceActively maintained 241 days since the last release
Last repo commit
First released
Downloads374,170 / month, #7,148 on PyPI 30-day window, as of 2026-08-14
Known vulnerabilitiesNone known OSV.dev, checked 2026-08-14
Classifiers
Intended Audience :: DevelopersOperating 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 :: Free ThreadingProgramming Language :: Python :: Implementation :: CPythonTopic :: Software Development :: Libraries :: Python Modules

Evidence: spectree-2.0.1-py3-none-any.whl

Tags

Capabilities
openapi document generationrequest response validationpython annotations api docspydantic validation decoratorapi schema from type hintsswagger redoc scalar uiframework-agnostic openapi
Topics
openapi-generationrequest-validationapi-documentation

Let your AI agent find packages like this

Example. Real query, live index.

You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.

wish › “swagger redoc scalar ui”

Give your agent the search over MCP, or paste the wish link into any chat.

More Python Modules packages

idna Worth it
PyPI · Python Modules · released Jun 2026

Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.

Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.

BSD-3-Clausepure Python · 3.9+
1.8Bdownloads / mo
setuptools Worth it
PyPI · Python Modules · released Aug 2026

Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.

MITpure Python · 3.10+
1.6Bdownloads / mo
PyYAML Worth it
PyPI · Python Modules · released Sep 2025

PyYAML parses and emits YAML 1.1 data format, enabling serialization and deserialization of configuration files and Python objects to and from human-readable YAML text.

MITcompiled wheel · 3.8+
1.2Bdownloads / mo
pydantic Worth it
PyPI · Python Modules · released May 2026

Pydantic validates Python data structures against type hints, coercing and checking input at runtime to ensure it matches a declared schema.

MITpure Python · 3.9+
1.1Bdownloads / mo
annotated-types Worth it
PyPI · Python Modules · released Jul 2026

Provides reusable metadata objects for use with PEP-593 `typing.Annotated` to express common constraints like bounds, collection sizes, and predicates on types.

Install it if you use or build libraries that need to express type constraints in a standardized, inspectable way—or if you want to annotate your own types with…

MITpure Python · 3.10+
871.3Mdownloads / mo
typing-inspection Worth it
PyPI · Python Modules · released Aug 2026

Provides runtime tools to inspect and introspect Python type annotations, enabling programmatic examination of type hints at execution time.

MITpure Python · 3.10+
783.0Mdownloads / mo

See also flask-pydantic-spec · quart-schema · fastspec · flask-openapi3 · swagger-ui-py · openapi3 · openapi-core · drf-yasg · flask-openapi3-swagger · aiopenapi3