Products/YouTube/YouTube Transcript/Integration
YouTube Transcript Integration
YouTube transcript API for Python
youtube_transcript_api gets about 15.79 million downloads a month on PyPI, and a large share of its open issues are some version of RequestBlocked or IpBlocked once the code runs on a cloud server instead of a laptop. GitHub issue
2 USD / 1,000 transcripts, pay as you go, with no charge for a NO_TRANSCRIPT or other error row.
Copy-paste example
import requests
def get_transcript(video_id: str) -> str:
response = requests.get(
"https://api.vakitek.co.uk/v1/youtube/transcript",
params={"video": video_id, "format": "json"},
headers={"X-API-Key": "YOUR_VAKITEK_API_KEY"},
)
response.raise_for_status()
item = response.json()["data"][0]
if "error" in item:
raise RuntimeError(item["error"])
return item["text"]Step by step
- Get a Vakitek API key from the dashboard and store it as an environment variable, never in source control.
- Replace the import of youtube_transcript_api with a small wrapper function (above) that calls GET /v1/youtube/transcript with requests.
- Keep the same function signature your code already calls, for example get_transcript(video_id), so callers do not need to change.
- Check the error field on the returned item instead of catching youtube_transcript_api's own exception classes, since a failed lookup is a normal 200 response with a typed error row.
- For more than one video, POST a videos list to the same path, up to 25 per call, instead of looping one request per video.
Your options compared
| Option | Trade-offs |
|---|---|
| youtube_transcript_api, direct | Free and simple for a local script, but 15.79 million monthly downloads and dozens of open RequestBlocked issues show it is routinely blocked once it runs from a cloud server's IP. |
| Vakitek API as a thin requests wrapper (this guide) | A few lines of code replace the library's network call, with residential proxy rotation handled server-side, at 2 USD / 1,000 transcripts. |
| youtube_transcript_api plus your own rotating proxies | Keeps the original library's interface, but you buy, configure and maintain the proxy pool yourself, and still hit YouTube's bot checks on videos a cheap proxy tier cannot get through. |
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
| requests.get raises an HTTPError with status 401. | The X-API-Key header is missing, wrong, or the key was revoked. | Confirm the key matches the one shown once in the Vakitek dashboard. Missing, unknown and revoked keys all return the same 401 UNAUTHORIZED body. |
| The response is 200 but item text is missing. | The video has no captions, is private, or hit another typed error. | Check the item error field (for example NO_TRANSCRIPT, PRIVATE or BLOCKED) before reading text, since errors return 200 with one errored row, not an HTTP failure. |
| A batch call with more than 25 videos fails. | The POST batch endpoint caps a single request at 25 videos. | The API returns 422 with error INVALID_INPUT and max 25. Chunk the list into groups of 25 or fewer. |
| Calls start failing with status 429. | The per-key rate limit, 120 requests a minute by default, was exceeded. | Add a short sleep or backoff between calls. 429 responses carry error RATE_LIMITED. |
Questions
Is this a drop-in replacement for youtube_transcript_api?
It replaces the network call, not the whole interface. Wrap the HTTP call in a function with the same name and signature your code already uses, and the rest of your script does not need to change.
Why does youtube_transcript_api fail on a server but work on my laptop?
YouTube blocks transcript requests more aggressively from IP ranges that belong to cloud providers. Issue
Does this need its own proxy setup?
No. Residential proxy rotation is handled on Vakitek's side and included in the 2 USD / 1,000 price.
Try YouTube Transcript with 5 USD of free credit.
Sources
- youtube_transcript_api monthly PyPI downloads: https://pypistats.org/api/packages/youtube-transcript-api/recent
- GitHub issue 303, cloud IP blocking: https://github.com/jdepoix/youtube-transcript-api/issues/303
