--- id: odmantic version: "1.1.0" license: unclear license_treatment: permissive maintenance: active --- # odmantic — ODMantic, an AsyncIO MongoDB Object Document Mapper for Python using type hints License: permissive · Maintenance: active · Downloads: 111.8K/mo ## 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 above — 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 pip install odmantic uv add odmantic 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_current - Install friction: low - Maintenance: active - Downloads: 111.8K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags mongodb odm python, async mongodb orm, pydantic mongodb mapper, python mongodb object mapper, asyncio mongodb odm, type-hinted mongodb models, motor mongodb wrapper, mongodb, async-first, type-safe [View on SkillFed](https://skillfed.io/packages/odmantic) · [View on PyPI](https://pypi.org/project/odmantic/)