Tutorials · 4 min read

Upload a video with the api.video Python Client

Upload a video from your computer to api.video using our Python Client! This works for small or large video files over 199 MiB, the client handles chunked uploads for you.

Erikka Innes

June 11, 2021

Uploading video with api.video's Python Client is easy. You can use the method described here to upload big files over 199 MiB or small files. The client will handle chunking the upload for you.

NOTE: If you're wondering how this differs from the previous Python tutorials:

It differs in that it uses our new Python Client.

If you'd prefer to watch a video about how to upload video from your computer with the new client, you can check that out here:

The API reference documentation for the endpoints used in this tutorial can be reviewed here:

If you prefer written walkthroughs, read on. I'll cover all the same information here.

Install the Python Client

Installing api.video's Python Client is easy:

pip install api.video

I recommend using a virtual environment to install, but it's not required.

How to Upload a Video from Your Computer

What you'll be doing, is sending a request to the api.video server to create a video container. You'll get back a video ID you can use to reference your container. Then you'll prepare your video for upload and send a request to upload the video to the video ID you specify.

Be aware that you can only upload to a video ID once. You can change settings and details about your video later using the update feature of the api.video API.

You can get the code sample I'm using here: https://github.com/apivideo/python-api-client/blob/master/examples/upload_video.py

When you are creating your video, you may want to include more settings and metadata than I show in the walkthrough. A complete list of choices are shown here: https://github.com/apivideo/python-api-client/blob/master/docs/VideoCreationPayload.md

And here's the code sample (tweaked a bit from the repository sample):


Code Sample Walkthrough

To use the api.video Python Client, you'll want to start by making your imports. You need three. The first one you'll need to import is apivideo. This will let you use authentication and the client. Next, you want to import VideosApi from apivideo.apis. It is best practice to import just the part of the client you'll use, because it improves performance. VideosApi will let us use the create and upload features. Finally, you'll import ApiAuthException for error handling.


Next, we'll add our API key and set up the Client. In the Python Client, authentication is handled for us, including refreshing the access token when needed. All we need to do is add our API key to the Client, then connect. After connecting, we can pass the Client to VideosApi, and we're ready to upload our video!


To upload our video, we first want to create our video container. The video container contains details about the video as well as any configuration settings like whether you want your video to be public or downloadable. As part of our request to create our container, we'll want to send all those details and settings in a payload. For this walkthrough, I'm adding a title because that's the only required setting for container creation. Then I'm including a description of what my video is, setting my video to be private (make public = false) and then I'm adding tags to search with - bunny and tree.


If you want to change the settings further, refer to the choices here: https://github.com/apivideo/python-api-client/blob/master/docs/VideoCreationPayload.md

Let's create a request to make our video container and retrieve the video ID:


We grabbed the video ID, so next we prepare our file. To upload files with api.video, we open them in read-only binary format. Then we'll add our file and video ID to our upload request and check out the response!


If everything works out, you'll get a response showing you all the metadata and configuration details for your upload. You can navigate to your api.video dashboard to see the video you uploaded there. If you're uploading a big video, give it a few minutes to be ready.

If you get stuck or have questions, you can write us on our community forum.

Try out more than 80 features for free

Access all the features for as long as you need.
No commitment or credit card required

Video API, simplified

Fully customizable API to manage everything video. From encoding to delivery, in minutes.

Built for Speed

The fastest video encoding platform. Serve your users globally with 140+ points of presence. 

Let end-users upload videos

Finally, an API that allows your end-users to upload videos and start live streams in a few clicks.


Volume discounts and usage-based pricing to ensure you don’t exceed your budget.