Skip to main content

No project description provided

Project description

Official Python SDK for Stream

build PyPI version PyPI - Python Version

Features

  • Video call creation and management
  • Chat session creation and management
  • Token generation for user authentication

Installation

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

pip install getstream

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")

Users and Authentication

from getstream.models import UserRequest

# sync two users using the update_users method, both users will get insert or updated
client.upsert_users(
    UserRequest(
        id="tommaso-id", name="tommaso", role="admin", custom={"country": "NL"}
    ),
    UserRequest(
        id="thierry-id", name="thierry", role="admin", custom={"country": "US"}
    ),
)

# Create a JWT token for the user to connect client-side (e.g. browser/mobile app)
token = client.create_token("tommaso-id")

Video API - Calls

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

import uuid
from getstream.models import (
    CallRequest,
    MemberRequest,
)

call = client.video.call("default", uuid.uuid4())
call.get_or_create(
    data=CallRequest(
        created_by_id="tommaso-id",
        members=[
            MemberRequest(user_id="thierry-id"),
            MemberRequest(user_id="tommaso-id"),
        ],
    ),
)

App configuration

# Video: update settings for a call type

# Chat: update settings for a channel type

Chat API - Channels

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

chat_instance = client.chat

# TODO: implement and call chat-related methods with chat_instance

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
pre-commit install

To activate the virtual environment, run the following command:

poetry shell

To run tests, create a .env using the .env.example and adjust it to have valid API credentials

poetry run pytest tests/ getstream/

Before pushing changes make sure to have git hooks installed correctly, so that you get linting done locally pre-commit install

You can also run the code formatting yourself if needed:

poetry run ruff format getstream/ tests/

Writing new tests

pytest is used to run tests and to inject fixtures, simple tests can be written as simple python functions making assert calls. Make sure to have a look at the available test fixtures under tests/fixtures.py

Generate code from spec

To regenerate the Python source from OpenAPI, just run the ./generate.sh script from this repo.

[!NOTE] Code generation currently relies on tooling that is not publicly available, only Stream devs can regenerate SDK source code from the OpenAPI spec.

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-1.1.0.tar.gz (53.5 kB view details)

Uploaded Source

Built Distribution

getstream-1.1.0-py3-none-any.whl (57.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: getstream-1.1.0.tar.gz
  • Upload date:
  • Size: 53.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for getstream-1.1.0.tar.gz
Algorithm Hash digest
SHA256 873dd2a54f0367c28f2bb50b22a78fb54560db11d042ec692b5befcd38aa69b2
MD5 22ffc3d8ac48aa59a1a23a8f579518a1
BLAKE2b-256 9b23b6c613b32bc2873682a1651540c90c30133b4887b8fb01ead6a30a291062

See more details on using hashes here.

File details

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

File metadata

  • Download URL: getstream-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 57.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for getstream-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 79d10290e7965e7dec5e60bd028648c5e8f5e7abeb908ce295e38a851293ca8d
MD5 f0f54830f40de06784da45561a79d288
BLAKE2b-256 7c4fb140e00ea8ac9f73b5dde8f0f31b15965f7ee71347c803baaf7dcf0e019b

See more details on using hashes here.

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