A Python client library for accessing JW Platform API
Project description
A Python client library for accessing JW Platform API. Visit JW Player Developer site for more information about JW Platform API.
Installation
JW Platform API library can be installed using pip:
pip install jwplatform
Library has Requests package as dependency. It will be installed automatically when installing using pip.
Usage
Import jwplatform library:
import jwplatform
Initialize jwplatform client instance. API keys can be created in the JW Platform dashboard on the API Credentials page. Copy the secret value to use here.
jwplatform_client = jwplatform.client.Client('API_SECRET')
Make an API request:
response = jwplatform_client.Media.get(site_id='SITE_ID', media_id='MEDIA_ID')
If API request is successful, response variable will contain dictionary with information related to the response and the actual video data in response.json_body:
>>> response.json_body
{"id": "Ny05CEfj",
"type": "media",
"created": "2019-09-25T15:29:11.042095+00:00",
"last_modified": "2019-09-25T15:29:11.042095+00:00",
"metadata": {
"title": "Example video",
"tags": ["new", "video"]
}}
JW Platform API library will raise exception inherited from jwplatform.errors.APIError if anything goes wrong. For example, if there is no media with the specified media_id requesting it will raise jwplatform.errors.NotFoundError:
try:
jwplatform_client.Media.get(site_id='SITE_ID', media_id='BAD_MEDIA_ID')
except jwplatform.errors.NotFoundError as err:
print(err)
For the complete list of available exception see jwplatform/errors.py file.
Source Code
Source code for the JW Platform API library provided on GitHub.
License
JW Platform API library is distributed under the MIT license.
Changelog
2.0.0 (2020-12-03)
Added support for JWPlatform API v2
All existing v1 API functionality has been moved to the jwplatform.v1 submodule (from jwplatform).
1.3.0 (2019-12-22)
remove Python 2 compatability
1.2.2 (2018-04-10)
parameters are now included in the request body by default for POST requests
1.2.1 (2017-11-20)
improved default parameters handling when instantiating client
added exponential connection backoff
1.2.0 (2016-11-22)
allow additional Request package params in API requests
1.1.0 (2016-11-03)
added JWPlatformRateLimitExceededError exception
1.0.0 (2016-07-21)
Initial release.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for jwplatform-2.0.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 900a2654560aeb48c21c21586a67313e6b2bb022d5a1c8451f8957afb39d7455 |
|
MD5 | fbe7a9d3dd65903300910b0bc6083945 |
|
BLAKE2b-256 | 8573c52a5762ae4a0924b8a5b09596e2510989b0f2039813e7d811d20a5dee84 |