YouTube API

The YouTube API lets you search YouTube, retrieve video metadata, extract transcripts, and check trainability -- all through a single unified interface. Each endpoint returns structured JSON with credit usage tracking.

Endpoints

EndpointDescription
POST /api/v1/youtube/searchSearch YouTube with filters (date, duration, type, quality)
POST /api/v1/youtube/metadataGet structured metadata for a video (views, likes, tags, description)
POST /api/v1/youtube/transcriptExtract the transcript/captions for a video
POST /api/v1/youtube/trainabilityCheck if a video can be used for AI training

Authentication

HeaderValueRequired
AuthorizationBearer YOUR_API_KEYYes
Content-Typeapplication/jsonYes

YouTube Search

Bash
POST https://api.scavio.dev
/api/v1/youtube/search

Search YouTube and get structured results. Supports filtering by upload date, duration, result type, video quality, and more.

Request Body

ParameterTypeDefaultDescription
searchstring--Required. Search query (1-500 chars).
upload_datestring--Filter by upload date. One of: last_hour, today, this_week, this_month, this_year
typestring--Filter by result type. One of: video, channel, playlist
durationstring--Filter by video duration. One of: short (under 4 min), medium (4-20 min), long (over 20 min)
sort_bystringrelevanceSort order. One of: relevance, date, view_count, rating
hdbooleanfalseHD videos only
4kbooleanfalse4K videos only
subtitlesbooleanfalseVideos with subtitles/captions only
creative_commonsbooleanfalseCreative Commons licensed videos only
livebooleanfalseLive streams only
hdrbooleanfalseHDR videos only
360booleanfalse360-degree videos only
3dbooleanfalse3D videos only
locationbooleanfalseVideos with location metadata only
vr180booleanfalseVR180 videos only

Example

curl -X POST 'https://api.scavio.dev
/api/v1/youtube/search' \
  -H 'Authorization: Bearer sk_live_your_key' \
  -H 'Content-Type: application/json' \
  -d '{
    "search": "langchain tutorial",
    "type": "video",
    "duration": "medium",
    "sort_by": "view_count",
    "upload_date": "this_year"
  }'

Response Example

JSON
{
  "data": [
    {
      "videoId": "sVcwVQRHIc8",
      "title": "Learn RAG From Scratch - Python AI Tutorial",
      "channel": "freeCodeCamp.org",
      "channelId": "UC8butISFwT-Wl7EV0hUK0BQ",
      "publishedAt": "2024-04-17",
      "duration": "2:33:11",
      "viewCount": 1258310,
      "thumbnail": "https://i.ytimg.com/vi/sVcwVQRHIc8/hq720.jpg",
      "description": "Learn how to implement RAG from scratch..."
    }
  ],
  "response_time": 1.23,
  "credits_used": 1,
  "credits_remaining": 999
}

Video Metadata

Bash
POST https://api.scavio.dev
/api/v1/youtube/metadata

Get structured metadata for a YouTube video including title, description, view count, like count, comment count, tags, thumbnails, upload date, channel info, and available formats.

Request Body

ParameterTypeDescription
video_idstringRequired. YouTube video ID (e.g. dQw4w9WgXcQ).

Example

curl -X POST 'https://api.scavio.dev
/api/v1/youtube/metadata' \
  -H 'Authorization: Bearer sk_live_your_key' \
  -H 'Content-Type: application/json' \
  -d '{"video_id": "sVcwVQRHIc8"}'

Response Example

JSON
{
  "data": {
    "title": "Learn RAG From Scratch - Python AI Tutorial",
    "description": "Learn how to implement RAG from scratch...",
    "upload_date": "20240417",
    "duration": 9191,
    "view_count": 1258310,
    "like_count": 23211,
    "comment_count": 295,
    "categories": ["Education"],
    "tags": ["rag", "langchain", "python", "llm"],
    "channel_id": "UC8butISFwT-Wl7EV0hUK0BQ",
    "uploader": "freeCodeCamp.org",
    "uploader_url": "https://www.youtube.com/@freecodecamp",
    "is_live": false,
    "age_limit": 0,
    "thumbnails": [
      {
        "url": "https://i.ytimg.com/vi/sVcwVQRHIc8/maxresdefault.jpg",
        "width": 1280,
        "height": 720
      }
    ]
  },
  "response_time": 0.89,
  "credits_used": 1,
  "credits_remaining": 998
}

Video Transcript

Bash
POST https://api.scavio.dev
/api/v1/youtube/transcript

Extract the transcript (captions/subtitles) for a YouTube video. Supports multiple languages and both auto-generated and uploader-provided transcripts.

Request Body

ParameterTypeDefaultDescription
video_idstring--Required. YouTube video ID.
languagestringenTranscript language code (e.g. en, es, fr, de).
transcript_originstring--Transcript origin. Use auto_generated for auto-captions or uploader_provided for manual captions.

Example

curl -X POST 'https://api.scavio.dev
/api/v1/youtube/transcript' \
  -H 'Authorization: Bearer sk_live_your_key' \
  -H 'Content-Type: application/json' \
  -d '{
    "video_id": "sVcwVQRHIc8",
    "language": "en"
  }'

Response Example

JSON
{
  "data": [
    {
      "text": "in this course you will learn how to build",
      "start": 0.0,
      "duration": 3.2
    },
    {
      "text": "retrieval augmented generation from scratch",
      "start": 3.2,
      "duration": 2.8
    },
    {
      "text": "straight from a LangChain software engineer",
      "start": 6.0,
      "duration": 3.1
    }
  ],
  "response_time": 1.45,
  "credits_used": 1,
  "credits_remaining": 997
}

Video Trainability

Bash
POST https://api.scavio.dev
/api/v1/youtube/trainability

Check if a YouTube video has transcripts available and is suitable for AI training purposes. Returns information about transcript availability, license, and training eligibility.

Request Body

ParameterTypeDescription
video_idstringRequired. YouTube video ID.

Example

curl -X POST 'https://api.scavio.dev
/api/v1/youtube/trainability' \
  -H 'Authorization: Bearer sk_live_your_key' \
  -H 'Content-Type: application/json' \
  -d '{"video_id": "sVcwVQRHIc8"}'

Response Example

JSON
{
  "data": {
    "video_id": "sVcwVQRHIc8",
    "has_transcript": true,
    "transcript_languages": ["en", "es", "fr", "de", "pt"],
    "license": "standard",
    "is_trainable": true
  },
  "response_time": 0.67,
  "credits_used": 1,
  "credits_remaining": 996
}

Response Format

All YouTube endpoints return a consistent response wrapper:

FieldTypeDescription
dataobject | array | nullThe response payload. Shape depends on the endpoint. null if the request failed upstream.
response_timenumberServer-side response time in seconds
credits_usednumberNumber of credits consumed by this request
credits_remainingnumberCredits remaining in your current billing period

Error Responses

StatusDescription
401Unauthorized -- missing or invalid API key
429Rate or usage limit exceeded for your plan
502Upstream error -- retry after a short delay
503Upstream unavailable -- retry later

See Errors for the full error reference and retry best practices.

Related