Tutorials · 4 min read

<a href="https://www.pexels.com/photo/office-working-app-computer-97077/">Photo by Negative Space from Pexels</a>

Helpful PHP scripts Pt. 3 - Export all your video details to a .csv file

With this PHP script you can export details about all the videos you have in api.video. If you just did a bulk upload, you may want this information to see what characteristics each video has. You can use this information about what to do next for your content.

Erikka Innes

January 29, 2021

In our 3rd installment of helpful PHP scripts for bulk video uploads, we'll take a look at how to export all your video data to a .csv file. This script is part of a collection of scripts that help with bulk video uploads. All are available in our Helpful PHP Scripts repository on GitHub. In each part of this series, we'll walk through how to set up one of them. The scripts you'll find include:

matrix like view of code

We'll be talking about Export All Your Video Data to .csv today! You'll be able to see:

  • videoId - the unique identifier for referencing the video in API calls
  • title - the title of the video
  • publishedAt - when a video was published, in ISO-8601 format
  • iframe code - the code for embedding your video as an iframe
  • thumbnail - the thumbnail image for the video if one was set
  • mp4Support - the URL for the mp4 of the video if one is available
  • metadata - all key value pairs you set to describe the video (if you didn't set any you won't have them)

You can check out the API reference documentation for listing videos, which is what we'll use to export our content to a .csv file. The API reference content is here: List all videos

You can use the videoId to associate the video with a custom player you created.

Now that you know what kind of data you'll receive, let's get started!


For this project you'll need:

  • PHP 5.4 or greater with the command-line interface (CLI) and JSON extension installed
  • The Composer dependency management tool (or another way to manage your dependency management). See the Composer website for installation options.
  • A GitHub account
  • An api.video account
  • Your API key for either production or sandbox


  1. Navigate to the Helpful PHP Scripts repository.
  2. Click Code and from the drop-down click Download ZIP. (You can also install from the CLI if you prefer.)
  3. Put the contents of your new .zip file in a folder you want to work from.
  4. Navigate to the folder containing the contents of your zip file in the terminal.
  5. In the terminal, type: composer require api-video/php-sdk

Try the Script

  1. In the terminal, type php create_csv.php
  2. You're asked what environment you want to use, prod or sandbox. For our walkthrough, choose prod. NOTE: You should choose the environment you have videos for. If you choose one of these environments and don't have videos stored there, you won't get any data to review.
  3. Provide your API key. You can get this by navigating to my.api.video and copying the appropriate key.
  4. Your .csv file will build and be output to project_details.csv.

You can also view the documentation for listing all videos in our API reference content here: List all videos Thanks for checking out our latest installment of Helpful PHP scripts! If you have any question or suggestions, please share them 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.