Skip to main content
If your Go service takes video or podcast links, the media step is the one that breaks once it runs on a server: sites block datacenter IPs, and many videos have no captions to read. Call Importly instead. It returns the transcript, a download link for the file, or the video’s details, for links from YouTube, TikTok, Instagram, X, podcasts and 1,000+ other sites. The code below uses only the standard library and Go 1.22 or later. It’s one small package, importly, plus two HTTP handlers.

1. Add your key

Create your key on the API key page (it is shown once) and put it in your server’s environment. The webhook signing secret is on the same page, under Webhook signing secret:
.env

2. A small client

Call returns the job, or an *APIError when the API refused the request. A 429 carries the retryAfter the API sent. Final() is true for a 400 (a bad link), 401 (a wrong key) or 402 (balance too low), which a retry won’t change:
importly/client.go

3. Transcripts and downloads

"mode": "auto" uses the video’s captions and falls back to speech-to-text when it has none. wait: true holds the request open for up to 30 seconds, so a transcript from captions usually comes back from the first call. POST /import returns a job ID straight away. WaitFor checks a job until it’s done, waits for retryAfter on a 429, and stops when the context ends:
importly/jobs.go
Run long jobs outside the request, in a goroutine or your job queue, with a deadline:
A finished transcript’s result has text, and data.segments with start and end times in seconds. A finished import’s result has mediaUrl, a link to the file that’s valid for 7 days: copy the file to your storage if you keep it, or connect your bucket once and import with "store": true (Save to your bucket). A caption transcript costs $0.003; speech-to-text is billed per minute, and maxCostDollars caps what one link can cost. See Transcripts and Downloads.

4. Webhooks in production

When a job belongs to a record in your database, add "webhookUrl": "https://your-app.example/webhooks/importly" to the start request and store the jobId with the record. Importly sends one POST when the job finishes. Check its signature on the raw body first (see Verify signatures):
importly/webhook.go
The handlers below start a transcript from a form post and take the webhook. The webhook handler only takes the jobId from the body and reads the job from the API with your key, so even a request that got past the signature check can’t put data into your app:
main.go
Each job gets one delivery and no retries, so also check jobs that have been pending for a few minutes with importly.Status. The webhook URL must be public https://, so a server on localhost gets nothing: use WaitFor in development. See Webhooks.

Notes

SOURCE_THROTTLED and LIVE_NOT_SUPPORTED are the failure codes that can work on a later attempt (a stream that is still live, or a site that is busy for now). Start a new job for those later; every other failure code is final. See Media unavailable and Source throttled. POST /import allows 240 requests per hour per key, and an account can have 50 imports queued or running at once. Status endpoints allow 3,600 requests per hour per job type; a check every 20 seconds is 180 an hour for each job in progress, so about 20 jobs can poll at once. For hundreds of links, see Batch imports. A youtube.com/playlist?list=… link is rejected with PLAYLIST_NOT_SUPPORTED. Send one request per video instead.