All guides

November 9, 2026 · 4 min read

How to Get YouTube Transcripts in C# and .NET

In short

Fetch YouTube transcripts in C# with HttpClient and System.Net.Http.Json: records for the response, SRT and VTT downloads, translation, and error handling.

In .NET you need no NuGet package beyond the framework: HttpClient and System.Net.Http.Json read the TranscriptYT YouTube Transcript API into C# records. It works in console apps, ASP.NET Core, Azure Functions, and anywhere else .NET runs.

Fetch a transcript

Create a free key in the dashboard (100 transcripts, no card) and set it as the TRANSCRIPTYT_KEY environment variable. This is a complete Program.cs.

using System.Net.Http.Headers;
using System.Net.Http.Json;

var http = new HttpClient { Timeout = TimeSpan.FromSeconds(120) };
http.DefaultRequestHeaders.Authorization =
    new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("TRANSCRIPTYT_KEY"));

var url = "https://transcript-yt.com/v1/transcript?url=" + Uri.EscapeDataString("https://youtu.be/5f3Pn-N6yLc");
using var res = await http.GetAsync(url);
if (!res.IsSuccessStatusCode)
{
    var err = await res.Content.ReadFromJsonAsync<ApiError>();
    throw new Exception($"{err?.Error.Code}: {err?.Error.Message}");
}

var t = (await res.Content.ReadFromJsonAsync<Transcript>())!;
Console.WriteLine($"{t.Title} {t.Language} {t.Source}");
foreach (var s in t.Segments.Take(3))
    Console.WriteLine($"{s.Start,7:F1}s  {s.Text}");

record Segment(double Start, double Duration, string Text);
record Transcript(string VideoId, string? Title, string Language, string Source, List<Segment> Segments);
record ApiErrorBody(string Code, string Message);
record ApiError(ApiErrorBody Error);

Subtitle files and translation

Add format=srt (or vtt, text, csv, md) to get the file body directly, and translate_to to translate into one of 150+ languages with the timings kept.

var srt = await http.GetStringAsync(
    "https://transcript-yt.com/v1/transcript?url=5f3Pn-N6yLc&format=srt&translate_to=es");
await File.WriteAllTextAsync("captions.es.srt", srt);

Errors and retries

Retry BLOCKED, RATE_LIMITED, and UPSTREAM_ERROR with backoff (Polly or Microsoft.Extensions.Http.Resilience work well). VIDEO_UNAVAILABLE, NO_CAPTIONS, and LANGUAGE_NOT_AVAILABLE are final, and a 402 means you're out of credits. Failed requests are never billed. Every code is in the docs.

Common questions

How do I get a YouTube transcript in C#?

Call GET https://transcript-yt.com/v1/transcript with the video URL as the url parameter and your key as a Bearer token, then read the JSON with ReadFromJsonAsync.

Which .NET version do I need?

.NET 6 or later. System.Net.Http.Json is part of the framework, and its web defaults map the API's camelCase fields to PascalCase properties.

Should I create a new HttpClient per request?

No. Reuse one instance, or register it with IHttpClientFactory in ASP.NET Core, so connections are pooled.

Try the YouTube Transcript API

Get transcripts as JSON, text, SRT, or VTT. 100 free credits, no card required.

More guides