Skip to main content

Huddle01 Python SDK

Overview

The Huddle01 Python SDK provides a comprehensive solution for interacting with Huddle01's infrastructure. It enables developers to build real-time communication systems with support for rooms, peers, active speakers, permissions, and WebSocket-based connections.

Features

  • Access Token Management: Generate and manage access tokens for secure communication.
  • Room Management: Create and manage rooms with various permissions and roles.
  • Local and Remote Peers: Define and manage local and remote peers, including their producers and roles.
  • WebSocket Communication: Connect to Huddle01's WebSocket server for real-time data exchange.
  • Enhanced Event Handling: Utilize EnhancedEventEmitter for subscribing and handling events seamlessly.
  • Active Speaker Tracking: Manage active speakers within a room.
  • Produce and Consume Media: Produce and consume media tracks like video, audio, and screen sharing.

Installation

To use the SDK, install it via pip:

pip install huddle01

Getting Started

Here's a quick example to get started:

1. Create a Huddle01 Room

Every interaction with the Huddle01 dRTC Network start with a Room, which is a container for peers and media streams.

You can read how to create a room here.

2. Create an Access Token

Generate an access token using your API key and room ID.

from huddle01.access_token import AccessToken, AccessTokenData, Role

data = AccessTokenData(
    api_key="your_api_key",
    room_id="room_id",
    role=Role.HOST
)
token = AccessToken(data)

jwt_token = await token.to_jwt()

3. Initialize the Huddle Client

Connect to a room using the generated token.

from huddle01.huddle_client import HuddleClient, HuddleClientOptions

options = HuddleClientOptions(autoConsume=True)

client = HuddleClient(project_id="project_id", options=options)

room = await client.create(room_id="room_id", token=jwt_token)

4. Work with Peers and Rooms

Manage peers, producers, and permissions.

# Example: Access the local peer
local_peer = room.local_peer

# Example: List remote peers
remote_peers = room.remote_peers

5. Produce and Consume Media

Produce and consume tracks like video, audio, or screen.

Producing Media

To produce media, use the LocalPeer.produce() method.

track = "video_track"  # Replace with the actual media track
producer = await local_peer.produce(track)

Consuming Media

To consume media from a remote peer, use the LocalPeer.consume() method.

producer_id = "producer_id"  # Replace with the actual producer ID
consumer = await local_peer.consume(producer_id)
Auto-Consuming Media

To automatically consume media from all producers, set the autoConsume option to True.

options = HuddleClientOptions(autoConsume=True)
client = HuddleClient(project_id="project_id", options=options)

room = await client.create(room_id="room_id", token=jwt_token)

5. Close the Connection

Always close the connection when done.

await client.close()

Modules

1. access_token

Manages access tokens, including permissions and roles.

2. huddle_client

Main entry point for connecting to the Huddle01 infrastructure. Manages rooms, peers, and communication.

3. room

Defines the structure and management of rooms.

4. remote_peer

Handles remote peers connected to a room.

5. socket

Manages WebSocket connections with advanced features like reconnection.

Room

Its defined as the grouping of Peers sharing Media Streams with one another,

Methoods

  • connect: Method allows to connect to a Room, which emits an Event RoomEvents.RoomJoined

Properties

  • state: Provides the current connection state of the Room
  • local_peer: Provides the Local Peer of the Room
  • remote_peers: Provides the list of Remote Peers connected to the Room

LocalPeer

Its defined as the Peer connected to the Room, which can Produce and Consume Media Streams.

Methods

  • produce: Method allows to produce a Media Stream, which emits an Event PeerEvents.ProducerAdded

  • consume: Method allows to consume a Media Stream, which emits an Event PeerEvents.ConsumerAdded

Properties

  • peer_id: Provides the Peer ID of the Peer
  • role: Provides the Role of the Peer, which can be HOST or GUEST
  • producers: Provides the list of Producers of the Peer
  • consumers: Provides the list of Consumers of the Peer

RemotePeer

Its defined as the Peer connected to the Room, which can Produce and Consume Media Streams.

Methods

  • get_producer: Method allows to get a Producer by its producer_id, label or using both.
  • is_producing_label: Method allows to check if the Peer is producing a Media Stream with a specific label
  • labels: Method allows to get the list of Labels of the Peer producer_ids: Method allows to get the list of Producer IDs of the Peer

Properties

  • peer_id: Provides the Peer ID of the Peer
  • role: Provides the Role of the Peer, which can be HOST or GUEST
  • labels_to_producers: Provides the mapping of Labels to Producers of the Peer

Metadata

Release files for huddle01 1.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for huddle01 1.1.2
File Size Uploaded Provenance Actions
huddle01-1.1.2.tar.gz 50.4 kB Without provenance Details for huddle01-1.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for huddle01 1.1.2
File Interpreter ABI Platform Actions
huddle01-1.1.2-py3-none-any.whl Python 3 none any Details for huddle01-1.1.2-py3-none-any.whl

Total release size: 118.3 kB

Release files / huddle01-1.1.2.tar.gz

Download URL huddle01-1.1.2.tar.gz
Size 50.4 kB
Tags Source
SHA-256 checksum
How to use checksums
4ecbf6794a3b7882bad87fdcbe1de64e251054cd8343099416ad83d0bb671b9e
BLAKE2b-256 checksum
How to use checksums
4d949d9c26d74569eddf9a0397e91cadbc60bd2be3ce2061cd2ce49d5850c46d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.6 Darwin/24.4.0

Release files / huddle01-1.1.2-py3-none-any.whl

Download URL huddle01-1.1.2-py3-none-any.whl
Size 67.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
de21402024a90f76eb0e4e8c62794131d95e3feb29d11525b7ea40bc970b80ce
BLAKE2b-256 checksum
How to use checksums
72c18cbfd4f370ecb5f796bdafc5d590cfbf12b2179be5b59becebd42f3b8f96
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.6 Darwin/24.4.0

Security for huddle01 1.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.1.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page