Skip to main content

No project description provided

Project description

Stream Video Client Library

The Stream Client Library provides a simple way to interact with the Stream API for managing video and chat services. This Python library makes it easy to create, manage, and authenticate video calls and chat sessions programmatically.

Features

  • Video call creation and management
  • Chat session creation and management
  • Token generation for user authentication with support for roles and call IDs

Installation

To install the Stream Client Library, run the following command:

pip install getstream

Replace stream with the actual package name you'll use when publishing your library.

Usage

To get started, you need to import the Stream class from the library and create a new instance with your API key and secret:

from getstream import Stream

client = Stream(api_key="your_api_key", api_secret="your_api_secret")

Video Calls

To create a video call, use the client.video.call method:

import uuid

call = client.video.call(
    call_type = "livestream",
    call_id = uuid.uuid4())
)

response = call.create(
        data=CallRequest(
            created_by_id="admin-user",
            settings_override=CallSettingsRequest(
                broadcasting=BroadcastSettingsRequest(
                    enabled=True,
                    hls=HlssettingsRequest(
                        enabled=True,
                        quality_tracks=["480p", "720p", "1080p"],
                    ),
                ),
            ),
        ),
    )
print(response)

Chat Sessions

To work with chat sessions, use the client.chat object and implement the desired chat methods in the Chat class:

chat_instance = client.chat

# Implement and call chat-related methods with chat_instance

User Authentication

To generate a JWT token for user authentication with role and call ID support, use the client.create_token method:

token = client.create_token("admin-user", call_cids=[call.cid], role="admin")

Cli for signing tokens

You can sign tokens by running the cli

poetry run create-token --api-key API_KEY --api-secret API_SECRET --user-id USER_ID [--expiration EXPIRATION]

Or you can use docker First, build the image:

docker build -t stream-py .

Then run the container

docker run -it --rm stream-py --api-key API_KEY --api-secret API_SECRET

Or use the published one

docker run -it --rm ghcr.io/getstream/stream-py:main --api-key API_KEY --api-secret API_SECRET --user-id

Development

We use poetry to manage dependencies and run tests. It's a package manager for Python that allows you to declare the libraries your project depends on and manage them. To install the development dependencies, run the following command:

poetry install

To activate the virtual environment, run the following command:

poetry shell

To run tests, run the following command:

# export secrets
export VIDEO_API_KEY=your_api_key
export VIDEO_API_SECRET=your_api_secret
poetry run pytest tests/

Before pushing changes make sure to run the linter:

poetry run black getstream/ tests/

Code Generation

In order to generate the code, clone the protocol repo

git clone github.com/GetStream/protocol
cd protocol
# checkout to the generator branch
git checkout PBE-832-openapi-generation-tool
# merge master into the generator branch to get the latest spec changes
git merge master

Then run the following command to generate the code

cd openapi-gen
go run . -i ../openapi/video-openapi.yaml -o ~/py-dev/stream/getstream  -c config.yaml # replicate with path to where you cloned the current repo

License

This project is licensed under the MIT License.

Contributing

Contributions are welcome! Please read the contributing guidelines to get started.

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

getstream-0.2.0.tar.gz (80.2 kB view details)

Uploaded Source

Built Distribution

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

getstream-0.2.0-py3-none-any.whl (313.8 kB view details)

Uploaded Python 3

File details

Details for the file getstream-0.2.0.tar.gz.

File metadata

  • Download URL: getstream-0.2.0.tar.gz
  • Upload date:
  • Size: 80.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.0 CPython/3.12.0 Darwin/23.0.0

File hashes

Hashes for getstream-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d56353852dde85bd165210751b577c386a0e30ffecdaf12488213c2ee899fb73
MD5 b5d29f9c0fe05a02322874debfeccaf0
BLAKE2b-256 4cefe35d9bc11b371269233b913d950d7796a7150fb26dbce527b88e55a2058d

See more details on using hashes here.

File details

Details for the file getstream-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: getstream-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 313.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.0 CPython/3.12.0 Darwin/23.0.0

File hashes

Hashes for getstream-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9e6e3a76d07186ea6c4aaf78a15068d5a4ded97e0c095d247f971ebb5c63dd0c
MD5 43b854e2d143f4c071ada30df7bc5bab
BLAKE2b-256 8f2c9584ad5b740d8046e4589c62fb48f608f874acf8f565fe14e7bd61cd00e1

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