Skip to main content

Python SDK for WebSuckIt integration

Project description

web-suck-it-py

Python SDK for websuckit

Test CI Deploy to PyPi PyPI - Version PyPI - Python Version

For tutorials and more in-depth information about websuckit Channels, visit our official docs.

Usage Overview

The following topics are covered:

Installation

Using poetry

poetry add web-suck-it-py

Initialization

from web_suck_it_py import WebSuckIt
from os import getenv
handler = WebSuckIt(
    user_id=UUID(getenv("USER_ID")),
    access_key=getenv("ACCESS_KEY"),
    public_key=getenv("PUBLIC_KEY"),
)

You can get your USER_ID, ACCESS_KEY and PUBLIC_KEY from the websuckit dashboard.

Channel

Accessing a channel's websocket URL

It is possible to access a channel websocket URL by channel name, through the get_connection_url function

from web_suck_it_py import GetChannelRequest
connection_url = handler.get_connection_url(
                    channel_name="CHANNEL-NAME",
                    channel_pass_key="CHANNEL-PASS-KEY",
                    replay_self=False,
                 )

Create channel

from web_suck_it_py import CreateChannelRequest
from web_suck_it_py import Channel
channel: Channel = handler.create_channel(
            CreateChannelRequest(
                channel="new-channel-name",
                max_connections=2,
            )
          )

Get channel

from web_suck_it_py import GetChannelRequest
from web_suck_it_py import Channel
channel: Channel = handler.get_channel(
            GetChannelRequest(
                channel_name = "CHANNEL-NAME",
            )
          )

Get channels (paginated)

from typing import List
from web_suck_it_py import GetChannelListRequest
from web_suck_it_py import Channel
channels: List[Channel] = handler.get_channels(
                            GetChannelListRequest(
                                page=0,
                                per_page=10,
                                search_key="search-channel",
                            )
                           )

Get or Create channel

from web_suck_it_py import GetOrCreateChannelRequest
from web_suck_it_py import Channel
channel: Channel = handler.get_or_create_channel(
            GetOrCreateChannelRequest(
                channel_name = "CHANNEL-NAME",
            )
          )

Update channel

from uuid import UUID
from web_suck_it_py import UpdateChannelRequest
from web_suck_it_py import Channel
channel: Channel = handler.update_channel(
                    UpdateChannelRequest(
                        # set to channel id
                        channel_id=UUID(""),
                        regenerate_pass_key=False,
                        # set `channel` to change channel name
                        channel="change-channel-name",
                        # set `max_connections` to change maximum concurrent connections
                        max_connections=5,
                     )
                    )

Delete channel

from uuid import UUID
from web_suck_it_py import DeleteChannelRequest
handler.delete_channel(
    DeleteChannelRequest(
        channel_id=UUID(""),
    )
)

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

web_suck_it_py-0.0.2.tar.gz (6.9 kB view hashes)

Uploaded Source

Built Distribution

web_suck_it_py-0.0.2-py3-none-any.whl (10.2 kB view hashes)

Uploaded Python 3

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