Bulk video download API
Downloading one video is easy; downloading 50,000 reliably is a queueing problem. This guide covers the patterns that keep bulk jobs fast and within your CrawlFetch rate limit.
The pattern
- Put URLs in a queue (SQS, Redis, a database table) — one job per URL.
- Run workers with a fixed concurrency below your plan's limit.
- Each worker resolves, downloads
downloadUrlimmediately, and stores the file. - On 429, pause that worker for
Retry-Afterseconds; on 500, retry with backoff; on 404, mark the job failed permanently. - Key jobs by the platform video ID so re-runs skip finished work.
Example worker with bounded concurrency
import asyncio, os, httpxLIMIT = asyncio.Semaphore(8) # stay under your plan's rate limitcf = httpx.AsyncClient(base_url="https://api.crawlfetch.com", headers={"Authorization": f"Bearer {os.environ['CRAWLFETCH_KEY']}"}, timeout=20)async def fetch_one(url: str) -> str:async with LIMIT:for attempt in range(5):r = await cf.get("/v1/resolve", params={"url": url})if r.status_code == 429:await asyncio.sleep(int(r.headers.get("retry-after", "5")))continueif r.status_code >= 500:await asyncio.sleep(2 ** attempt)continuer.raise_for_status()v = r.json()async with cf.stream("GET", v["downloadUrl"]) as dl:with open(f"{v['id']}.mp4", "wb") as f:async for chunk in dl.aiter_bytes():f.write(chunk)return v["id"]raise RuntimeError(f"gave up on {url}")async def main(urls):print(await asyncio.gather(*(fetch_one(u) for u in urls), return_exceptions=True))
Plan sizing
Every plan comes with monthly credits (Free 500, Starter 19,000, Pro 49,000, Scale 200,000), and each successful download costs a few credits by platform and file size. Every response includes x-credits-remaining, so workers can top up or slow down before they hit 402. See pricing.
FAQ
Can I mix platforms in one batch?
Yes. YouTube, TikTok, Instagram Reels and the other supported platforms all go through the same endpoint.
Should I resolve everything first and download later?
No — download links expire after a few hours. Resolve and download in the same job.
Related
Last updated 2026-10-25