Sign up for free

Regular video upload

api.video provides different ways to upload your videos. There are two ways to upload with tokens, and then there are two ways to upload depending on whether your video is over 200MiB or under. This guide walks through how to do regular video upload for a video under 200MiB in size.

Check out the guide on Progressive upload to understand how to upload videos larger than 200MiB in size.

Megabyte (MB) and Mebibyte (MiB) are both used to measure units of information on computer storage. 1 MB is 1000Kb (kilobytes), and 1 MiB is 1048.576Kb. api.video uses MiB.

API documentation

Video upload overview

This section gives you an overview of your upload options. This guide walks through regular uploads but describes all the available choices here.

If you want to learn about delegated uploads, which are useful for creating private videos, or allowing your viewers to upload content themselves, or even just making it easier for you to do uploads, check out the Delegated upload tokens guide.

The two token-based upload methods are:

  • Regular upload - you use an access token you retrieved when you authenticate to do a two-step process where you create a video object with metadata, retrieve the video ID, and use that to upload your video into the object.
  • Delegated upload - you create a token and use the token to upload your video in one step. You can change the metadata later on.

There are two types of upload depending on whether your video is over 200MiB or under. You can use either a regular or delegated upload for a video under 200MiB. If your video is over 200MiB, you can do a progressive upload, where you break a video into chunks and then upload the pieces using parts in the header. You can also use bytes in the header, which is a bit more complicated. If you use one of the clients, big uploads are handled for you using the bytes method. You can also use the progressive upload method if you wish, though the steps require a bit more effort.

Create an account

Before you can start uploading your first video, you need to create an api.video account.

Once you are logged in to the Dashboard, select the environment of your choice (sandbox or production) and copy your API key.

Choose an API client

The clients offered by api.video include:

Install

To install your selected client, do the following:

Installing the api.video client
go get github.com/apivideo/api.video-go-client

Upload a video file

Uploading a video via the API or from your computer

Create the video object

The first step to uploading a video is to create a video object. Once you create the object, you can use it to upload a video. Check out this simple code that creates a video object. Make sure that you replace your_api_key with your own API key from the dashboard.

Creating a video object
curl --user *your_api_key*: \
--request POST \
--url https://ws.api.video/videos \
--header 'Content-Type: application/json' \
--data '
{
  "title": "My First Video"
}
'

The API deletes empty video containers after 7 days.

The response to your API request will return the following, along with other params:

{
  "videoId": "your_video_id_here",
  "assets": {
	  ...
		"player": "https://embed.api.video/vod/{videoId}",
	  ...  
	}
}

Remember the videoId: you will need it to upload your video, in the next step. Also, save the value of assets.player for video playback.

If you are using one of our API clients, you will find the above information in the returned response's Video object.

Upload your file into the video object

In the first step, you created the video object. Next, you need to upload the video file into the video object using this API request:

Uploading a video file
curl --user *your_api_key*:
--url https://ws.api.video/videos/{videoId}/source
--form file=@/path/to/video.mp4

API response

{
  "videoId": "your_video_id",
  "assets": {
	  ...
		"player": "https://embed.api.video/vod/{videoId}",
	  ...  
	}
}

Watch and share your video

The easiest way to play your video is to use the api.video player URL that you received in the API response:

"player": "https://embed.api.video/vod/{videoId}"

To watch your video, just paste the link into your favorite browser. Use the same link to share your video.

Conclusion

If you're just getting started, this two-part upload process is ideal for you. If you choose to use one of our clients, handling large files is done for you by the client. If you want to try a progressive upload, these are best when you're working with huge files and you want to send the parts of them concurrently.

Resources

Check out api.video's blog content and tutorials about video uploads, private videos, and delegated uploads!

Was this page helpful?