Node.js
import { Supadata } from '@supadata/js';
const supadata = new Supadata({
apiKey: 'YOUR_API_KEY',
});
const searchResults = await supadata.youtube.search({
query: 'rick astley never gonna give you up',
type: 'video', // Optional: 'video', 'channel', 'playlist', 'all' (default 'all')
limit: 20, // Optional: get more than the first page of results
sortBy: 'views', // Optional: 'relevance', 'rating', 'date', 'views'
uploadDate: 'year', // Optional: 'hour', 'today', 'week', 'month', 'year'
duration: 'medium', // Optional: 'short', 'medium', 'long'
});
console.log(`Found ${searchResults.results.length} results`);from supadata import Supadata
supadata = Supadata(api_key="YOUR_API_KEY")
search_results = supadata.youtube.search(
query="rick astley never gonna give you up",
type="video", # Optional: 'video', 'channel', 'playlist', 'all' (default 'all')
limit=20, # Optional: get more than the first page of results
sort_by="views", # Optional: 'relevance', 'rating', 'date', 'views'
upload_date="year", # Optional: 'hour', 'today', 'week', 'month', 'year'
duration="medium" # Optional: 'short', 'medium', 'long'
)
print(f"Found {len(search_results.results)} results")
for result in search_results.results:
print(f"{result.type}: {result.title}")curl -X GET "https://api.supadata.ai/v1/youtube/search?query=rick%20astley%20never%20gonna%20give%20you%20up&type=video&limit=20&sortBy=views&uploadDate=month" \
-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/search', 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/search",
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/search"
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/search")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.supadata.ai/v1/youtube/search")
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{
"query": "Rick Astley Never Gonna Give You Up",
"results": [
{
"type": "video",
"id": "dQw4w9WgXcQ",
"title": "Rick Astley - Never Gonna Give You Up (Official Video)",
"description": "The official music video for Rick Astley...",
"thumbnail": "https://i.ytimg.com/vi/dQw4w9WgXcQ/hqdefault.jpg",
"duration": 213,
"viewCount": 1234567890,
"uploadDate": "2009-10-25T00:00:00.000Z",
"channel": {
"id": "UCuAXFkgsw1L7xaCfnd5JJOw",
"name": "Rick Astley",
"thumbnail": "https://yt3.ggpht.com/..."
},
"handle": "@RickAstleyYT",
"videoCount": 100
}
],
"totalResults": 1000000,
"nextPageToken": "eyJxdWVyeSI6IlJpY2sgQXN0bGV5IiwiZmlsdGVycyI6e319"
}{
"error": "invalid-request",
"message": "Invalid Request",
"details": "The request is invalid or malformed",
"documentationUrl": "https://docs.supadata.ai/errors#invalid-request"
}{
"error": "invalid-request",
"message": "Invalid Request",
"details": "The request is invalid or malformed",
"documentationUrl": "https://docs.supadata.ai/errors#invalid-request"
}YouTube Endpoints
Search
Search YouTube for videos, channels, and playlists with advanced filters.
GET
/
youtube
/
search
Node.js
import { Supadata } from '@supadata/js';
const supadata = new Supadata({
apiKey: 'YOUR_API_KEY',
});
const searchResults = await supadata.youtube.search({
query: 'rick astley never gonna give you up',
type: 'video', // Optional: 'video', 'channel', 'playlist', 'all' (default 'all')
limit: 20, // Optional: get more than the first page of results
sortBy: 'views', // Optional: 'relevance', 'rating', 'date', 'views'
uploadDate: 'year', // Optional: 'hour', 'today', 'week', 'month', 'year'
duration: 'medium', // Optional: 'short', 'medium', 'long'
});
console.log(`Found ${searchResults.results.length} results`);from supadata import Supadata
supadata = Supadata(api_key="YOUR_API_KEY")
search_results = supadata.youtube.search(
query="rick astley never gonna give you up",
type="video", # Optional: 'video', 'channel', 'playlist', 'all' (default 'all')
limit=20, # Optional: get more than the first page of results
sort_by="views", # Optional: 'relevance', 'rating', 'date', 'views'
upload_date="year", # Optional: 'hour', 'today', 'week', 'month', 'year'
duration="medium" # Optional: 'short', 'medium', 'long'
)
print(f"Found {len(search_results.results)} results")
for result in search_results.results:
print(f"{result.type}: {result.title}")curl -X GET "https://api.supadata.ai/v1/youtube/search?query=rick%20astley%20never%20gonna%20give%20you%20up&type=video&limit=20&sortBy=views&uploadDate=month" \
-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/search', 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/search",
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/search"
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/search")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.supadata.ai/v1/youtube/search")
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{
"query": "Rick Astley Never Gonna Give You Up",
"results": [
{
"type": "video",
"id": "dQw4w9WgXcQ",
"title": "Rick Astley - Never Gonna Give You Up (Official Video)",
"description": "The official music video for Rick Astley...",
"thumbnail": "https://i.ytimg.com/vi/dQw4w9WgXcQ/hqdefault.jpg",
"duration": 213,
"viewCount": 1234567890,
"uploadDate": "2009-10-25T00:00:00.000Z",
"channel": {
"id": "UCuAXFkgsw1L7xaCfnd5JJOw",
"name": "Rick Astley",
"thumbnail": "https://yt3.ggpht.com/..."
},
"handle": "@RickAstleyYT",
"videoCount": 100
}
],
"totalResults": 1000000,
"nextPageToken": "eyJxdWVyeSI6IlJpY2sgQXN0bGV5IiwiZmlsdGVycyI6e319"
}{
"error": "invalid-request",
"message": "Invalid Request",
"details": "The request is invalid or malformed",
"documentationUrl": "https://docs.supadata.ai/errors#invalid-request"
}{
"error": "invalid-request",
"message": "Invalid Request",
"details": "The request is invalid or malformed",
"documentationUrl": "https://docs.supadata.ai/errors#invalid-request"
}Query Parameters
Array of special features to filter by (repeat the parameter for several: features=hd&features=subtitles). Note: works only for videos and movies.
Available options:
hd, subtitles, creative-commons, 3d, live, 4k, 360, location, hdr, vr180 Example:
["hd", "subtitles", "creative-commons"]
Response
Successfully retrieved search results
Was this page helpful?