{"categories":[{"label":"Python Modules","url":"https://skillfed.io/packages/category/software-development-libraries-python-modules/21"},{"label":"Application Frameworks","url":"https://skillfed.io/packages/category/software-development-libraries-application-frameworks/5"}],"enrichment":{"capability":"Enables FastAPI's Depends() dependency injection system to work outside route handlers\u2014in CLI tools, background workers, Celery tasks, and scheduled jobs\u2014without duplicating dependency logic.","skillfed_tags":["dependency-injection","fastapi-extension","cli-tools"],"use_cases":["Reuse FastAPI route dependencies in CLI commands without refactoring or duplication.","Inject dependencies into Celery tasks or background workers using the same Depends() syntax as routes.","Access FastAPI app.state and registered dependencies in scheduled jobs (cron, APScheduler).","Write testable functions with dependency overrides using manual mock injection.","Handle async dependencies in Kafka consumers or streaming callbacks with async_get_injected_obj().","Manage resource lifecycle (database connections, file handles) via generator-based dependencies in non-route contexts."],"what_it_does":"fastapi-injectable is a lightweight decorator and function-based wrapper that extends FastAPI's Depends() system to work outside route handlers. It solves a long-standing limitation (FastAPI issue #1105) where developers had to duplicate dependency logic or introduce a second DI framework when moving from routes into CLI commands, background tasks, Celery jobs, or scheduled workers.\n\nThe package provides three main entry points: the @injectable decorator for marking functions, get_injected_obj() for synchronous contexts, and async_get_injected_obj() for code running in an active event loop. It handles full async support, resource cleanup via generator dependencies, optional caching, and graceful shutdown. A bundled mypy plugin enables type-checking of @injectable calls. The single runtime dependency is fastapi itself.","worth_installing":"Yes. The package is actively maintained, has no known vulnerabilities, and solves a real problem for FastAPI users who need dependency injection outside routes. Low install friction, permissive license, and production-stable status make it a straightforward choice. The main gotcha is cache management in loops\u2014read the long-running worker documentation before deploying to background tasks."},"id":"fastapi-injectable","links":{"html":"https://skillfed.io/packages/fastapi-injectable","md":"https://skillfed.io/packages/fastapi-injectable.md","pypi":"https://pypi.org/project/fastapi-injectable/"},"maintenance":{"status":"active"},"meta":{"latest_release":"2026-06-21","license_spdx":"MIT","license_treatment":"permissive","name":"fastapi-injectable","python_support":"supports_current","summary":"Use FastAPI's Depends() anywhere \u2014 in CLI tools, Celery tasks, background workers, and more. No refactoring needed."},"popularity":{"monthly_downloads":83496,"position":14072,"tier":"top_15000"},"security":{"n_vulnerabilities":0},"version":"1.6.0"}
