© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•3y ago
Jeremy Deceuster

Python realtime messages

I'm struggling to setup a realtime connection in python. Could someone point me in the right direction? This is my code so far

from realtime.connection import Socket
from supabase.client import Client, ClientOptions, SupabaseRealtimeClient


class SupabaseClient(Client):
    def __init__(
        self, db_id: str, api_key: str, options: ClientOptions = ClientOptions()
    ):
        super().__init__(f"https://{db_id}.supabase.co", api_key, options)

        # Assign supabase id
        self.supabase_id = db_id

        # Create realtime client
        socket = Socket(
            url=f"wss://{db_id}.supabase.co/realtime/v1/websocket?apikey={api_key}&vsn=1.0.0",
            auto_reconnect=True,
        )
        socket.connect()
        self.realtime = SupabaseRealtimeClient(
            socket=socket, schema="public", table_name="*"
        )
        self.realtime.subscribe(self.test_cb)

    def test_cb(self, payload):
        print(payload)


if __name__ == "__main__":
    db = SupabaseClient(db_id="id", api_key="key")
from realtime.connection import Socket
from supabase.client import Client, ClientOptions, SupabaseRealtimeClient


class SupabaseClient(Client):
    def __init__(
        self, db_id: str, api_key: str, options: ClientOptions = ClientOptions()
    ):
        super().__init__(f"https://{db_id}.supabase.co", api_key, options)

        # Assign supabase id
        self.supabase_id = db_id

        # Create realtime client
        socket = Socket(
            url=f"wss://{db_id}.supabase.co/realtime/v1/websocket?apikey={api_key}&vsn=1.0.0",
            auto_reconnect=True,
        )
        socket.connect()
        self.realtime = SupabaseRealtimeClient(
            socket=socket, schema="public", table_name="*"
        )
        self.realtime.subscribe(self.test_cb)

    def test_cb(self, payload):
        print(payload)


if __name__ == "__main__":
    db = SupabaseClient(db_id="id", api_key="key")
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

supabase realtime in python
SupabaseSSupabase / help-and-questions
3y ago
Deleted realtime.messages table
SupabaseSSupabase / help-and-questions
3mo ago
python realtime silent timeout issue
SupabaseSSupabase / help-and-questions
6mo ago
Realtime client doesn't receive broadcast messages
SupabaseSSupabase / help-and-questions
6mo ago