Tutorial

How to Get YouTube Video Metadata via API

Retrieve YouTube video metadata including title, view count, likes, channel info, and description using the Scavio API. No YouTube Data API quota needed.

YouTube video metadata — title, view count, like count, description, tags, channel name, and upload date — is valuable for content analysis, influencer research, and competitive benchmarking. The YouTube Data API v3 imposes strict daily quotas that limit large-scale analysis. The Scavio YouTube metadata endpoint returns rich video metadata by video ID without YouTube API quota concerns. This tutorial shows how to fetch metadata for individual videos and batch multiple lookups efficiently.

Prerequisites

  • Python 3.8 or higher
  • requests library installed
  • A Scavio API key
  • One or more YouTube video IDs to look up

Walkthrough

Step 1: Fetch metadata for a single video

POST to the Scavio endpoint with platform youtube, action metadata, and the video_id.

Python
def get_video_metadata(video_id: str) -> dict:
    response = requests.post(
        "https://api.scavio.dev/api/v1/search",
        headers={"x-api-key": API_KEY},
        json={"platform": "youtube", "action": "metadata", "video_id": video_id}
    )
    response.raise_for_status()
    return response.json()

Step 2: Extract key fields

Parse the metadata response to extract title, view count, like count, and channel information.

Python
meta = get_video_metadata("dQw4w9WgXcQ")
video = meta.get("video", {})
print("Title:", video.get("title"))
print("Views:", video.get("view_count"))
print("Likes:", video.get("like_count"))
print("Channel:", video.get("channel_name"))
print("Published:", video.get("published_at"))

Step 3: Batch fetch multiple videos

Loop over a list of video IDs and collect metadata for each. Use time.sleep to stay within rate limits.

Python
import time

def batch_metadata(video_ids: list[str]) -> list[dict]:
    results = []
    for vid_id in video_ids:
        meta = get_video_metadata(vid_id)
        results.append(meta.get("video", {}))
        time.sleep(0.5)  # polite rate limiting
    return results

Step 4: Sort videos by view count

Rank the fetched videos by view count to identify the most popular content.

Python
videos = batch_metadata(["dQw4w9WgXcQ", "9bZkp7q19f0", "kJQP7kiw5Fk"])
sorted_videos = sorted(videos, key=lambda v: int(v.get("view_count", 0) or 0), reverse=True)
for v in sorted_videos:
    print(f"{v.get('title', 'N/A')[:50]}: {v.get('view_count')} views")

Python Example

Python
import os
import time
import requests

API_KEY = os.environ.get("SCAVIO_API_KEY", "your_scavio_api_key")
ENDPOINT = "https://api.scavio.dev/api/v1/search"

def get_metadata(video_id: str) -> dict:
    r = requests.post(ENDPOINT, headers={"x-api-key": API_KEY},
                      json={"platform": "youtube", "action": "metadata", "video_id": video_id})
    r.raise_for_status()
    return r.json().get("video", {})

def batch(ids: list[str]) -> list[dict]:
    results = []
    for vid in ids:
        results.append(get_metadata(vid))
        time.sleep(0.3)
    return results

if __name__ == "__main__":
    ids = ["dQw4w9WgXcQ", "9bZkp7q19f0"]
    videos = batch(ids)
    for v in sorted(videos, key=lambda x: int(x.get("view_count") or 0), reverse=True):
        print(f"{v.get('title', 'N/A')[:60]}: {v.get('view_count')} views")

JavaScript Example

JavaScript
const API_KEY = process.env.SCAVIO_API_KEY || "your_scavio_api_key";
const ENDPOINT = "https://api.scavio.dev/api/v1/search";

async function getMetadata(videoId) {
  const res = await fetch(ENDPOINT, {
    method: "POST",
    headers: { "x-api-key": API_KEY, "Content-Type": "application/json" },
    body: JSON.stringify({ platform: "youtube", action: "metadata", video_id: videoId })
  });
  const data = await res.json();
  return data.video || {};
}

async function main() {
  const ids = ["dQw4w9WgXcQ", "9bZkp7q19f0"];
  const videos = await Promise.all(ids.map(getMetadata));
  videos.sort((a, b) => (parseInt(b.view_count) || 0) - (parseInt(a.view_count) || 0));
  videos.forEach(v => console.log(`${v.title?.slice(0, 60)}: ${v.view_count} views`));
}
main().catch(console.error);

Expected Output

JSON
{
  "video": {
    "video_id": "dQw4w9WgXcQ",
    "title": "Rick Astley - Never Gonna Give You Up (Official Video)",
    "channel_name": "Rick Astley",
    "channel_id": "UCuAXFkgsw1L7xaCfnd5JJOw",
    "view_count": "1547823901",
    "like_count": "17200000",
    "published_at": "2009-10-25",
    "duration": "PT3M33S",
    "description": "The official video for Rick Astley's Never Gonna Give You Up..."
  }
}

Related Tutorials

Frequently Asked Questions

Most developers complete this tutorial in 15 to 30 minutes. You will need a Scavio API key (free tier works) and a working Python or JavaScript environment.

Python 3.8 or higher. requests library installed. A Scavio API key. One or more YouTube video IDs to look up. A Scavio API key gives you 500 free credits per month.

Yes. The free tier includes 500 credits per month, which is more than enough to complete this tutorial and prototype a working solution.

Scavio has a native LangChain package (langchain-scavio), an MCP server, and a plain REST API that works with any HTTP client. This tutorial uses the raw REST API, but you can adapt to your framework of choice.

Start Building

Retrieve YouTube video metadata including title, view count, likes, channel info, and description using the Scavio API. No YouTube Data API quota needed.