Skip to main content

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.0

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

realtime-1.0.1.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

realtime-1.0.1-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: realtime-1.0.1.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.3 Darwin/22.2.0

File hashes

Hashes for realtime-1.0.1.tar.gz
Algorithm Hash digest
SHA256 d72a2c039cb86f63d4c5606fd62c8cfeadf4ed96113eb3bfa50cb262ee1e01e5
MD5 a3a924056467fe63e0964c83f92de588
BLAKE2b-256 f44e9adfaee8f5c90165f333a3aa46a0548432f28ecc024c5eedc2b84ac9b756

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: realtime-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.3 Darwin/22.2.0

File hashes

Hashes for realtime-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bd4b6c18f1ab00ca2f8774b6cf71fee21674216a9da55bc01e68d45daf64ccb1
MD5 e63f542ed5383b4c7762dddf97fab547
BLAKE2b-256 3862281fb3c4d1cac3e66264e4bdd549fd8005aad6eb73e93580c8ea2fccb8ee

See more details on using hashes here.

Provenance

Supported by

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