Skip to main content

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, default 443
  • encrypted (bool): Use WSS, default True

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

realtimex_python-1.0.1.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

realtimex_python-1.0.1-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file realtimex_python-1.0.1.tar.gz.

File metadata

  • Download URL: realtimex_python-1.0.1.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for realtimex_python-1.0.1.tar.gz
Algorithm Hash digest
SHA256 1ff1ea3c5ad57193d401bc4a3bff6d85e569eb295256c98a59fe42768a2a4f78
MD5 84cb9e227fdaf052d5a11106d2b63f16
BLAKE2b-256 88bb4cc28eff787791259e34fc5d8feba6c45c3aa651e1093c99336883d6529f

See more details on using hashes here.

File details

Details for the file realtimex_python-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for realtimex_python-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cf0998b0e9f767f40b77f84891860ed0e1e675afa64eb72525864b742f003fbd
MD5 69cb297c1907b93cd09234e6f429689f
BLAKE2b-256 558432fe1c26be68f3d025762ea67addfe106e39cc3149d644d6519ffc49a6ed

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page