Node.js
import { Supadata } from '@supadata/js';
const supadata = new Supadata({
apiKey: 'YOUR_API_KEY',
});
const video = await supadata.youtube.video({
id: 'https://youtu.be/dQw4w9WgXcQ', // can be id or url
});
console.log(video.title);from supadata import Supadata
supadata = Supadata(api_key="YOUR_API_KEY")
video = supadata.youtube.video(
id="https://youtu.be/dQw4w9WgXcQ" # can be id or url
)
print(f"Video title: {video.title}")
print(f"Channel: {video.channel.name}")curl -X GET "https://api.supadata.ai/v1/youtube/video?id=https://youtu.be/dQw4w9WgXcQ" \
-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/video', 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/video",
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/video"
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/video")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.supadata.ai/v1/youtube/video")
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{
"id": "dQw4w9WgXcQ",
"title": "Rick Astley - Never Gonna Give You Up (Official Music Video)",
"description": "The official music video for \"Never Gonna Give You Up\"...",
"duration": 213,
"channel": {
"id": "UCuAXFkgsw1L7xaCfnd5JJOw",
"name": "Rick Astley"
},
"tags": [
"Rick Astley",
"Official Video",
"Music"
],
"transcriptLanguages": [
"en",
"es",
"fr"
],
"thumbnail": "https://i.ytimg.com/vi/dQw4w9WgXcQ/hqdefault.jpg",
"uploadDate": "2009-10-25T00:00:00.000Z",
"viewCount": 1234567890,
"likeCount": 12345678
}{
"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
Video
deprecated
Get metadata for a YouTube video.
GET
/
youtube
/
video
Node.js
import { Supadata } from '@supadata/js';
const supadata = new Supadata({
apiKey: 'YOUR_API_KEY',
});
const video = await supadata.youtube.video({
id: 'https://youtu.be/dQw4w9WgXcQ', // can be id or url
});
console.log(video.title);from supadata import Supadata
supadata = Supadata(api_key="YOUR_API_KEY")
video = supadata.youtube.video(
id="https://youtu.be/dQw4w9WgXcQ" # can be id or url
)
print(f"Video title: {video.title}")
print(f"Channel: {video.channel.name}")curl -X GET "https://api.supadata.ai/v1/youtube/video?id=https://youtu.be/dQw4w9WgXcQ" \
-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/video', 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/video",
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/video"
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/video")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.supadata.ai/v1/youtube/video")
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{
"id": "dQw4w9WgXcQ",
"title": "Rick Astley - Never Gonna Give You Up (Official Music Video)",
"description": "The official music video for \"Never Gonna Give You Up\"...",
"duration": 213,
"channel": {
"id": "UCuAXFkgsw1L7xaCfnd5JJOw",
"name": "Rick Astley"
},
"tags": [
"Rick Astley",
"Official Video",
"Music"
],
"transcriptLanguages": [
"en",
"es",
"fr"
],
"thumbnail": "https://i.ytimg.com/vi/dQw4w9WgXcQ/hqdefault.jpg",
"uploadDate": "2009-10-25T00:00:00.000Z",
"viewCount": 1234567890,
"likeCount": 12345678
}{
"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 video URL or ID. See supported URL formats.
Examples:
"https://youtu.be/dQw4w9WgXcQ"
"dQw4w9WgXcQ"
Response
Successfully fetched video metadata
YouTube video ID
Example:
"dQw4w9WgXcQ"
Video title
Example:
"Rick Astley - Never Gonna Give You Up (Official Music Video)"
Video description
Example:
"The official music video for \"Never Gonna Give You Up\"..."
Video duration in seconds
Example:
213
Channel information
Show child attributes
Show child attributes
Video tags
Example:
["Rick Astley", "Official Video", "Music"]
Available transcript language codes
Example:
["en", "es", "fr"]
URL to video thumbnail
Example:
"https://i.ytimg.com/vi/dQw4w9WgXcQ/hqdefault.jpg"
Video upload date
Example:
"2009-10-25T00:00:00.000Z"
Number of views
Example:
1234567890
Number of likes
Example:
12345678
Was this page helpful?
⌘I