fastapi-injector
python-injector integration for FastAPI
Decision gist · record as of 2026-08-14
Yes, with conditions. Install if you need constructor-based dependency injection in FastAPI and are comfortable with a permissive BSD license and aging maintenance (308 days since last release). The package is stable and has no known vulnerabilities, but expect slower issue resolution. Skip if you prefer lighter-weight solutions or need active maintenance and rapid updates.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.10 or later; FastAPI must be installed separately or via extras (standard or slim).
- Low install friction; single runtime dependency on injector.
- Maintenance status is aging—last release was 308 days ago—so expect slower response to issues, though the package remains functional.
License · maintenance · safety
BSD (permissive) — BSD license is permissive; you may use, modify, and distribute this package freely in commercial and open-source projects with minimal restrictions.
last release 2025-10-10 (308 days)
0 known vulnerabilities (OSV.dev, 2026-08-14) · 117,641 downloads/mo, #12,155 on PyPI
Alternatives
Verify before relying
pip install fastapi-injector
from fastapi import FastAPI
from injector import Injector
from fastapi_injector import attach_injector, Injected
inj = Injector()
app = FastAPI()
attach_injector(app, inj)
@app.get("/")
async def route(dep: SomeClass = Injected(SomeClass)):
return dep.method()- Whether request-scoped caching works correctly with nested async dependencies in production.
- Performance impact of context-variable-based request scope on high-concurrency workloads.
- Compatibility with recent FastAPI versions beyond what the aging maintenance signal suggests.
What it is and what it does
fastapi-injector bridges the injector library (a mature Python dependency-injection container) with FastAPI's dependency system. It lets you define your application's object graph separately from your routes, then inject dependencies into handlers using the Injected marker. This is useful for layered architectures where domain logic (use cases, repositories) lives in inner layers and depends on abstract interfaces, while concrete implementations are bound and provided by the injector in the outer FastAPI layer.
The package includes a RequestScope for per-request caching (so the same instance is reused within a single request but fresh instances are created for new requests), middleware integration, support for both async and sync dependencies, and automatic cleanup of context-manager resources at request end. It requires Python 3.10 or later and depends only on injector.
Use it for
- Implement onion/hexagonal architecture where domain use cases depend on abstract ports and FastAPI routes inject concrete repository implementations.
- Manage per-request database connections or transaction scopes by binding them to request scope and injecting them into multiple route handlers.
- Decouple route handlers from concrete service implementations, making unit tests easier by swapping real services for mocks via injector bindings.
- Share expensive resources (connection pools, caches) across multiple dependencies within a single request without passing them through function signatures.
- Build modular FastAPI applications where different routers can depend on the same injected services without tight coupling.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, with conditions.
Install if you need constructor-based dependency injection in FastAPI and are comfortable with a permissive BSD license and aging maintenance (308 days since last release). The package is stable and has no known vulnerabilities, but expect slower issue resolution. Skip if you prefer lighter-weight solutions or need active maintenance and rapid updates.
Install
fastapi-injector on PyPI
Before you install
Low install friction; single runtime dependency on injector. Maintenance status is aging—last release was 308 days ago—so expect slower response to issues, though the package remains functional.
Requires Python 3.10 or later; FastAPI must be installed separately or via extras (standard or slim).
License in practice
BSD license is permissive; you may use, modify, and distribute this package freely in commercial and open-source projects with minimal restrictions.
Quickstart
pip install fastapi-injector
from fastapi import FastAPI
from injector import Injector
from fastapi_injector import attach_injector, Injected
inj = Injector()
app = FastAPI()
attach_injector(app, inj)
@app.get("/")
async def route(dep: SomeClass = Injected(SomeClass)):
return dep.method()
Verify before relying
- Whether request-scoped caching works correctly with nested async dependencies in production.
- Performance impact of context-variable-based request scope on high-concurrency workloads.
- Compatibility with recent FastAPI versions beyond what the aging maintenance signal suggests.
Package facts
| License | BSD permissive |
| Python support | Supports the current Python release <4,>=3.10 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 1 packageinjector |
| Maintenance | Aging 308 days since the last release |
| First released | |
| Downloads | 117,641 / month, #12,155 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Environment :: Web EnvironmentFramework :: FastAPIIntended Audience :: DevelopersTopic :: Software Development :: LibrariesTyping :: Typed |
Evidence: fastapi_injector-0.9.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “injector integration fastapi”
- fastapi-injectorIntegrates the injector dependency-injection library with FastAPI,…
- wireupWireup is a type-driven dependency injection container for Python…
- dependency-injectorDependency Injector is a dependency injection framework that…
Give your agent the search over MCP, or paste the wish link into any chat.
More Libraries packages
urllib3 is an HTTP client library that provides thread-safe connection pooling, SSL/TLS verification, multipart file uploads, request retries, compression support, and proxy handling for Python applications.
Requests is a Python HTTP library that simplifies sending HTTP/1.1 requests with automatic handling of headers, authentication, cookies, and response parsing.
Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.
Install it if you're building an extensible application or framework.
Provides parsing, arithmetic, and recurrence rule computation for dates and times, with timezone support and iCalendar RFC compliance.
Install it if you need to parse flexible date strings, compute relative dates, handle timezones, or work with recurrence rules—it's the de facto choice for these tasks.
Six provides utility functions to write Python code that runs on both Python 2.7 and Python 3.3+, smoothing over language differences between the two versions.
pytest is a testing framework that lets you write test functions using plain assert statements and automatically discovers and runs them, with detailed failure reporting.
See also injector · fastapi-injectable · Flask-Injector · dependency-injector · inject · fast-depends · fastapi-decorators · rodi · simple-di · fastapi-socketio