No project description provided
Project description
realtime-py
Python Client Library to interface with the Phoenix Realtime Server
Requirements
Python 3 higher
Installation
pip3 install realtime==1.0.2
Installation from source
pip3 install -r requirements.txt
python3 usage.py
Quick Start
from realtime.connection import Socket
def callback1(payload):
print("Callback 1: ", payload)
def callback2(payload):
print("Callback 2: ", payload)
if __name__ == "__main__":
URL = "ws://localhost:4000/socket/websocket"
s = Socket(URL)
s.connect()
channel_1 = s.set_channel("realtime:public:todos")
channel_1.join().on("UPDATE", callback1)
channel_2 = s.set_channel("realtime:public:users")
channel_2.join().on("*", callback2)
s.listen()
Sample usage with Supabase
Here's how you could connect to your realtime endpoint using Supabase endpoint. Correct as of 5th June 2021. Please replace SUPABASE_ID and API_KEY with your own SUPABASE_ID and API_KEY. The variables shown below are fake and they will not work if you try to run the snippet.
from realtime.connection import Socket
SUPABASE_ID = "dlzlllxhaakqdmaapvji"
API_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiYW5vbiIsImlhdCI6MT"
def callback1(payload):
print("Callback 1: ", payload)
if __name__ == "__main__":
URL = f"wss://{SUPABASE_ID}.supabase.co/realtime/v1/websocket?apikey={API_KEY}&vsn=1.0.0"
s = Socket(URL)
s.connect()
channel_1 = s.set_channel("realtime:*")
channel_1.join().on("UPDATE", callback1)
s.listen()
Then, go to the Supabase interface and toggle a row in a table. You should see a corresponding payload show up in your console/terminal.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file realtime-1.0.2.tar.gz.
File metadata
- Download URL: realtime-1.0.2.tar.gz
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
776170a4329edc869b91e104c554cda02c8bf8e052cbb93c377e22482870959c
|
|
| MD5 |
93d57e05e24fbc888246e322027de9d4
|
|
| BLAKE2b-256 |
e30ea461b2ad20b380e1f58280260f7a2519114933d4c1c8eaae06dfc595a50d
|
File details
Details for the file realtime-1.0.2-py3-none-any.whl.
File metadata
- Download URL: realtime-1.0.2-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f8375199fd917cd0ded818702321f91b208ab72794ade0a33cee9d55ae30f11
|
|
| MD5 |
bf2b61095f9958a68d5fa1caa7f74cf7
|
|
| BLAKE2b-256 |
2ec0b0be23f55642d0018a5c1e3c5e6aeda11fe5e18e24b5f969636b10fc34a5
|