mux-python


Namemux-python JSON
Version 3.15.0 PyPI version JSON
download
home_pagehttps://github.com/muxinc/mux-python
SummaryMux API
upload_time2024-04-05 13:44:28
maintainerNone
docs_urlNone
authorMux DevEx
requires_pythonNone
licenseMIT
keywords openapi openapi-generator mux api
VCS
bugtrack_url
requirements future six python_dateutil setuptools urllib3
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![Mux Python Banner](github-python-sdk.png)

<p align="center">
  <a href="https://pypi.org/project/mux-python/"><img src="https://img.shields.io/pypi/v/mux_python" title="PyPI" /></a>
  <a href="https://github.com/muxinc/mux-python/workflows/Integration%20Test"><img src="https://github.com/muxinc/mux-python/workflows/Integration%20Test/badge.svg" title="CI" /></a>
</p>
<p align="center">
  <a href="https://pypi.org/project/mux-python">PyPI</a> |
  <a href="https://docs.mux.com">Mux Docs</a> |
  <a href="https://docs.mux.com/api-reference">Mux API Reference </a>
</p>

# Mux Python

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

[Mux Video](https://mux.com/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](https://mux.com/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](https://github.com/certifi/python-certifi/issues/26). We suggest upgrading to a later LTS operating system if you encounter this issue.

## Installation

### Via pip

```sh
pip install git+https://github.com/muxinc/mux-python.git
```
(you may need to run `pip` with root permission)

### Via source
```sh
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](https://jsonapi.org/) 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.](https://docs.mux.com/docs#section-1-get-an-api-access-token)

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](examples/):
* [List Assets, Live Streams, Signing Keys, and Uploads.](examples/video/list-everything.py)
* [Create an Asset, wait for it to become availiable, and print its playback URL](examples/video/ingest.py)
* [Create a new Live Stream and retrieve its Stream key.](examples/video/create-live-stream.py)

There's also example usage of every API call (also used for testing):
* [Video](examples/video/)
  * [Assets](examples/video/exercise-assets.py)
  * [Live Streams](examples/video/exercise-live-streams.py)
  * [Signing Keys](examples/video/exercise-signing-keys.py)
  * [Uploads](examples/video/exercise-uploads.py)
* [Data](examples/data/)
  * [Errors](examples/data/exercise-errors.py)
  * [Exports](examples/data/exercise-exports.py)
  * [Filters](examples/data/exercise-filters.py)
  * [Metrics](examples/data/exercise-metrics.py)
  * [Video Views](examples/data/exercise-video-views.py)

```python
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.](#authentication)

### 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](mailto:support@mux.com).

## Documentation

[Be sure to check out the documentation in the `docs` directory.](docs/)

## Issues
If you run into problems, [please raise a GitHub issue,](https://github.com/muxinc/mux-python/issues) 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!](https://github.com/muxinc/mux-python/issues)

## License
[MIT License.](LICENSE) Copyright 2019 Mux, Inc.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/muxinc/mux-python",
    "name": "mux-python",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "OpenAPI, OpenAPI-Generator, Mux API",
    "author": "Mux DevEx",
    "author_email": "devex@mux.com",
    "download_url": "https://files.pythonhosted.org/packages/f6/56/5eb41d479d5c0be9a917e193ecd19256864cd6ebc1ff98f6e2ceadf9342a/mux_python-3.15.0.tar.gz",
    "platform": null,
    "description": "![Mux Python Banner](github-python-sdk.png)\n\n<p align=\"center\">\n  <a href=\"https://pypi.org/project/mux-python/\"><img src=\"https://img.shields.io/pypi/v/mux_python\" title=\"PyPI\" /></a>\n  <a href=\"https://github.com/muxinc/mux-python/workflows/Integration%20Test\"><img src=\"https://github.com/muxinc/mux-python/workflows/Integration%20Test/badge.svg\" title=\"CI\" /></a>\n</p>\n<p align=\"center\">\n  <a href=\"https://pypi.org/project/mux-python\">PyPI</a> |\n  <a href=\"https://docs.mux.com\">Mux Docs</a> |\n  <a href=\"https://docs.mux.com/api-reference\">Mux API Reference </a>\n</p>\n\n# Mux Python\n\nOfficial Mux API wrapper for python projects, supporting both Mux Data and Mux Video.\n\n[Mux Video](https://mux.com/video) is an API-first platform, powered by data and designed by video experts to make beautiful video possible for every development team.\n\n[Mux Data](https://mux.com/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.\n\nNot familiar with Mux? Check out https://mux.com/ for more information.\n\n## Requirements\n\nPython 2.7 or 3.4+\n\n### Compatibility with Ubuntu 14.04\n\nMux uses cross signed TLS root certificates, which may not be compatible with Ubuntu 14.04 LTS [as documented in this issue](https://github.com/certifi/python-certifi/issues/26). We suggest upgrading to a later LTS operating system if you encounter this issue.\n\n## Installation\n\n### Via pip\n\n```sh\npip install git+https://github.com/muxinc/mux-python.git\n```\n(you may need to run `pip` with root permission)\n\n### Via source\n```sh\ngit checkout https://github.com/muxinc/mux-python.git\ncd mux-python\npython setup.py install --user\n```\n\n## Getting Started\n\n### Overview\n\nMux 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:\n\n1) 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](https://jsonapi.org/) 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.\n\n2) 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.\n\n### Authentication\nTo 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.](https://docs.mux.com/docs#section-1-get-an-api-access-token)\n\nIts 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.\n\n### Example Usage\nBelow is a quick example of using mux-python to list the Video assets stored in your Mux account.\n\nBe sure to also checkout the [examples directory](examples/):\n* [List Assets, Live Streams, Signing Keys, and Uploads.](examples/video/list-everything.py)\n* [Create an Asset, wait for it to become availiable, and print its playback URL](examples/video/ingest.py)\n* [Create a new Live Stream and retrieve its Stream key.](examples/video/create-live-stream.py)\n\nThere's also example usage of every API call (also used for testing):\n* [Video](examples/video/)\n  * [Assets](examples/video/exercise-assets.py)\n  * [Live Streams](examples/video/exercise-live-streams.py)\n  * [Signing Keys](examples/video/exercise-signing-keys.py)\n  * [Uploads](examples/video/exercise-uploads.py)\n* [Data](examples/data/)\n  * [Errors](examples/data/exercise-errors.py)\n  * [Exports](examples/data/exercise-exports.py)\n  * [Filters](examples/data/exercise-filters.py)\n  * [Metrics](examples/data/exercise-metrics.py)\n  * [Video Views](examples/data/exercise-video-views.py)\n\n```python\nimport os\nimport mux_python\nfrom mux_python.rest import ApiException\n\n# Authentication Setup\nconfiguration = mux_python.Configuration()\nconfiguration.username = os.environ['MUX_TOKEN_ID']\nconfiguration.password = os.environ['MUX_TOKEN_SECRET']\n\n# API Client Initialization\nassets_api = mux_python.AssetsApi(mux_python.ApiClient(configuration))\n\n# List Assets\nprint(\"Listing Assets: \\n\")\ntry:\n    list_assets_response = assets_api.list_assets()\n    for asset in list_assets_response.data:\n        print('Asset ID: ' + asset.id)\n        print('Status: ' + asset.status)\n        print('Duration: ' + str(asset.duration) + \"\\n\")\nexcept ApiException as e:\n    print(\"Exception when calling AssetsApi->list_assets: %s\\n\" % e)\n```\n\n## Exceptions & Error Handling\n\nAll 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.\n\n### NotFoundException\n\n`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.\n\n### UnauthorizedException\n\n`UnauthorizedException` is thrown when Mux cannot authenticate your request. [You should check you have configured your credentials correctly.](#authentication)\n\n### ServiceException\n\n`ServiceException` is thrown when Mux returns a HTTP 5XX Status Code. If you encounter this reproducibly, please get in touch with [support@mux.com](mailto:support@mux.com).\n\n## Documentation\n\n[Be sure to check out the documentation in the `docs` directory.](docs/)\n\n## Issues\nIf you run into problems, [please raise a GitHub issue,](https://github.com/muxinc/mux-python/issues) filling in the issue template. We'll take a look as soon as possible.\n\n## Contributing\nPlease do not submit PRs against this package. It is generated from our OpenAPI definitions - [Please open an issue instead!](https://github.com/muxinc/mux-python/issues)\n\n## License\n[MIT License.](LICENSE) Copyright 2019 Mux, Inc.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Mux API",
    "version": "3.15.0",
    "project_urls": {
        "Homepage": "https://github.com/muxinc/mux-python"
    },
    "split_keywords": [
        "openapi",
        " openapi-generator",
        " mux api"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "756d0c3887e937ed3121b1223ca1c20955c39404170907fd5c73c761accaaa5e",
                "md5": "a866b4393b9bdf12dcd5a987dfa0107f",
                "sha256": "01c02beb958037162aa9e802b5ae05f2e425d4095645df69e09ce209c625470a"
            },
            "downloads": -1,
            "filename": "mux_python-3.15.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a866b4393b9bdf12dcd5a987dfa0107f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 395664,
            "upload_time": "2024-04-05T13:44:26",
            "upload_time_iso_8601": "2024-04-05T13:44:26.322170Z",
            "url": "https://files.pythonhosted.org/packages/75/6d/0c3887e937ed3121b1223ca1c20955c39404170907fd5c73c761accaaa5e/mux_python-3.15.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f6565eb41d479d5c0be9a917e193ecd19256864cd6ebc1ff98f6e2ceadf9342a",
                "md5": "5851f1b5c14bcf8d0e095b6683823b97",
                "sha256": "dc89f2596d2e7b3f73e7c3dcc88957081c3d42443a31e8bae1efb1bea369a484"
            },
            "downloads": -1,
            "filename": "mux_python-3.15.0.tar.gz",
            "has_sig": false,
            "md5_digest": "5851f1b5c14bcf8d0e095b6683823b97",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 176837,
            "upload_time": "2024-04-05T13:44:28",
            "upload_time_iso_8601": "2024-04-05T13:44:28.470161Z",
            "url": "https://files.pythonhosted.org/packages/f6/56/5eb41d479d5c0be9a917e193ecd19256864cd6ebc1ff98f6e2ceadf9342a/mux_python-3.15.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-05 13:44:28",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "muxinc",
    "github_project": "mux-python",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "future",
            "specs": []
        },
        {
            "name": "six",
            "specs": [
                [
                    ">=",
                    "1.10"
                ]
            ]
        },
        {
            "name": "python_dateutil",
            "specs": [
                [
                    ">=",
                    "2.5.3"
                ]
            ]
        },
        {
            "name": "setuptools",
            "specs": [
                [
                    ">=",
                    "21.0.0"
                ]
            ]
        },
        {
            "name": "urllib3",
            "specs": [
                [
                    ">=",
                    "1.25.3"
                ]
            ]
        }
    ],
    "tox": true,
    "lcname": "mux-python"
}
        
Elapsed time: 0.21976s