Node.js
import { Supadata } from '@supadata/js';
const supadata = new Supadata({
apiKey: 'YOUR_API_KEY',
});
const videos = await supadata.youtube.playlist.videos({
id: 'https://www.youtube.com/playlist?list=PLlaN88a7y2_plecYoJxvRFTLHVbIVAOoc', // can be id or url
limit: 20, // Optional: limit the number of videos to fetch
});
console.log(`Found ${videos.videoIds.length} videos`);from supadata import Supadata
supadata = Supadata(api_key="YOUR_API_KEY")
videos = supadata.youtube.playlist.videos(
id="https://www.youtube.com/playlist?list=PLlaN88a7y2_plecYoJxvRFTLHVbIVAOoc", # can be id or url
limit=20 # Optional: limit the number of videos to fetch
)
print(f"Found {len(videos.video_ids)} videos")
print(videos.video_ids)curl -X GET "https://api.supadata.ai/v1/youtube/playlist/videos?id=https://www.youtube.com/playlist?list=PLlaN88a7y2_plecYoJxvRFTLHVbIVAOoc&limit=20" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json"const options = {method: 'GET', headers: {'x-api-key': '<api-key>'}};
fetch('https://api.supadata.ai/v1/youtube/playlist/videos', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.supadata.ai/v1/youtube/playlist/videos",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.supadata.ai/v1/youtube/playlist/videos"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.supadata.ai/v1/youtube/playlist/videos")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.supadata.ai/v1/youtube/playlist/videos")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"videoIds": [
"dQw4w9WgXcQ",
"xvFZjo5PgG0"
],
"shortIds": [
"dQw4w9WgXcQ",
"xvFZjo5PgG0"
],
"liveIds": [
"dQw4w9WgXcQ",
"xvFZjo5PgG0"
]
}{
"error": "invalid-request",
"message": "Invalid Request",
"details": "The request is invalid or malformed",
"documentationUrl": "https://supadata.ai/documentation/errors#invalid-request"
}{
"error": "invalid-request",
"message": "Invalid Request",
"details": "The request is invalid or malformed",
"documentationUrl": "https://supadata.ai/documentation/errors#invalid-request"
}{
"error": "invalid-request",
"message": "Invalid Request",
"details": "The request is invalid or malformed",
"documentationUrl": "https://supadata.ai/documentation/errors#invalid-request"
}YouTube Endpoints
Playlist Videos
Get video IDs from a YouTube playlist.
GET
/
youtube
/
playlist
/
videos
Node.js
import { Supadata } from '@supadata/js';
const supadata = new Supadata({
apiKey: 'YOUR_API_KEY',
});
const videos = await supadata.youtube.playlist.videos({
id: 'https://www.youtube.com/playlist?list=PLlaN88a7y2_plecYoJxvRFTLHVbIVAOoc', // can be id or url
limit: 20, // Optional: limit the number of videos to fetch
});
console.log(`Found ${videos.videoIds.length} videos`);from supadata import Supadata
supadata = Supadata(api_key="YOUR_API_KEY")
videos = supadata.youtube.playlist.videos(
id="https://www.youtube.com/playlist?list=PLlaN88a7y2_plecYoJxvRFTLHVbIVAOoc", # can be id or url
limit=20 # Optional: limit the number of videos to fetch
)
print(f"Found {len(videos.video_ids)} videos")
print(videos.video_ids)curl -X GET "https://api.supadata.ai/v1/youtube/playlist/videos?id=https://www.youtube.com/playlist?list=PLlaN88a7y2_plecYoJxvRFTLHVbIVAOoc&limit=20" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json"const options = {method: 'GET', headers: {'x-api-key': '<api-key>'}};
fetch('https://api.supadata.ai/v1/youtube/playlist/videos', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.supadata.ai/v1/youtube/playlist/videos",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.supadata.ai/v1/youtube/playlist/videos"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.supadata.ai/v1/youtube/playlist/videos")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.supadata.ai/v1/youtube/playlist/videos")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"videoIds": [
"dQw4w9WgXcQ",
"xvFZjo5PgG0"
],
"shortIds": [
"dQw4w9WgXcQ",
"xvFZjo5PgG0"
],
"liveIds": [
"dQw4w9WgXcQ",
"xvFZjo5PgG0"
]
}{
"error": "invalid-request",
"message": "Invalid Request",
"details": "The request is invalid or malformed",
"documentationUrl": "https://supadata.ai/documentation/errors#invalid-request"
}{
"error": "invalid-request",
"message": "Invalid Request",
"details": "The request is invalid or malformed",
"documentationUrl": "https://supadata.ai/documentation/errors#invalid-request"
}{
"error": "invalid-request",
"message": "Invalid Request",
"details": "The request is invalid or malformed",
"documentationUrl": "https://supadata.ai/documentation/errors#invalid-request"
}Authorizations
Query Parameters
YouTube playlist URL or ID. See supported URL formats.
Examples:
"https://www.youtube.com/playlist?list=PLlaN88a7y2_plecYoJxvRFTLHVbIVAOoc"
"PLlaN88a7y2_plecYoJxvRFTLHVbIVAOoc"
Maximum number of video IDs to return
Required range:
1 <= x <= 5000Example:
10
Response
Successfully fetched playlist video IDs
Was this page helpful?
⌘I