API Documentation

Authentication

All API requests require an API key in the header:

X-API-Key: ytins_your_api_key_here

Download Captions

Extract captions from a YouTube video.

POST /api/v1/captions/download

Request Body:

{
  "video_url": "https://www.youtube.com/watch?v=VIDEO_ID",
  "language": "en",           // optional, default: "en"
  "format": "json",           // "json" or "txt", default: "json"
  "cleanup": true,            // optional, default: false
  "include_timing": false     // optional, default: false
}

Response:

{
  "video_id": "VIDEO_ID",
  "language": "en",
  "format": "json",
  "word_count": 1234,
  "credits_used": 1234,
  "captions": [...]
}

cURL Example:

curl -X POST https://api.ytinsight.app/api/v1/captions/download \
  -H "X-API-Key: ytins_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "video_url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
    "language": "en",
    "format": "json",
    "cleanup": true
  }'

Get Available Languages

List all available caption languages for a video.

GET /api/v1/captions/languages/:videoId

cURL Example:

curl https://api.ytinsight.app/api/v1/captions/languages/dQw4w9WgXcQ \
  -H "X-API-Key: ytins_your_api_key"

Credit System

Credits are deducted based on word count:

  • 1 credit = 1 word extracted from video
  • Credits are deducted after successful caption extraction
  • Failed requests do not consume credits
  • Check your balance in the dashboard

Error Codes

Code Description
400 Bad Request - Invalid parameters
401 Unauthorized - Invalid API key
402 Payment Required - Insufficient credits
429 Too Many Requests - Rate limit exceeded
500 Internal Server Error