All Social Media Video Downloader - Apify
  • Introduce
  • How it works
  • Get Download Link
  • Get YouTube Download Link
  • Merge Audio & Video for Instagram/Facebook
  • Proxy
Powered by GitBook
On this page
  • Overview
  • API Request
  • cURL
  • JSON Results
  • Other language examples

Get YouTube Download Link

Merge video and audio from YouTube

PreviousGet Download LinkNextMerge Audio & Video for Instagram/Facebook

Last updated 3 months ago

Overview

The difference between Get Direct Link and Download and Merge is that the video will be downloaded, audio and video will be merged and then the share link will be created

Proxy is required to get the list of download links.

By default the video will have no sound. This method is only for those who want to download videos from YouTube with audio available.

Because the video is downloaded, it will consume more proxy usage capacity

API Request

Endpoint:

Method: POST

Headers:

{
  "Content-Type": "application/json"
}

Request Body:

{
  "url": "https://www.youtube.com/watch?v=HCjNJDNzw8Y",
  "proxySettings": {
    "useApifyProxy": true,
    "apifyProxyGroups": ["RESIDENTIAL"],
    "apifyProxyCountry": "CA"
  },
  "mergeYoutube": {
    "quality": 720
  }
}

Download & Merge audio and video from YouTube

You need to add the following field in the body:

"mergeYoutube":
{
   "quality": 720
}

quality (144, 240, 360, 480, 720, 1080, 1440, 2160) is the quality of the video you want to download

The tool only downloads videos with quality equal to or lower than the specified quality

(if the entered quality is not available)

If you are integrating Actor as download API, you can always set mergeYoutube value, when url is Youtube it will work, when url is not Youtube it will not be affected

This will help API to get all url and when url is Youtube it will be merged automatically

cURL

curl -X POST "https://api.apify.com/v2/acts/wilcode~all-social-media-video-downloader/runs?token=<YOUR_API_TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://www.youtube.com/watch?v=HCjNJDNzw8Y",
    "proxySettings": {
      "useApifyProxy": true,
      "apifyProxyGroups": ["RESIDENTIAL"],
      "apifyProxyCountry": "CA"
    },
    "mergeYoutube": {
      "quality": 720
    }
  }'

JSON Results

{
    "title": "Video title",
    "uploader": "Channel Name",
    "channel": "Channel Name",
    "upload_date": "20240706",
    "duration": 100,
    "description": "",
    "like_count": 478,
    "comment_count": 19,
    "thumbnail": "image thumbnail url",
    "formats": [
      {
        "resolution": "720x1080",
        "url": "url download"
      },
      {
        "resolution": "1080x1920",
        "url": "url download"
      },
      {
        "resolution": "audio only",
        "url": "url download"
      },
    ],
    "download": [
      {
        "resolution": 720,
        "url": "https://api.apify.com/v2/key-value-stores/amhvXQKACHs124/records/downloaded_video_1732199392399.mp4"
      }
    ]
}

The list of download links and resolutions will be listed in the formats attribute.

When the body has the mergeYoutube field, the result will have an additional download field

In the download field there will be the url and resolution of the quality you entered.

The download url is the file saved in your Storage (Apify), this link will be automatically generated

This link will automatically expire and the file will be deleted from your Storage in 7 days.

Why does the video sometimes crash while downloading?

  • Due to unstable proxy, the video download fails while downloading

  • You need to change proxy or change proxy country (if using Apify Proxy)

Other language examples

Fetch in JavaScript

const fetch = require('node-fetch');

const endpoint = 'https://api.apify.com/v2/acts/wilcode~all-social-media-video-downloader/runs?token=<YOUR_API_TOKEN>';

const requestBody = {
  url: 'https://www.youtube.com/watch?v=HCjNJDNzw8Y',
  proxySettings: {
    useApifyProxy: true,
    apifyProxyGroups: ['RESIDENTIAL'],
    apifyProxyCountry: 'CA'
  },
  mergeYoutube: {
    quality: 720
  }
};

fetch(endpoint, {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify(requestBody)
})
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));

Python

import requests

endpoint = 'https://api.apify.com/v2/acts/wilcode~all-social-media-video-downloader/runs?token=<YOUR_API_TOKEN>'

headers = {
    'Content-Type': 'application/json'
}

body = {
    'url': 'https://www.youtube.com/watch?v=HCjNJDNzw8Y',
    'proxySettings': {
        'useApifyProxy': True,
        'apifyProxyGroups': ['RESIDENTIAL'],
        'apifyProxyCountry': 'CA'
    },
    'mergeYoutube': {
        'quality': 720
    }
}

response = requests.post(endpoint, headers=headers, json=body)
print(response.json())

C#

using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static async Task Main(string[] args)
    {
        string endpoint = "https://api.apify.com/v2/acts/wilcode~all-social-media-video-downloader/runs?token=<YOUR_API_TOKEN>";

        // Define request body
        var requestBody = new
        {
            url = "https://www.youtube.com/watch?v=HCjNJDNzw8Y",
            proxySettings = new
            {
                useApifyProxy = true,
                apifyProxyGroups = new[] { "RESIDENTIAL" },
                apifyProxyCountry = "CA"
            },
            mergeYoutube = new
            {
                quality = 720
            }
        };

        // Convert request body to JSON
        string jsonBody = System.Text.Json.JsonSerializer.Serialize(requestBody);

        using (HttpClient client = new HttpClient())
        {
            // Set headers
            client.DefaultRequestHeaders.Add("Content-Type", "application/json");

            // Send POST request
            HttpResponseMessage response = await client.PostAsync(
                endpoint,
                new StringContent(jsonBody, Encoding.UTF8, "application/json")
            );

            // Get response content
            string responseContent = await response.Content.ReadAsStringAsync();

            // Print response
            Console.WriteLine("Response:");
            Console.WriteLine(responseContent);
        }
    }
}
https://api.apify.com/v2/acts/wilcode~all-social-media-video-downloader/runs?token=<YOUR_API_TOKEN>