ASP.NET Core: download YouTube, TikTok and Instagram videos
Register CrawlFetch as a typed HttpClient and expose it through a minimal API endpoint.
How it fits together
AddHttpClient configures the base address and bearer header once; the endpoint forwards the URL and returns the trimmed result.
ASP.NET Core example
using System.Net.Http.Headers;var builder = WebApplication.CreateBuilder(args);builder.Services.AddHttpClient("crawlfetch", c =>{c.BaseAddress = new Uri("https://api.crawlfetch.com");c.DefaultRequestHeaders.Authorization =new AuthenticationHeaderValue("Bearer", builder.Configuration["CRAWLFETCH_KEY"]);});var app = builder.Build();app.MapGet("/resolve", async (string url, IHttpClientFactory f) =>{var r = await f.CreateClient("crawlfetch").GetAsync($"/v1/resolve?url={Uri.EscapeDataString(url)}");return Results.Content(await r.Content.ReadAsStringAsync(), "application/json", statusCode: (int)r.StatusCode);});app.Run();
Notes for ASP.NET Core
- Keep the key in user secrets locally and Key Vault in production.
- Add
AddStandardResilienceHandler()for retries.
FAQ
Does it work on Azure Functions?
Yes — the same HttpClient setup works in isolated-worker functions.
Related
Last updated 2026-10-25