Turn a YouTube video into a summary
Transcripts run as background jobs. Kick one off, poll until it lands, then feed the text to any LLM.
Python
import os, time, requests
KEY = os.environ["SOCIALCRAWL_API_KEY"]
H = {"x-api-key": KEY}
VIDEO = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
# Transcripts are slow, so the API queues them and returns a job id.
r = requests.get("http://datatrend.nl/v1/youtube/transcript", params={"url": VIDEO}, headers=H)
job = r.json()["data"]["job_id"]
while True:
poll = requests.get(f"http://datatrend.nl/v1/jobs/{job}", headers=H).json()
if poll.get("data", {}).get("status") in (None, "done", "failed"):
break
time.sleep(2)
transcript = poll["data"]
print(transcript["word_count"], "words,", transcript["duration_seconds"], "seconds")
print(transcript["text"][:500])
You'll need a key. It takes ten seconds and starts with 100 credits.
Get a key