Python API client

The official Python client for api.video

badgebadge   badgebadge   badgebadge

api.video Python client

api.video is the video infrastructure for product builders. Lightning fast video APIs for integrating, scaling, and managing on-demand & low latency live streaming features in your app.

Table of contents

Project description

api.video's Python API client streamlines the coding process. Chunking files is handled for you, as is pagination and refreshing your tokens.

Getting started

Requirements

Python >= 3.6

Installation

pip install api.video

Code samples

Automatic authentication

list all videos:

import apivideo
from apivideo.apis import VideosApi

api_key = "__API_KEY__"

with apivideo.AuthenticatedApiClient(api_key) as client:
    # if you rather like to use the sandbox environment:
    # with apivideo.AuthenticatedApiClient(api_key, production=False) as client:

    videos_api = VideosApi(client)
    videos = videos_api.list()

In this context the client will keep its authentication updated.

Manual authentication

If there is an issue, like you think a refresh token may have been exposed, you can manually retrieve a new one. Otherwise, authentication is handled for you.
When you retrieve a new refresh token, the old one becomes invalid. Here is the code, where you retrieve a list of videos and then refresh your token:

import apivideo
from apivideo.apis import VideosApi
from apivideo.exceptions import ApiAuthException

api_key = "__API_KEY__"

client = apivideo.AuthenticatedApiClient(api_key)
# if you rather like to use the sandbox environment:
# client = apivideo.AuthenticatedApiClient(api_key, production=False)
client.connect()
videos_api = VideosApi(client)
videos = videos_api.list()

try:
    client.refresh_token()
except ApiAuthException:
    print("cannot refresh token !")

...

Documentation

API Endpoints

All URIs are relative to https://ws.api.video

CaptionsApi

MethodHTTP requestDescription
deleteDELETE /videos/{videoId}/captions/{language}Delete a caption
listGET /videos/{videoId}/captionsList video captions
getGET /videos/{videoId}/captions/{language}Show a caption
updatePATCH /videos/{videoId}/captions/{language}Update caption
uploadPOST /videos/{videoId}/captions/{language}Upload a caption

ChaptersApi

MethodHTTP requestDescription
deleteDELETE /videos/{videoId}/chapters/{language}Delete a chapter
listGET /videos/{videoId}/chaptersList video chapters
getGET /videos/{videoId}/chapters/{language}Show a chapter
uploadPOST /videos/{videoId}/chapters/{language}Upload a chapter

LiveStreamsApi

MethodHTTP requestDescription
deleteDELETE /live-streams/{liveStreamId}Delete a live stream
delete_thumbnailDELETE /live-streams/{liveStreamId}/thumbnailDelete a thumbnail
listGET /live-streamsList all live streams
getGET /live-streams/{liveStreamId}Show live stream
updatePATCH /live-streams/{liveStreamId}Update a live stream
createPOST /live-streamsCreate live stream
upload_thumbnailPOST /live-streams/{liveStreamId}/thumbnailUpload a thumbnail

PlayerThemesApi

MethodHTTP requestDescription
deleteDELETE /players/{playerId}Delete a player
delete_logoDELETE /players/{playerId}/logoDelete logo
listGET /playersList all player themes
getGET /players/{playerId}Show a player
updatePATCH /players/{playerId}Update a player
createPOST /playersCreate a player
upload_logoPOST /players/{playerId}/logoUpload a logo

RawStatisticsApi

MethodHTTP requestDescription
list_live_stream_sessionsGET /analytics/live-streams/{liveStreamId}List live stream player sessions
list_session_eventsGET /analytics/sessions/{sessionId}/eventsList player session events
list_video_sessionsGET /analytics/videos/{videoId}List video player sessions

UploadTokensApi

MethodHTTP requestDescription
delete_tokenDELETE /upload-tokens/{uploadToken}Delete an upload token
listGET /upload-tokensList all active upload tokens.
get_tokenGET /upload-tokens/{uploadToken}Show upload token
create_tokenPOST /upload-tokensGenerate an upload token

VideosApi

MethodHTTP requestDescription
deleteDELETE /videos/{videoId}Delete a video
getGET /videos/{videoId}Show a video
get_statusGET /videos/{videoId}/statusShow video status
listGET /videosList all videos
updatePATCH /videos/{videoId}Update a video
pick_thumbnailPATCH /videos/{videoId}/thumbnailPick a thumbnail
upload_with_upload_tokenPOST /uploadUpload with an upload token
createPOST /videosCreate a video
uploadPOST /videos/{videoId}/sourceUpload a video
upload_thumbnailPOST /videos/{videoId}/thumbnailUpload a thumbnail

WebhooksApi

MethodHTTP requestDescription
deleteDELETE /webhooks/{webhookId}Delete a Webhook
getGET /webhooks/{webhookId}Show Webhook details
listGET /webhooksList all webhooks
createPOST /webhooksCreate Webhook

Models

Have you gotten use from this API client?

Please take a moment to leave a star on the client ⭐

This helps other users to find the clients and also helps us understand which clients are most popular. Thank you!

Contribution

Since this API client is generated from an OpenAPI description, we cannot accept pull requests made directly to the repository. If you want to contribute, you can open a pull request on the repository of our client generator. Otherwise, you can also simply open an issue detailing your need on this repository.


Did this page help you?