crawlfetch

Firebase Cloud Functions: download YouTube, TikTok and Instagram videos

For Flutter and mobile apps on Firebase, a callable Cloud Function keeps the CrawlFetch key off the device and hands the app a download link.

How it fits together

The app calls a callable function with the URL; the function checks auth, resolves the URL and returns downloadUrl.

Firebase Cloud Functions example

import { onCall, HttpsError } from "firebase-functions/v2/https";
import { defineSecret } from "firebase-functions/params";
const key = defineSecret("CRAWLFETCH_KEY");
export const resolveVideo = onCall({ secrets: [key] }, async (req) => {
if (!req.auth) throw new HttpsError("unauthenticated", "Sign in first.");
const r = await fetch("https://api.crawlfetch.com/v1/resolve?" + new URLSearchParams({ url: req.data.url }), {
headers: { Authorization: "Bearer " + key.value() },
});
if (!r.ok) throw new HttpsError("unavailable", "Could not resolve video (" + r.status + ")");
const { title, thumbnail, downloadUrl } = await r.json();
return { title, thumbnail, downloadUrl };
});

Notes for Firebase Cloud Functions

  • Enable App Check to stop calls from outside your app.

FAQ

How does the Flutter app call it?

FirebaseFunctions.instance.httpsCallable('resolveVideo').call({'url': url}).

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