api.video
SearchCtrl K

Features

Developers

Run api.video commands from the commandline!

September 8, 2021 - Erikka Innes in Python

We now offer a commandline you can use to run api.video commands. Using Click and our Python client, the commandline offers all the features of our API, plus a few extra things:

  • You can upload a video with a single command, the two step process is handled for you.
  • You can get a csv file of the analytics results for player, video or live stream session information.
  • You can bulk delete videos.
  • You can bulk upload videos with details.

The commandline is open to developer suggestions and improvements - if there's something you want to add, we can review your contribution to the GitHub repository, which is available here: api.video Commandline

Installation

As always, I'll recommend that you set up a virtual environment to try things out. After you do that (or if you decide to skip that step), you'll need to do these things:

  1. Install click: pip click install click
  2. Install api.video: pip install api.video
  3. Get the repository from GitHub.
  4. Add a folder at the same level as these files called 'videos' if you want a place to try uploading videos from.

Configure the commandline

To use the commandline, the first thing you need to do is add your API key. In the virtual environment / folder you installed everything, in a terminal, type:

python av_cli.py config

Follow the instructions to add your API key. You should now be able to use all the features of the commandline.

You can type: python av_cli.py --help to get an exhaustive list of available commandline commands. You can also add --help after any of the individual commands for more information, like this: python av_cli.py liststreams --help.

Usage is stated at the top to show you how to structure each command. In general, it'll follow this arrangement:

python av_cli.py COMMANDNAME [OPTIONS] [REQUIRED ARGUMENT]

If you're adding a string, make sure you always have quotes at the start and end of the string. If you're using a dictionary as a string, make sure the quotes at the start and end of the entire dictionary are not the same kind as what you use inside the dictionary.

If you're writing a parameter out, always convert the parameter to snake case. For example, if the api.video documentation says camel case 'sortBy' then when you specify it to the commandline you'll put 'sort_by.'

Bulk upload files

This section goes over using the bulk upload command. The bulk upload lets you upload a set of videos from a specified folder along with all the details you want for every video, except for tags and metadata, which you must add later.

The basic command is: python av_cli.py bulkdetailupload 'path_to_video_folder/' 'path_to_csv_folder'

For the path to the video folder, make sure it ends with a slash. This path is added to each file to create the link to upload from.

The CSV file should include every field you can add in a header row, like this:

filename,title,description,public,panoramic,mp4_support,player_id

And then following rows should contain information as necessary. You can leave something blank by framing it with a comma on either side:

small_vid.mp4,my great title,it's a video,false,true,true, ,

Note that in this example above, the , , represent an empty (lack) of a value for a player_id and the line closes with a comma before beginning the next row.

Conclusion

That should be everything! The commandline can help you quickly reference information, upload videos, get csv files for analytics data and bulk delete videos you don't need anymore.

We are open to submissions, so if you want to add more features please suggest them or submit your ideas for inclusion!

Erikka Innes

Developer Evangelist

Connect your users with videos

Create a free account today