apischema
JSON (de)serialization, GraphQL and JSON schema generation using Python typing.
What it is and what it does
Apischema is a Python library for converting between Python objects and JSON, generating GraphQL schemas, and producing JSON schemas—all driven by standard Python type annotations and dataclasses. It works with any type (dataclasses, NewType, generic collections) without requiring a base class, and integrates with your IDE and type checker naturally.
The library is designed to stay close to Python's standard library (dataclasses, typing) rather than imposing its own object model. It handles validation during deserialization, generates schemas for documentation and API contracts, and supports GraphQL as a first-class concern alongside JSON. It has no runtime dependencies and supports Python 3.9 and later, including PyPy3.
Use it for:
- Deserialize and validate JSON API responses into typed Python dataclasses with automatic error reporting.
- Generate JSON Schema and GraphQL schemas from your existing dataclass definitions for API documentation.
- Serialize Python dataclass instances back to JSON for API responses without manual field mapping.
- Build GraphQL query resolvers that work directly with your Python type annotations.
- Adapt the library to support custom types (ORM models, attrs classes) via its conversion system.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Apischema handles JSON serialization/deserialization, GraphQL schema generation, and JSON schema generation directly from Python type annotations and dataclasses, with no base class requirement.
Yes. Apischema is actively maintained, has no dependencies, supports current Python versions, and solves a real problem (API data handling) without imposing a base class or breaking from standard library conventions. The MIT license is permissive. No known security vulnerabilities. Suitable for production use in API clients and servers.
Install
apischema on PyPI
pip
pip install apischemauv
uv add apischemapoetry
poetry add apischemaInstalling apischema
Before you install
Low install friction with no runtime dependencies. Active maintenance with recent commits and a steady release cadence since 2020; last release 2024-10-01.
License in practice
MIT license permits commercial and private use with minimal restrictions; you must include a copy of the license and copyright notice.
Quickstart
pip install apischema
from dataclasses import dataclass
from apischema import deserialize, serialize
@dataclass
class Item:
name: str
value: int
data = {"name": "example", "value": 42}
item = deserialize(Item, data)
result = serialize(Item, item)
Requires Python 3.9 or later; PyPy3 is supported.
Verify before relying
- Whether performance claims ('a lot faster') have been independently verified against current versions of competing libraries.
- Whether the GraphQL implementation is feature-complete relative to graphql-core or other GraphQL libraries.
- Real-world adoption patterns and ecosystem integration beyond the documented examples.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 682 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 158,326/month — #10,727 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: apischema-0.19.0-py3-none-any.whl
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
colanderColander deserializes and validates data…
permissive · top 15,000 on PyPI
dataclasses-jsonschemaGenerates JSON Schema from Python dataclasses…
permissive · top 15,000 on PyPI
dataclasses-avroschemaGenerates Avro schemas from Python dataclasses,…
permissive · top 5,000 on PyPI
py-avro-schemaGenerates Apache Avro schemas from Python…
permissive · top 15,000 on PyPI
datamodel-code-generatorGenerates Python data models (Pydantic,…
permissive · top 5,000 on PyPI
json-strong-typingSerializes Python dataclasses to JSON and…
permissive · top 15,000 on PyPI
warchant_dc_schemaGenerates JSON Schema (2020-12 draft) from…
permissive · top 15,000 on PyPI
desertDesert generates marshmallow serialization…
permissive · top 15,000 on PyPI
djangorestframework-queryfieldsAllows Django REST framework API clients to…
permissive · top 15,000 on PyPI
anyjsonAnyjson provides a uniform API for JSON…
permissive · top 15,000 on PyPI