The route
app/api/youtube-transcript/route.ts
.env.local and in your host’s environment variables as IMPORTLY_API_KEY, without a NEXT_PUBLIC_ prefix, so it never reaches the browser. Create it on the API key page.
What comes back
source is platform_captions when the video’s own captions were used and speech-to-text otherwise. Segment times are in seconds, ready for subtitles, chapters or search. Shorts and youtu.be links work the same way.
Errors to handle
Polling, a form and webhooks
The Next.js recipe adds the polling route, a client form and a webhook for saving transcripts to your database. Options such as language and your own speech-to-text key are in Transcripts.A transcript from captions costs $0.003. Speech-to-text is $0.01 per minute. Try it free, no card required. See Pricing & credits.