Package: getstream
Stream Video Client LibraryThe 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.FeaturesVideo call creation and managementChat session creation and managementToken generation for user authentication with support for roles and call IDsInstallationTo install the Stream Client Library, run the following command:pipinstallgetstreamReplacestreamwith the actual package name you'll use when publishing your library.UsageTo get started, you need to import theStreamclass from the library and create a new instance with your API key and secret:fromgetstreamimportStreamclient=Stream(api_key="your_api_key",api_secret="your_api_secret")Video CallsTo create a video call, use theclient.video.callmethod:importuuidcall=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 SessionsTo work with chat sessions, use theclient.chatobject and implement the desired chat methods in theChatclass:chat_instance=client.chat# Implement and call chat-related methods with chat_instanceUser AuthenticationTo generate a JWT token for user authentication with role and call ID support, use theclient.create_tokenmethod:token=client.create_token("admin-user",call_cids=[call.cid],role="admin")Cli for signing tokensYou can sign tokens by running the clipoetryruncreate-token--api-keyAPI_KEY--api-secretAPI_SECRET--user-idUSER_ID[--expirationEXPIRATION]Or you can use docker
First, build the image:dockerbuild-tstream-py.Then run the containerdockerrun-it--rmstream-py--api-keyAPI_KEY--api-secretAPI_SECRETOr use the published onedockerrun-it--rmghcr.io/getstream/stream-py:main--api-keyAPI_KEY--api-secretAPI_SECRET--user-idDevelopmentWe 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:poetryinstallTo activate the virtual environment, run the following command:poetryshellTo run tests, run the following command:# export secretsexportVIDEO_API_KEY=your_api_keyexportVIDEO_API_SECRET=your_api_secret
poetryrunpytesttests/Before pushing changes make sure to run the linter:poetryrunblackgetstream/tests/Code GenerationIn order to generate the code, clone theprotocolrepogitclonegithub.com/GetStream/protocolcdprotocol# checkout to the generator branchgitcheckoutPBE-832-openapi-generation-tool# merge master into the generator branch to get the latest spec changesgitmergemasterThen run the following command to generate the codecdopenapi-gen
gorun.-i../openapi/video-openapi.yaml-o~/py-dev/stream/getstream-cconfig.yaml# replicate with path to where you cloned the current repoLicenseThis project is licensed under theMIT License.ContributingContributions are welcome! Please read thecontributing guidelinesto get started.