Skip to main content
If your Express backend takes video or podcast links, the download or transcript 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. You don’t need Redis or a worker for this. A route starts the Importly job and stores its ID, Importly sends a signed webhook to your app when the job finishes, and a small script run from cron picks up any job whose webhook didn’t arrive. If you already run BullMQ, see BullMQ instead. The code uses Node 18+ fetch, Express and Postgres through pg.

1. Add your key

Create your key on the API key page (it is shown once). On the same page, under Webhook signing secret, click Reveal and copy the whsec_… secret. Add both to your server’s environment, and to .env for development:
.env
The code saves to a videos table:

2. A small client

A 400 (a bad link), 401 (a wrong key) or 402 (balance too low) throws with the API’s message. A webhook’s result fields sit in data itself, while the status endpoint nests them under result, so saveResult takes the job and its result separately:
importly.js

3. Start the job from a route

"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 in this one call and is saved straight away. Anything still queued or running finishes later through the webhook. maxCostDollars caps what one link can cost:
app.js
To download the file instead, insert the row with importly_kind 'import' and call POST /import. It returns a job ID straight away, and the webhook brings the mediaUrl:
webhookUrl must be a public https:// address. In local development, leave it out and run the script in step 5 to fetch results.

4. The webhook route

Importly sends one POST when the job finishes. Check the Importly-Signature header against the raw body before you trust it, so use express.raw on this route, not express.json: parsing the JSON first changes the bytes and the signature won’t match.
app.js
A finished transcript’s importly_result has text, and data.segments with start and end times in seconds. A finished import’s has mediaUrl, a link to the file that’s valid for 7 days: copy it to your storage if you keep it, or connect your bucket once and import with store: true (Save to your bucket). See Webhooks for every payload.

5. Catch missed webhooks

Each job gets one webhook delivery and no retries, so a deploy or a brief outage can miss one. This script asks the status endpoint about every job that has been pending for more than two minutes, and gives up on jobs still pending after an hour:
check-importly-jobs.js
Run it every few minutes from cron, or from your platform’s scheduler (Render cron jobs, Railway cron, Heroku Scheduler, a Kubernetes CronJob):
crontab

Notes

A caption transcript costs $0.003; speech-to-text is billed per minute, and downloads by size. See Transcripts, Downloads and Pricing. SOURCE_THROTTLED and LIVE_NOT_SUPPORTED are the failure codes that can work on a later attempt (a site that is busy for now, or a stream that is still live). For those, start the job again 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. For hundreds of links, see Batch imports. A youtube.com/playlist?list=… link is rejected with PLAYLIST_NOT_SUPPORTED. Insert one row per video instead.