Features

Developers

New code samples for the Python client

May 24, 2021 - Erikka Innes in Python

We recently released a new Python client. To make it easier to work with, I set up basic code samples for every endpoint showing you how your requests should be created. The basic samples are all in the Examples folder in the Python client repository.

Tips for working with the Python client

These are some tips for working with the Python client.

  • Don't mix n' match the Python client's documentation with the docs at docs.api.video. Parameters are sometimes mapped to more Pythonic parameters in the Python client. For example enablesApi becomes enables_api. This isn't the case everywhere, check the code sample and the documentation in the repository.
  • When you're using the API, typically you'll import the endpoint you want to work with. So you'll import the API with 'import apivideo' and then you'll also have an import statement like 'from apivideo.apis import VideosApi' if you want to use the video endpoint. If you also want to use exceptions, you'd add 'from apivideo.exceptions import ApiAuthException.'
  • Authentication is handled for you. It's arranged so you never need to worry about it. You may wonder then, why we provide a way to manually retrieve a refresh token. This is in case your token is exposed. Retrieving a new refresh token will cancel the old one.
  • When you create requests without the client, you'll notice that you open your file in binary, then attach it to a dictionary and send it. In the client, you just open your file in binary, assign that to a variable and send the open file. This is demonstrated in the examples, if the explanation is unclear. For an example, see the upload_video.py sample.
  • Everything for making requests is built using urllib3.

Documentation Examples

If you don't want to use the simplified examples in the code sample folder, you can also use the samples provided by the Python client documentation. Just look up the endpoint you want details about and there are samples provided there.

Erikka Innes

Developer Evangelist

Create your free account

Start building with video now