{"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":"python","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,"search_vec":"'5.1.2':44 'activ':47 'analyt':37,60 'api':6,23,57 'api-first':22 'build':27 'cloud':58 'current':41 'data':14,32,59 'experi':29 'first':24 'frequent':50 'librari':39 'maintain':48 'media':61 'minor':53 'mux':1,5,13,16,18,31 'offici':4 'patch':51 'platform':25 'project':10 'provid':33 'python':2,9 'qualiti':34 'releas':54 'sdk':3 'servic':36 'stream':56 'support':11 'version':43 'video':17,19,28,55 'wrapper':7","created_at":"2026-04-14T01:29:23.519738+00:00","updated_at":"2026-04-16T16:43:44.435553+00:00","problems":[{"fix":"Ensure that `configuration.username` (Mux Token ID) and `configuration.password` (Mux Token Secret) are set correctly, typically via environment variables (`os.environ['MUX_TOKEN_ID']` and `os.environ['MUX_TOKEN_SECRET']`).","cause":"The Mux API token ID or secret key provided are incorrect or invalid for the requested operation. This often manifests as a `mux_python.rest.ApiException` with an HTTP status code of 401.","error":"mux_python.rest.ApiException: (401)\nReason: Unauthorized"},{"fix":"Install the library using pip: `pip install mux-python` or `pip3 install mux-python` if you have multiple Python versions.","cause":"The `mux-python` library is not installed in the current Python environment, or the environment where the script is being run does not have access to the installed library.","error":"ModuleNotFoundError: No module named 'mux_python'"},{"fix":"Consult the `mux-python` documentation for the specific API response object to identify the correct attribute names. Frequently, the desired data will be found within the `.data` attribute of the response object (e.g., `response_object.data.id` instead of `response_object.id`).","cause":"You are trying to access an attribute or method on a `mux-python` object (e.g., an API response) that does not exist or has a different name than expected. Often, the core data in Mux API responses is nested under a `.data` attribute.","error":"AttributeError: 'ResponseObject' object has no attribute 'expected_attribute'"},{"fix":"Verify that the key exists before attempting to access it. Use `dictionary.get('some_key', default_value)` to provide a default value if the key is missing, or check for key existence with `if 'some_key' in dictionary:` before direct access. Ensure all required environment variables, like `MUX_TOKEN_ID` and `MUX_TOKEN_SECRET`, are properly set.","cause":"Attempting to access a non-existent key in a dictionary-like object returned by `mux-python` (e.g., when processing API response data or retrieving environment variables for configuration).","error":"KeyError: 'some_key'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"5.1.2","cli_name":"","cli_version":null,"type":"library","homepage":"https://www.mux.com","github":"https://github.com/muxinc/mux-python","docs":null,"changelog":null,"pypi":"https://pypi.org/project/mux-python/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["http-networking","communication"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-30","next_check":"2026-07-28","install_tag":null}}