How to use the API using Python

Read Time:13 Minute, 51 Second API enables you to connect your application to Livecoding and its different resources.

In this article, we will use the Django framework and Requests library. The same method can be interpolated to other frameworks and library with ease.


To prepare to use API, register an app on


The first thing we have to do before using API methods is to authorize.

Authorization in API works through standard oAuth protocol, so first we need to implement methods to get an access token with API credentials and later refresh them.

Assume that we have model object with credentials data:

All methods implemented in the Client class:

In auth() method, we make a post request to auth endpoint with an authorization code and then retrieve the access token and refresh token and save them for later use with API requests.

In order to authorise code from authorization server, we have to get request to authorization server:

After successful authorization redirects to our redirect URL, where we can handle authorization code, and continue the auth() procedure.

For convenient use lets create views for it:


Access token has expiration period, so we need periodically refresh it:

API calls

In order to call API methods we need to supply access token with special HTTP header:

“Authorization: Bearer mytoken”

Let implement method to form it:

And now all necessary is ready to retrieve data through API.

For example, we want to get scheduled broadcasts. So we have to make proxy method for API method “scheduledbroadcast”, and for convenient use, we will make the ability to pass any params to it.To avoid access token expiration, we will refresh it on every call.

And then use it like:

In that way, you can use any method supported by API

Have any questions? Don’t forget to comment below and let us know.


You might also like this video