YouTube to MP3 API

The YouTube to MP3 API allows for quick and easy conversion of YouTube videos into high-quality MP3 audio files. Through direct integration, you can obtain the MP3 download link for the desired video with just one API call.
Check out our API at RapidAPI.

How it works:

  1. Send a POST request to the API with the videoId of the YouTube video.
  2. The API will return the MP3 download link ready for use.

Accepted Parameters:

  • videoId: The unique ID of the YouTube video (e.g., for https://www.youtube.com/watch?v=dQw4w9WgXcQ, the videoId would be dQw4w9WgXcQ).

Response Format:
The response includes the request status and the MP3 download link.

Perfect for developers who want to integrate video-to-MP3 conversion functionality into their applications or services.

The YouTube to MP3 API allows for quick and easy conversion of YouTube videos into high-quality MP3 audio files.

YouTube to MP3 API Documentation

Base URL:
https://tube-mp31.p.rapidapi.com/

Endpoints

Converts a YouTube video to MP3 format and provides a direct download

METHOD POST https://tube-mp31.p.rapidapi.com/json

Request

Headers

 {
         "Content-Type": "application/json",
         "X-RapidAPI-Key": "YOUR_API_KEY",
         "X-RapidAPI-Host": "tube-mp31.p.rapidapi.com"
         }

Body Parameters

Parameter Type Required Description
videoId string Yes The YouTube video ID to be converted.

Example Request Body

 {
         "videoId": "dQw4w9WgXcQ"
         }

Example PHP Code to Call the API


<?php

$curl = curl_init();

curl_setopt_array($curl, [
    CURLOPT_URL => "https://tube-mp31.p.rapidapi.com/api/json",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_POSTFIELDS => json_encode([
        'videoId' => 'dQw4w9WgXcQ'
    ]),
    CURLOPT_HTTPHEADER => [
        "Content-Type: application/json",
        "x-rapidapi-host: tube-mp31.p.rapidapi.com",
        "x-rapidapi-key: YOUR_API_KEY" 
    ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
    echo "cURL Error #:". $err;
} else {
    echo $response;
}

?>

Response

Success Response

Field Type Description
status string Status of the request (success).
response string Direct download URL for the converted MP3.
  • Example Success Response
 {
         "status": "success",
         "result": [
            {
               "videoId": "Video ID",
               "title": "Artist - Song Name",
               "author": "Author",
               "duration": 167,
               "dlurl": "https://example.com/downloads/audio.mp3",
               "token": "JTdCJTIyaWQlMjIlM0ElMjIxa0FudTdWaXI...."
            }
         ]
         }

Error Responses

Response Field Type Description
Error Response error string Error message if the request fails.
  • Example Error Response (Missing videoId)
 {
         "error": "\"videoId\" parameter is mandatory."
         }
  • Example Error Response (Method Not Allowed)
 {
         "error": "Method not permitted."
         }


Rate Limiting

  • Request Limit: 100 requests per minute.
  • Status Code: 429 Too Many Requests is returned when the limit is exceeded.

Error Handling

  • 400 Bad Request: Returned if the videoId parameter is missing or invalid.
  • 405 Method Not Allowed: Returned if a method other than POST is used.
  • 500 Internal Server Error: Indicates a server-side issue.

Features

  • Converts YouTube videos to MP3 format effortlessly.
  • Provides direct download links for easy integration.
  • Supports high-quality audio conversion.
YouTube to MP3 Old method (iframe)

If you are a Web Developer and looking for a Video Downloader API for your projects then you are at the right place. We offer super fast iFrame converter APIs to allow you download videos without using your server resources. APIs works with any programming language like PHP, Python, JavaScript, jQuery, Ajax, JSON, Node.JS, Swift, C#, Java, Android & iOS.

Our API supports video platforms like YouTube. Try our YouTube to MP3 API.


Single Button API

API does not work if used with " sandbox" iFrame attribute. Your domain or IP will be blocked.
ex: <iframe sandbox="allow-scripts allow-same-origin"...

GET
https://apiyt.cc/{FTYPE}/{VIDEO_ID}
Parameters
FTYPE

mp3 or mp4

VIDEO_ID

https://www.youtube.com/watch?v=pRpeEdMmmQ0

MP3 iFrame Code:

<iframe src="https://apiyt.cc/mp3/pRpeEdMmmQ0" style="width: 160px; height: 60px;" width="100%" height="100%" allowtransparency="true" scrolling="no" style="border:none"></iframe>

Generates this:

Multi Button API
GET
https://apiyt.cc/buttons/{FTYPE}/{VIDEO_ID}
Parameters
FTYPE

mp3 or mp4

VIDEO_ID

https://www.youtube.com/watch?v=pRpeEdMmmQ0

iFrame Code:

<iframe id="buttonApi" src="https://apiyt.cc/buttons/mp3/mYHPnqa7B3Y"  width="100%" height="100%" allowtransparency="true" scrolling="no" style="border:none"></iframe>

Javascript code for automatically (Responsive) resizing:

<!-- Put the Library in your <head> tag --> <script src="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.3.2/iframeResizer.min.js"></script>
<!-- Put the resizer code after the <iframe> tag --> <script>iFrameResize({ log: false }, '#buttonApi')</script>

Generates this:

Widget API
GET
https://apiyt.cc/{FTYPE}/{VIDEO_ID}
Parameters
FTYPE

widget

VIDEO_ID

https://www.youtube.com/watch?v=pRpeEdMmmQ0

iFrame Code:

<iframe id="buttonApi" src="https://apiyt.cc/widget/mYHPnqa7B3Y" width="100%" height="100%" allowtransparency="true" scrolling="no" style="border:none;overflow:hidden;height: 300px;width: 100%;"></iframe>

Javascript code for automatically (Responsive) resizing:

<!-- Put the Library in your <head> tag --> <script src="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.3.2/iframeResizer.min.js"></script>
<!-- Put the resizer code after the <iframe> tag --> <script>iFrameResize({ log: false }, '#widgetApi')</script>

Generates this:

Search API

API does not work if used with " sandbox" iFrame attribute. Your domain or IP will be blocked.
ex: <iframe sandbox="allow-scripts allow-same-origin"...

GET
https://apiyt.cc/{FTYPE}/{VIDEO_ID}
Parameters
FTYPE

search

VIDEO_ID

https://www.youtube.com/watch?v=pRpeEdMmmQ0

iFrame Code:

<iframe id="SearchApi" src="https://apiyt.cc/search/post+malone" width="100%" height="530" allowtransparency="true" style="border:none"></iframe>

Generates this: