api.video Python API 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.

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

AnalyticsApi

MethodHTTP requestDescription
get_live_streams_playsGET /analytics/live-streams/playsGet play events for live stream
get_videos_playsGET /analytics/videos/playsGet play events for video

CaptionsApi

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

ChaptersApi

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

LiveStreamsApi

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

PlayerThemesApi

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

UploadTokensApi

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

VideosApi

MethodHTTP requestDescription
createPOST /videosCreate a video object
uploadPOST /videos/{videoId}/sourceUpload a video
upload_with_upload_tokenPOST /uploadUpload with an delegated upload token
getGET /videos/{videoId}Retrieve a video object
updatePATCH /videos/{videoId}Update a video object
deleteDELETE /videos/{videoId}Delete a video object
listGET /videosList all video objects
upload_thumbnailPOST /videos/{videoId}/thumbnailUpload a thumbnail
pick_thumbnailPATCH /videos/{videoId}/thumbnailSet a thumbnail
get_statusGET /videos/{videoId}/statusRetrieve video status and details

WatermarksApi

MethodHTTP requestDescription
uploadPOST /watermarksUpload a watermark
deleteDELETE /watermarks/{watermarkId}Delete a watermark
listGET /watermarksList all watermarks

WebhooksApi

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

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.

Was this page helpful?