Authentication

Learn how to authenticate your API requests using Bearer tokens.

Overview

The YouTube Transcript API uses Bearer token authentication. Every request to the API must include an header with your API key. Authorization

Keep your API key secret

Never expose your API key in client-side code, public repositories, or share it with others. If compromised, revoke it immediately from your dashboard.

Getting Your API Key

Follow these steps to obtain your API key:

1

Create an account or sign in

Sign Up or Sign In.

2

Navigate to API Keys

Dashboard > API Keys.

3

Generate a new API key

Click "Create New Key", give it a name, and copy the generated key. Make sure to save it - you won't be able to see it again!

API Key Format

API keys are prefixed with yt_ followed by a unique identifier:

yt_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6

Making Authenticated Requests

Include your API key in the Authorization header using the Bearer scheme:

Two authentication methods are supported:

  • Authorization: Bearer yt_your_api_key - Bearer token in Authorization header
  • X-API-Key: yt_your_api_key - Direct API key header

cURL (Bearer Token)

Terminal
curl -X GET "https://api.fetchtranscript.com/v1/transcripts/dQw4w9WgXcQ" \
  -H "Authorization: Bearer yt_your_api_key"

cURL (X-API-Key Header)

Terminal
curl -X GET "https://api.fetchtranscript.com/v1/transcripts/dQw4w9WgXcQ" \
  -H "X-API-Key: yt_your_api_key"

Python

Python
import requests

API_KEY = "yt_your_api_key"
BASE_URL = "https://api.fetchtranscript.com/v1"

headers = {
    "Authorization": f"Bearer {API_KEY}"
}

response = requests.get(
    f"{BASE_URL}/transcripts/dQw4w9WgXcQ",
    headers=headers
)

print(response.json())

JavaScript

JavaScript
const API_KEY = "yt_your_api_key";
const BASE_URL = "https://api.fetchtranscript.com/v1";

const response = await fetch(
  `${BASE_URL}/transcripts/dQw4w9WgXcQ`,
  {
    headers: {
      "Authorization": `Bearer ${API_KEY}`
    }
  }
);

const data = await response.json();
console.log(data);

Authentication Errors

If authentication fails, you will receive one of the following error responses:

Status CodeErrorDescription
401missing_api_keyNo API key provided in request
401invalid_api_keyAPI key has been revoked
402insufficient_creditsInsufficient credits

Best Practices

Use environment variables

Store your API key in environment variables, not in your code.

Use different keys for different environments

Create separate API keys for development, staging, and production.

Rotate keys periodically

Regularly rotate your API keys to minimize security risks.

Never expose keys client-side

Make API calls from your server, not from browser JavaScript.

Next Steps