Skip to main content

Mux Python Banner

PyPI | Mux Docs | Mux API Reference

Mux Python

Official Mux API wrapper for python projects, supporting both Mux Data and Mux Video.

Mux Video is an API-first platform, powered by data and designed by video experts to make beautiful video possible for every development team.

Mux Data is a platform for monitoring your video streaming performance with just a few lines of code. Get in-depth quality of service analytics on web, mobile, and OTT devices.

Not familiar with Mux? Check out https://mux.com/ for more information.

Requirements

Python 2.7 or 3.4+

Compatibility with Ubuntu 14.04

Mux uses cross signed TLS root certificates, which may not be compatible with Ubuntu 14.04 LTS as documented in this issue. We suggest upgrading to a later LTS operating system if you encounter this issue.

Installation

Via pip

pip install git+https://github.com/muxinc/mux-python.git

(you may need to run pip with root permission)

Via source

git checkout https://github.com/muxinc/mux-python.git
cd mux-python
python setup.py install --user

Getting Started

Overview

Mux Python is a code generated lightweight wrapper around the Mux REST API and reflects them accurately. This has a few consequences you should watch out for:

  1. For almost all API responses, the object you're looking for will be in the data field on the API response object, as in the example below. This is because we designed our APIs with similar concepts to the JSON:API standard. This means we'll be able to return more metadata from our API calls (such as related entities) without the need to make breaking changes to our APIs. We've decided not to hide that in this library.

  2. We don't use a lot of object orientation. For example API calls that happen on a single asset don't exist in the asset class, but are API calls in the AssetsApi which require an asset ID.

Authentication

To use the Mux API, you'll need an access token and a secret. Details on obtaining these can be found here in the Mux documentation.

Its up to you to manage your token and secret. In our examples, we read them from MUX_TOKEN_ID and MUX_TOKEN_SECRET in your environment.

Example Usage

Below is a quick example of using mux-python to list the Video assets stored in your Mux account.

Be sure to also checkout the examples directory:

There's also example usage of every API call (also used for testing):

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)

Exceptions & Error Handling

All exceptions inherit from ApiException, you can catch it as in the example above, or you can catch one of the more specific exceptions below. You can check the fields error_type and error_messages in all Exceptions to see what error the Mux API reported.

NotFoundException

NotFoundException is thrown when a resource is not found. This is useful when trying to get an entity by its ID, for example get_asset("some-id-here") in the AssetsApi.

UnauthorizedException

UnauthorizedException is thrown when Mux cannot authenticate your request. You should check you have configured your credentials correctly.

ServiceException

ServiceException is thrown when Mux returns a HTTP 5XX Status Code. If you encounter this reproducibly, please get in touch with support@mux.com.

Documentation

Be sure to check out the documentation in the docs directory.

Issues

If you run into problems, please raise a GitHub issue, filling in the issue template. We'll take a look as soon as possible.

Contributing

Please do not submit PRs against this package. It is generated from our OpenAPI definitions - Please open an issue instead!

License

MIT License. Copyright 2019 Mux, Inc.

Metadata

Release files for mux-python 3.19.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mux-python 3.19.0
File Size Uploaded
mux_python-3.19.0.tar.gz 183.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mux-python 3.19.0
File Interpreter ABI Platform
mux_python-3.19.0-py3-none-any.whl Python 3 none any Details

Total release size: 597.0 kB

Release files / mux_python-3.19.0.tar.gz

Download URL mux_python-3.19.0.tar.gz
Size 183.9 kB
Tags Source
SHA-256 checksum
How to use checksums
e9bcd30502664525e3e24d3062ed52462da0b69bd747ea2a200a5038a76f1888
BLAKE2b-256 checksum
How to use checksums
e66bcb9c193546b368b2ee4dab9edab311fbfb11a5420858cd4964defab0b6a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.10

Release files / mux_python-3.19.0-py3-none-any.whl

Download URL mux_python-3.19.0-py3-none-any.whl
Size 413.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3d627131f8e700630ac86fec37037f0e0bdd2575e4ab123aca90482a7d34e0ea
BLAKE2b-256 checksum
How to use checksums
c42d9ced44f3091e37685e8f0e374c6d088cc8a003e0cdfe0b1b2d247093ba99
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.10

Release history Release notifications | RSS feed

5.1.2

2 release files

5.1.1

2 release files

5.1.0

2 release files

5.0.1

2 release files

5.0.0

2 release files

4.0.0

2 release files

3.20.0

2 release files

This release

3.19.0 This release

2 release files

3.18.0

2 release files

3.14.0

2 release files

3.13.0

2 release files

3.11.2

2 release files

3.11.0

1 release file

3.10.0

3 release files

3.9.0

3 release files

3.8.0

3 release files

3.7.1

3 release files

3.7.0

3 release files

3.6.0

3 release files

3.5.2

3 release files

3.5.1

3 release files

3.5.0

3 release files

3.4.0

3 release files

3.3.1

3 release files

3.3.0

3 release files

3.2.0

3 release files

3.0.0

3 release files

2.2.0

3 release files

2.1.1

3 release files

2.1.0

3 release files

2.0.0

3 release files

1.12.0

3 release files

1.11.0

2 release files

1.9.0

2 release files

1.8.0

2 release files

1.7.0

2 release files

1.6.0

3 release files

1.5.0

2 release files

1.3.0

2 release files

1.2.2

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page