Python SDK for RealtimeX real-time messaging service
Project description
RealtimeX Python SDK
Python client library for RealtimeX real-time messaging service.
Installation
pip
pip install realtimex-python
Quick Start
from realtimex import RealtimeX
# Initialize
realtimex = RealtimeX('YOUR_API_KEY', {
'cluster': 'eu', # optional, default 'eu'
'ws_host': 'ws.realtimex.net', # optional
'ws_port': 443, # optional
'encrypted': True, # optional, default True
})
# Subscribe to a channel
channel = realtimex.subscribe('my-channel')
# Listen for events
channel.bind('my-event', lambda data: print('Received:', data))
# Send client events
channel.trigger('client-my-event', {
'message': 'Hello'
})
API
RealtimeX(api_key, options={})
Create a new RealtimeX instance.
Options:
cluster(str): Cluster name, default'eu'ws_host(str): WebSocket host, default'ws.realtimex.net'ws_port(int): WebSocket port, default443encrypted(bool): Use WSS, defaultTrue
Methods
subscribe(channel_name)
Subscribe to a channel.
channel = realtimex.subscribe('my-channel')
unsubscribe(channel_name)
Unsubscribe from a channel.
realtimex.unsubscribe('my-channel')
disconnect()
Disconnect from RealtimeX.
realtimex.disconnect()
Channel
bind(event, callback)
Bind to an event.
channel.bind('my-event', lambda data: print(data))
unbind(event, callback=None)
Unbind from an event.
channel.unbind('my-event')
trigger(event, data)
Trigger a client event (must be prefixed with client-).
channel.trigger('client-my-event', {'message': 'Hello'})
bind_global(callback)
Bind to all events on the channel.
channel.bind_global(lambda event, data: print(event, data))
Connection Events
realtimex.connection.bind('connecting', lambda: print('Connecting...'))
realtimex.connection.bind('connected', lambda: print('Connected!'))
realtimex.connection.bind('disconnected', lambda: print('Disconnected'))
License
MIT
Project details
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 realtimex_python-1.0.0.tar.gz.
File metadata
- Download URL: realtimex_python-1.0.0.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f326bcad0e1311f082e94ce8197d6163f527f0f4690f8d317a965c458fe664b
|
|
| MD5 |
5edda137b868e7aff8326bc43acc4ce2
|
|
| BLAKE2b-256 |
51238bda5e70c56ad6b38442e692059faa87e209e7292036bc2bcbbf94da269b
|
File details
Details for the file realtimex_python-1.0.0-py3-none-any.whl.
File metadata
- Download URL: realtimex_python-1.0.0-py3-none-any.whl
- Upload date:
- Size: 9.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff903264127770f8a8d66fd2955c35a11ce15ef0f9b3c56e5c20883bce012d5f
|
|
| MD5 |
d312b3f0d74d5ecf93a3a0e0776e0a1e
|
|
| BLAKE2b-256 |
f80997bc24317ffcf2accd9801c5811d4e94001097f6a7ca93996490df43ef4b
|