crawlfetch

Django: download YouTube, TikTok and Instagram videos

In Django, keep the CrawlFetch call in a small service module, call it from a view for instant results, and from a Celery task when you need to save the file.

How it fits together

A view resolves the URL and renders the result; a Celery task downloads downloadUrl into a FileField so the request returns immediately.

Django example

import os
import requests
SESSION = requests.Session()
SESSION.headers["Authorization"] = f"Bearer {os.environ['CRAWLFETCH_KEY']}"
def resolve(url: str) -> dict:
r = SESSION.get("https://api.crawlfetch.com/v1/resolve", params={"url": url}, timeout=15)
r.raise_for_status()
return r.json()

Notes for Django

  • Read the key from the environment (or django-environ), never settings.py in git.
  • retry_backoff=True gives exponential backoff for 429 and 500 responses.
  • Point FileField storage at S3 (django-storages) for production.

FAQ

Can I store downloaded files in S3?

Yes — use django-storages so video.file.save uploads to your bucket.

Related

Last updated 2026-10-25

Add video downloads to your product today.

1,000 credits on signup plus 500 every month. That is roughly 180 YouTube clips to start, with no card.

Create free account