fastapi-pymongoΒΆ FastAPI integration for PyMongo. Contents Installation Requirements PyObjectId PyObjectId Why Why not pydantic_extra_types.MongoObjectId Why not beanie.PydanticObjectId Why not the pyobjectid PyPI package Usage Settings MongoSettings Why Usage Adding your own settings Overriding for tests Client lifecycle mongo_lifespan() get_client() get_database() Why Usage What this does not do API reference Reference Why Changelog [Unreleased] [0.1.0a3] - 2026-10-13 [0.1.0a2] - 2026-10-08 [0.1.0a1] - 2026-10-05 [0.1.0a0] - 2026-10-01 Examples Quickstart 1. Configure settings and lifespan 2. Define a model with a Pydantic-native ObjectId 3. Write route handlers 4. Run it Next steps Beanie integration Why Install Usage Where PyObjectId fits Using both in the same app