The short version: the importly SDK
If you just need the transcript in a script or a background task, the official importly package wraps the same API in a few lines:
mode="auto") the transcript comes from the media’s captions ($0.003), and from speech-to-text ($0.01 per minute) when there are none; max_cost_dollars caps what speech-to-text may cost. To never pay for speech-to-text, pass mode="captions": a video without captions then raises TranscriptionProviderRequiredError with a price quote, at no charge. speaker_labels=True gives each segment a speaker ("A", "B", …) and always uses speech-to-text. For the file itself, call client.import_media(url, video_quality="720p") and read result.media_url; for audio only, pass include_video=False, and audio_format="original" to keep the source’s own audio instead of an mp3 (result.mime_type says what you got). include_transcript=True adds the transcript to the same job, with transcript_mode and transcript_speaker_labels; result.transcript_status is "completed" (the text is in result.transcript), "skipped" (result.transcript_skipped_reason says why, at no charge) or, for long media whose file is ready first, "running": import_media waits for it within its timeout, and after that client.wait_for_import(job_id) or client.wait_for_transcription(result.transcript_job_id) picks it up. For title, uploader and view counts, call client.metadata(url). There’s an AsyncImportly for asyncio.gather, and client.start_transcription(url, webhook_url=...) when you want a webhook instead of waiting; importly.webhooks.parse_webhook(body, signature=..., secret=...) checks the Importly-Signature header and parses the delivery.
The rest of this page is the full FastAPI service: endpoints, polling and a signed webhook, written as plain HTTP so the same calls also run in Flask, Django or a Celery task.
1. Add your key
Create your key on the API key page (it’s shown once) and put it in your server’s environment:.env
2. Start the transcript
"mode": "auto" uses the video’s captions and falls back to speech-to-text when there are none. wait holds the request until the transcript is ready, so a captioned video usually comes back in this one call.
main.py
error message. A job that fails later, for example because the video is private, comes back with status: "failed", a code and a message. See Error handling.
3. Poll if it’s still running
Long videos without captions take longer thanwait. Then the response has status: "queued" or "running" and a jobId. Your frontend calls this endpoint every few seconds until the status is completed or failed:
main.py
text is the whole transcript. segments holds the same text with start and end times in seconds, which is what you want for chunking into a vector store, captions or search.
4. In production: save results with a webhook
When the transcript belongs to a record in your database, start the job with awebhookUrl instead of waiting, and store the jobId with the record:
POST when the job finishes. This endpoint takes only the jobId from it and reads the result from the API with your key, so a forged request can’t put data into your app. Every delivery is also signed: to reject forged requests before calling the API, check the Importly-Signature header as shown in Verify signatures:
main.py
https://, so a server on localhost gets nothing: poll in development. See Webhooks.
On AWS Lambda, the AWS Lambda recipe does the same with three handlers and a DynamoDB table, including the signature check and a sweep for missed webhooks.
Downloading the file instead
For the video or audio file itself, send the link toPOST /import and read GET /import/status the same way. The finished job has result.mediaUrl, a link to the file that’s valid for 7 days. Set includeVideo: false for audio only, or store: true to have it copied to your own bucket. /import has no wait, so poll or use a webhook. See Downloads.
A transcript from captions costs $0.003. Speech-to-text for a video without captions is $0.01 per minute, and
maxCostDollars stops a long one before it’s charged. Try it free, no card required. See Pricing & credits.