Skip to main content
If your Node app hands video or podcast links to a BullMQ worker, the media job 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 from the worker 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. Long imports can take a few minutes, so don’t hold a worker for them. This page uses two queues: importly-start starts the job, and importly-check checks its status every 20 seconds until it’s done. A check only ever reads the status, so a retry never starts the job twice. Tested with BullMQ 6, ioredis 6 and Node 22. The code is TypeScript; drop the types for plain JavaScript.

1. Add your key

Create your key on the API key page (it is shown once). Add it as IMPORTLY_API_KEY to the environment your workers run in, and to .env for local development:
.env
BullMQ 6 no longer installs ioredis for you, so add it yourself.

2. A small client

A 429 or a 5xx throws RetryLater with how long to wait: the retryAfter the API sent, or 30 seconds. A 400 (a bad link), 401 (a wrong key) or 402 (balance too low) won’t change on a retry, so it throws BullMQ’s UnrecoverableError and the job fails without using up its attempts:
importly.ts

3. The queues

Pass one ioredis connection with maxRetriesPerRequest: null, which BullMQ workers need. A 5xx on either queue is retried up to five times with backoff:
queues.ts

4. The workers

"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 and is saved straight away. Anything still queued or running goes to importly-check:
worker.ts
Two BullMQ features do the waiting:
  • On a 429 from a start, startWorker.rateLimit() pauses the whole start queue for retryAfter, on every worker, and Worker.RateLimitError() puts the job back without counting an attempt.
  • A check that finds the job still running moves itself to the delayed set with moveToDelayed and throws DelayedError, so the same BullMQ job comes back in 20 seconds. It does the same on a 429 or 5xx, waiting as long as the API asked.
saveResult is yours:
save-result.ts
db stands for your ORM. A transcript has result.text, plus result.data.segments with start and end times. An import has result.mediaUrl, a link to the file that’s valid for 7 days, so copy the file to your storage if you keep it, or connect your bucket once and import with store: true (Save to your bucket).

Run it

Add a job from your API route once the record is saved:
Run the workers in their own process, for example node --env-file=.env --import tsx worker.ts, next to your web server. They work on any host that runs a long-lived Node process and has Redis: Fly.io, Railway, Render, a container or a VM. On serverless hosts without a long-lived process, use Trigger.dev or Inngest instead.

Notes

POST /import and POST /transcribe allow 240 requests per hour per key. BullMQ’s limiter counts across every worker on the queue, so max: 4 per minute keeps all of them together under that. 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 be checked at once, which is why the check worker runs with concurrency: 20. For hundreds of links, see Batch imports. 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, add the start job again later; every other failure code is final. See Media unavailable and Source throttled. Prefer a webhook? Start the job with a webhookUrl and save the result in an Express route, as in Webhooks. Each job gets one delivery and no retries, so keep importly-check as a fallback for jobs that stay pending. A youtube.com/playlist?list=… link is rejected with PLAYLIST_NOT_SUPPORTED. Add one job per video instead.
A transcript from captions costs $0.003, speech-to-text is $0.01 per minute, and a download is billed by size, about $0.15 for a 10-minute 720p video. maxCostDollars caps what one link can cost. Try it free, no card required. See Pricing & credits.