Retrieve soundtrack from YouTube url

December 13, 2024

Table of contents

  1. Request Headers
  2. Query Parameters
  3. Responses
  4. Model
  5. Examples
  6. Try It

This endpoint will return a link to the YouTube video soundtrack. You can download it, adjust if needed, and upload it to your track collection using POST /files.

https://api.useapi.net/v1/mureka/files/youtube/?…

Request Headers
Authorization: Bearer {API token}
Content-Type: application/json
Query Parameters
  • account is optional when only one account configured. However, if you have multiple accounts configured, this parameter becomes required.

  • url is required. Provide the YouTube url link for which you want to retrieve the soundtrack.

Responses
  • 200 OK

    {
        "name": "<YouTube video name>",
        "cos_url": "https://...mp3",
        "duration": 21000
    }
    
  • 400 Bad Request

    {
        "error": "<Error message>",
        "code": 400
    }
    
  • 401 Unauthorized

    {
      "error": "Unauthorized",
      "code": 401
    }
    
Model
{ // TypeScript, all fields are optional
  name: string
  cos_url: string
  duration: number
}
Examples
  • curl "https://api.useapi.net/v1/mureka/files/youtube/?account=account&url=<url>" \
       -H "Accept: application/json" \
       -H "Authorization: Bearer …" 
    
  • const token = "API token";
    const account = "Previously configured account"; 
    const url = "YouTube video url"; 
    const apiUrl = `https://api.useapi.net/v1/mureka/files/youtube/?account=${account}&url=${url}`; 
    const response = await fetch(apiUrl, {
      headers: {
        "Authorization": `Bearer ${token}`,
      },
    });
    const result = await response.json();
    console.log("response", {response, result});
    
  • import requests
    token = "API token"
    account = "Previously configured account"
    url = "YouTube video url"
    apiUrl = f"https://api.useapi.net/v1/mureka/files/youtube/?account={account}&url={url}"
    headers = {
        "Content-Type": "application/json", 
        "Authorization" : f"Bearer {token}"
    }
    response = requests.get(apiUrl, headers=headers)
    print(response, response.json())
    
Try It