Realtime WebSocket Events for Python — Django, Flask & FastAPI
Trigger real-time WebSocket events from Django, Flask, and FastAPI. Zero-dependency server SDK using only the Python standard library — no WebSocket server to run or manage.
pip install apinator-server npm install @apinator/client Sending real-time WebSocket notifications from a Python backend doesn't require running a separate WebSocket server or process. Apinator's Python server SDK lets you publish events from Django views, Flask routes, or FastAPI endpoints with a single API call. The persistent WebSocket connections live on Apinator's infrastructure — your Python application just triggers events when something happens.
Quick Start
How to add realtime WebSocket events to Django, Flask, or FastAPI
Add realtime features to your Python app in a few steps.
Install the server SDK
Add the Python server SDK. Zero dependencies — uses only the standard library.
Initialize the client
Create an Apinator client with your app credentials. Works with any Python framework.
Trigger WebSocket events from your views
Publish real-time WebSocket events from any Python backend — Django views, Flask routes, FastAPI endpoints, or Celery tasks.
Authenticate private channels
Add an endpoint that authenticates channel subscriptions for your frontend clients.
Why Python
Built for Python developers
Zero Dependencies
Uses only Python stdlib — hashlib, hmac, urllib, json. No requests, no httpx, no bloat.
Works Everywhere
Django, Flask, FastAPI, Tornado, or plain scripts. Any Python 3.10+ environment.
Type Hints
Full type annotations throughout. Works with mypy and Pyright for static type checking.
Webhook Verification
Verify incoming webhook signatures with a single method call. Replay attack protection included.
How to add WebSocket notifications to a Python backend
Python web frameworks like Django, Flask, and FastAPI are built around the request/response cycle — they don't maintain persistent connections out of the box. Adding WebSocket support traditionally required integrating additional libraries (Django Channels, python-socketio, websockets) and running separate worker processes alongside your existing web server, each with their own configuration and operational overhead.
Apinator takes a different approach. Your Python backend doesn't manage any WebSocket connections. Instead, you make a simple HTTPS API call using Apinator's SDK to publish an event — from a Django view, a Celery task, a FastAPI background task, or any other Python code. Apinator's servers maintain the persistent WebSocket connections to your browser clients and deliver the event in real-time, typically in under 100ms.
The Python SDK has zero dependencies. It uses only Python's standard library — hmac, hashlib, urllib.request — to sign requests and publish events. This means no additions to requirements.txt, no dependency conflicts, and no compatibility issues across Python 3.10+ environments regardless of the framework.
Full Example
Full Example: Realtime WebSocket Dashboard with Django
Complete WebSocket example: Django views for channel authentication and event publishing, plus a JavaScript frontend that receives real-time updates.
Related Docs
Read the core WebSocket guides
Related Use Cases
Explore realtime use cases
Start building realtime Python apps
Completely free. No credit card. No catch.