skillfed

odmantic

ODMantic, an AsyncIO MongoDB Object Document Mapper for Python using type hints

odmantic v1.1.0 111.8K downloads/30d#12,399 on PyPI1,175
Permissive license Active released

What it is and what it does

ODMantic bridges Python type hints and MongoDB by letting you define models as Pydantic classes, then use those classes to query, insert, update, and delete documents with full type safety and validation. It wraps motor (the async MongoDB driver) and pymongo, supporting both async/await patterns (ideal for ASGI frameworks like FastAPI) and synchronous code.

You define a model by subclassing Model and annotating fields with Python types; ODMantic handles collection naming, field validation via Pydantic, and automatic _id generation. Queries use Python comparison operators (e.g., `Publisher.founded <= 2000`) rather than MongoDB query syntax, and the engine provides methods like `find()`, `find_one()`, `save()`, and `save_all()` to perform database operations. Built-in JSON serialization and schema generation are included.

Use it for:

  • Build FastAPI or Starlette applications with async MongoDB persistence using type-hinted models.
  • Define MongoDB schemas with Pydantic validation to catch invalid data before it reaches the database.
  • Query MongoDB collections using Python operators instead of MongoDB query syntax.
  • Migrate from synchronous ORMs to async-first code without rewriting model definitions.
  • Generate JSON schemas and API documentation automatically from your ODMantic models.

Worth the install?

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

ODMantic is an async-first Object Document Mapper for MongoDB that lets you define database models using Python type hints and Pydantic validation, then query and persist them with a functional API.

Yes. ODMantic is actively maintained, has low install friction, carries no known vulnerabilities, and solves a real problem for Python developers using MongoDB with async frameworks. The ISC license is permissive. Install it if you need an async MongoDB ODM with strong type safety and Pydantic integration.

Install

odmantic on PyPI

pip

pip install odmantic

uv

uv add odmantic

poetry

poetry add odmantic

Installing odmantic

Before you install

Low friction install with a pure-Python wheel. Actively maintained as of 2026-05-19 with 1175 repository stars. Depends on pydantic, motor, pymongo, and typing-extensions—all stable, widely-used libraries.

License in practice

Licensed under ISC (permissive), allowing commercial and private use with minimal restrictions.

Quickstart

pip install odmantic

from odmantic import Model, Field, AIOEngine
from typing import Optional

class Publisher(Model):
    name: str
    founded: int = Field(ge=1440)
    location: Optional[str] = None

engine = AIOEngine()
await engine.save_all([Publisher(name="Test", founded=2000)])
results = await engine.find(Publisher, Publisher.founded >= 2000)

Requires a running MongoDB instance (4.0 or later) and Python 3.8 or later. Async operations require an event loop context.

Verify before relying

  • Whether Pydantic 2.5+ is strictly required or if earlier 2.x versions work.
  • Performance characteristics and scalability limits for large document collections.
  • Completeness of query operator support compared to raw PyMongo.

Package facts

License not declared (permissive)
Python support supports the current Python release (>=3.8)
Install friction low — pure-Python wheel
Runtime dependencies 4 — pydantic, typing-extensions, motor, pymongo
Maintenance actively maintained — 202 days since the last release
Last repo commit
First released
Downloads 111,772/month — #12,399 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: odmantic-1.1.0-py3-none-any.whl

Keywords: mongodb, asyncio, types, pydantic, motor

Development Status :: 4 - BetaEnvironment :: Web EnvironmentFramework :: AsyncIOFramework :: PydanticFramework :: Pydantic :: 2Intended Audience :: DevelopersIntended Audience :: Information TechnologyIntended Audience :: System AdministratorsLicense :: OSI Approved :: ISC License (ISCL)Operating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonTopic :: DatabaseTopic :: Database :: Front-EndsTopic :: InternetTopic :: Software DevelopmentTopic :: Software Development :: LibrariesTopic :: Software Development :: Libraries :: Python ModulesTopic :: Software Development :: Object BrokeringTyping :: Typed

Tags

mongodb odm pythonasync mongodb ormpydantic mongodb mapperpython mongodb object mapperasyncio mongodb odmtype-hinted mongodb modelsmotor mongodb wrapper
mongodbasync-firsttype-safe

More Software Development packages