Use the official Mux SDK for Python to call the Mux API from your server. The SDK handles authentication and wraps each API endpoint in native Python code.
The Mux SDK for Python wraps the Mux REST API in native Python code. Use this SDK when you write your server application in Python. You can create assets, manage live streams, and query Mux Data without manual HTTP requests.
Install this module using either pip or by installing from source.
# Via pip
pip install git+https://github.com/muxinc/mux-python.git
# Via source
git checkout https://github.com/muxinc/mux-python.git
cd mux-python
python setup.py install --userTo start, you'll need a Mux access token. Once you've got that, you're off to the races!
import os
import mux_python
from mux_python.rest import ApiException
# Authentication Setup
configuration = mux_python.Configuration()
configuration.username = os.environ['MUX_TOKEN_ID']
configuration.password = os.environ['MUX_TOKEN_SECRET']
# API Client Initialization
assets_api = mux_python.AssetsApi(mux_python.ApiClient(configuration))
# List Assets
print("Listing Assets: \n")
try:
list_assets_response = assets_api.list_assets()
for asset in list_assets_response.data:
print('Asset ID: ' + asset.id)
print('Status: ' + asset.status)
print('Duration: ' + str(asset.duration) + "\n")
except ApiException as e:
print("Exception when calling AssetsApi->list_assets: %s\n" % e)Check out the Mux Python SDK docs for more information.