Python
Use the DNotifier Python SDK in asyncio applications: FastAPI backends, background workers, CLI tools, and data pipelines. The client is async-first β call await notifier.connect() and other methods from async def functions.
Requirements
Requirement
Version / notes
Python
3.9 or later
pip / poetry / uv
Any recent version
DNotifier credentials
app_id and secret from app.dnotifier.com
Install
pip install dnotifierDependencies httpx and websockets are installed automatically.
Basic pattern
import asyncio
from dnotifier import DNotifier
async def main():
notifier = DNotifier(
app_id="your-app-id",
secret="your-app-secret",
transport="ws",
user_id="user-123",
on_connected=lambda: print("Connected"),
on_message=lambda msg: print(msg.payload.to_json()),
on_disconnected=lambda **kw: print("Disconnected", kw),
)
await notifier.connect()
await notifier.send(
sender_id="user-123",
receiver_id="user-456",
data={"type": "text", "text": "Hello"},
)
await notifier.disconnect()
asyncio.run(main())Transport choice
Use case
Transport
Live chat, push-style updates
"ws"
AI prompts, RAG, workflows, sync RPC
"http"
See Choose your transport and the transport matrix.
FastAPI example
Run DNotifier in a lifespan handler or background task:
Environment variables
Next steps
Last updated