Dapr FastAPI Extension
raw JSON → 1.17.4 verified Fri May 01 auth: no python
The Dapr FastAPI extension integrates Dapr's pub/sub, actors, and bindings with FastAPI applications. Version 1.17.4 supports Python >=3.10, released on 2025-09-12. Release cadence is approximately monthly.
pip install dapr-ext-fastapi Common errors
error dapr.exceptions.DaprInternalError: Actor not found ↓
cause Actor class not registered with DaprApp.
fix
Add dapr_app.register_actor(YourActorClass) after actor definition.
error ImportError: cannot import name 'DaprApp' from 'dapr.fastapi' ↓
cause Incorrect import path; the module is dapr.ext.fastapi.
fix
Use from dapr.ext.fastapi import DaprApp
error RuntimeError: DaprApp has already been initialized ↓
cause Calling dapr_app.init() or re-initializing with a second FastAPI app.
fix
Only pass the FastAPI app once in the constructor: DaprApp(app).
Warnings
breaking In v1.3.0, the subscription decorator changed from @dapr_app.subscribe to @app.post with DaprPubSubMiddleware. Old decorator no longer works. ↓
fix Use FastAPI routes with DaprPubSubMiddleware for pub/sub.
deprecated dapr_app.init() is deprecated in favor of initializing DaprApp with the FastAPI app directly. ↓
fix Use DaprApp(app) instead of DaprApp() and then dapr_app.init(app).
gotcha When using Dapr actors, ensure the actor class is registered with @actor decorator and dapr_app.register_actor is called. Missing registration results in 'Actor not found' errors. ↓
fix Call dapr_app.register_actor(MyActor) after actor definition.
Imports
- DaprApp wrong
from dapr.fastapi import DaprAppcorrectfrom dapr.ext.fastapi import DaprApp
Quickstart
from fastapi import FastAPI
from dapr.ext.fastapi import DaprApp
app = FastAPI()
dapr_app = DaprApp(app)
@app.get('/')
def read_root():
return {'message': 'Hello Dapr'}