Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

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 β€” Python


Install

pip install dnotifier

Dependencies 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

β†’ Credentials & environment


Next steps

Last updated