skillfed

apischema

JSON (de)serialization, GraphQL and JSON schema generation using Python typing.

apischema v0.19.0 158.3K downloads/30d#10,727 on PyPI242
Permissive license MIT Active released

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 apischema

uv

uv add apischema

poetry

poetry add apischema

Installing 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

Development Status :: 4 - BetaIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.9Topic :: Software Development :: Libraries :: Python Modules

Tags

json serialization deserialization pythongraphql schema generation typingjson schema from dataclassesapi data validation pythontype-driven serialization
json-serializationgraphqltype-annotations

More Python Modules packages