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"
}Search
Search YouTube for videos, channels, and playlists with advanced filters.
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"
}Authorizations
Query Parameters
Search query string
1"Never Gonna Give You Up"
Filter by upload date (eg. last month). Note: works only for videos and movies.
all, hour, today, week, month, year "month"
Filter by content type
all, video, channel, playlist, movie "video"
Filter by video duration: short (<4min), medium (4-20min), long (>20min). Note: works only for videos and movies.
all, short, medium, long "medium"
Sort order of search results.
relevance, rating, date, views "views"
Array of special features to filter by (repeat the parameter for several: features=hd&features=subtitles). Note: works only for videos and movies.
hd, subtitles, creative-commons, 3d, live, 4k, 360, location, hdr, vr180 ["hd", "subtitles", "creative-commons"]
Maximum number of results to return. When provided, the API will automatically paginate to fetch up to this many results. When omitted, returns a single page with nextPageToken for manual pagination.
1 <= x <= 500050
Token for fetching the next page of results. When provided, other filter parameters are ignored.
"eyJxdWVyeSI6IlJpY2sgQXN0bGV5IiwiZmlsdGVycyI6e319"
Response
Successfully retrieved search results
The search query that was executed
"Rick Astley Never Gonna Give You Up"
Array of search results
Show child attributes
Show child attributes
Estimated total number of results
1000000
Token for fetching the next page of results. Only returned when limit parameter is not provided.
"eyJxdWVyeSI6IlJpY2sgQXN0bGV5IiwiZmlsdGVycyI6e319"
Was this page helpful?