{"id":5334,"library":"mux-python","title":"Mux Python SDK","description":"Official Mux API wrapper for Python projects, supporting both Mux Data and Mux Video. Mux Video is an API-first platform for building video experiences, while Mux Data provides quality of service analytics. The library is currently at version 5.1.2 and is actively maintained with frequent patch and minor releases.","status":"active","version":"5.1.2","language":"en","source_language":"en","source_url":"https://github.com/muxinc/mux-python","tags":["video","streaming","api","cloud","data","analytics","media"],"install":[{"cmd":"pip install mux-python","lang":"bash","label":"Install with pip"}],"dependencies":[],"imports":[{"note":"Configuration object is directly within the top-level `mux_python` module.","symbol":"Configuration","correct":"import mux_python\nconfiguration = mux_python.Configuration()"},{"note":"ApiClient is instantiated from the top-level `mux_python` module.","symbol":"ApiClient","correct":"client = mux_python.ApiClient(configuration)"},{"note":"Common exceptions like `ApiException` are found in the `mux_python.rest` submodule.","symbol":"ApiException","correct":"from mux_python.rest import ApiException"},{"note":"API client classes like `AssetsApi` are available directly from the top-level `mux_python` module and require an `ApiClient` instance.","symbol":"AssetsApi","correct":"assets_api = mux_python.AssetsApi(client)"}],"quickstart":{"code":"import os\nimport mux_python\nfrom mux_python.rest import ApiException\n\n# Authentication Setup\nconfiguration = mux_python.Configuration()\nconfiguration.username = os.environ.get('MUX_TOKEN_ID', '')\nconfiguration.password = os.environ.get('MUX_TOKEN_SECRET', '')\n\nif not configuration.username or not configuration.password:\n    print(\"Error: MUX_TOKEN_ID and MUX_TOKEN_SECRET environment variables must be set.\")\n    exit(1)\n\n# API Client Initialization\napi_client = mux_python.ApiClient(configuration)\nassets_api = mux_python.AssetsApi(api_client)\n\ntry:\n    # List Assets\n    print(\"Listing Mux Assets:\")\n    list_assets_response = assets_api.list_assets()\n    if list_assets_response.data:\n        for asset in list_assets_response.data:\n            print(f\"  Asset ID: {asset.id}, Status: {asset.status}, Duration: {asset.duration}\")\n    else:\n        print(\"  No assets found.\")\nexcept ApiException as e:\n    print(f\"Exception when calling AssetsApi->list_assets: {e}\\n\")\nexcept Exception as e:\n    print(f\"An unexpected error occurred: {e}\")\n","lang":"python","description":"This quickstart demonstrates how to initialize the Mux Python client using API credentials from environment variables and then list all existing video assets in your Mux account. Mux API responses typically return the primary data object within a `.data` attribute."},"warnings":[{"fix":"Update `CreateAssetRequest` to use `inputs` and `playback_policies` (which accept lists) instead of the singular `input` and `playback_policy` parameters.","message":"In version 5.0.0, `CreateAssetRequest` changed `input` to `inputs` and `playback_policy` to `playback_policies`. While deprecation notices were added for the old fields, direct usage should update to the new array-accepting fields.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Replace usage of `encoding_tier` with `video_quality` in API calls and model definitions.","message":"The `encoding_tier` parameter has been deprecated since version 3.18.0 and replaced by `video_quality` (e.g., 'standard' or 'premium').","severity":"deprecated","affected_versions":">=3.18.0"},{"fix":"Always access the `.data` attribute on API response objects to retrieve the expected resource (e.g., `list_assets_response.data`).","message":"Mux Python SDK, being code-generated, wraps API responses in an object where the main data payload is often accessed via a `.data` attribute (e.g., `response.data`). Forgetting `.data` will result in accessing the wrapper object instead of the actual API resource.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For handling webhooks, it's recommended to parse the incoming JSON payload manually or use a dedicated webhook parsing library, and then extract relevant information rather than relying on SDK models.","message":"The Mux Python SDK is not designed for parsing or modeling webhook payloads directly. Attempting to use SDK models for webhook events may lead to unexpected behavior or errors.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}