Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

fastapi-pymongo

FastAPI integration for PyMongo:

  • PyObjectId: Pydantic-native ObjectId. Validates from ObjectId or hex string, serializes to a string in JSON mode (Python-mode dumps keep the ObjectId, so documents round-trip through insert_one), correct OpenAPI/JSON schema.
  • MongoSettings: pydantic-settings base class for Mongo URI and database name. Subclass to add app settings.
  • mongo_lifespan / get_client / get_database: client lifecycle wired to FastAPI's lifespan, exposed via Depends().
  • beanie_lifespan (optional, fastapi-pymongo[beanie]): runs Beanie's init_beanie alongside the rest of fastapi_pymongo, for an ODM on top.

Install

pip install fastapi-pymongo

Optional Beanie integration:

pip install "fastapi-pymongo[beanie]"

Examples

Development

pip install -e ".[dev]"
pytest            # unit tests (integration and perf are deselected by default)
pytest -m perf    # PyObjectId overhead benchmarks
ruff check src tests examples
mypy src

Integration tests need a running MongoDB; set MONGODB_URI (default mongodb://localhost:27017). Run the full suite with a local server, for example via mongodb-runner start --topology standalone.

Documentation

Sphinx docs (furo theme) under docs/source:

pip install -e ".[docs]"
sphinx-build -b html docs/source docs/build
open docs/build/index.html

Metadata

Release files for fastapi-pymongo 0.1.0a4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fastapi-pymongo 0.1.0a4
File Size Uploaded Provenance Actions
fastapi_pymongo-0.1.0a4.tar.gz 12.3 kB With provenance Details for fastapi_pymongo-0.1.0a4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for fastapi-pymongo 0.1.0a4
File Interpreter ABI Platform Actions
fastapi_pymongo-0.1.0a4-py3-none-any.whl Python 3 none any Details for fastapi_pymongo-0.1.0a4-py3-none-any.whl

Total release size: 22.9 kB

Release files / fastapi_pymongo-0.1.0a4.tar.gz

Download URL fastapi_pymongo-0.1.0a4.tar.gz
Size 12.3 kB
Tags Source
SHA-256 checksum
How to use checksums
7a9008714885427e2bfbbd9eb9a4b14df8f7f2b385801c54775a58c973a1b1d0
BLAKE2b-256 checksum
How to use checksums
69e3be41089b0970a22bda8d0ef266bef5193918b88840de8a50c7b36cd90dc4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Release files / fastapi_pymongo-0.1.0a4-py3-none-any.whl

Download URL fastapi_pymongo-0.1.0a4-py3-none-any.whl
Size 10.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
58c4842a49e5f5937ac99a8dab6b5701da808629ea7310dab0e7c76a9e6aa92d
BLAKE2b-256 checksum
How to use checksums
e59f7d63292541d72d3a0f02080948a2f8ac4dd48262071a01edf0e0d8e6b6d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Security for fastapi-pymongo 0.1.0a4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for fastapi_pymongo-0.1.0a4.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page