Download video and music using PHP

Using our API to download YouTube video, SoundCloud music, Facebook media, etc with PHP. For FREE!

Code Example


This API is really easy to use to download media files! Check this example out. How to download a YouTube video with PHP:

// This code snippet uses an open-source library.
$response = Unirest\Request::get("",
    "X-Mashape-Key" => "YOUR-API-KEY",
    "Accept" => "text/plain"

This will return a JSON array with download links, thumbnails, etc!

As an example, imagine you want to download the trailer for Serenity, the okay movie based on the awesome series Firefly, from YouTube. First, locate the URL you want, in this case it’s “”.

Then you can just use that URL (with URL encoding), and your Mashape API key, as above. If you don’t have an API key yet, click here to get started.

So, your PHP code should look something like this:

// This code snippet uses an open-source library.
$response = Unirest\Request::get("",
    "X-Mashape-Key" => "",
    "Accept" => "text/plain"
You will get a JSON array back as a result:
   "message":"Successfully received info.",
   "title":"Serenity - Trailer", 
   "description":"A passenger with a deadly secret. Six rebels on the run. An assassin in pursuit. When the renegade crew of Serenity agrees to hide a fugitive on their ship, they find themselves in an action-packed battle between the relentless military might of a totalitarian regime who will destroy anything - or anyone - to get the girl back and the bloodthirsty creatures who roam the uncharted areas of space. But, the greatest danger of all may be on their ship. From the mind of Joss Whedon (Buffy the Vampire Slayer, Angel) comes a new edge-of-your-seat adventure loaded with explosive battles, gripping special effects and fantastic new worlds!",
      "Joss Whedon",
      "Nathan Fillion",
      "Alan Tudyk",
      "Gina Torres",
      "Morena Baccarin",
      "Adam Baldwin",
      "Jewel Staite",
      "format":"audio only (DASH audio)",
      "format_note":"Audio only, no video",
      "format":"1920x1080 (1080p)",

In the resulting JSON array, you have “status” and “message” to give you the results, the thumbnail for the video, and the most important part, the “streams” array!

The “streams” array contains all variants of the video, with or without audio, and in different quality!

Just pick the URL you want to download, and that’s it!

Developers are downloading 50,000+ videos daily with our API. For FREE!