Go Integration

YouTube Transcript API for Go

Fetch YouTube transcripts in Go using the standard library. Our API is ideal for high-performance microservices, CLI tools, and data pipelines written in Go. No external dependencies needed beyond the Go standard library.

Complete Code Example

package main

import (
	"encoding/json"
	"fmt"
	"log"
	"net/http"
	"net/url"
	"os"
)

type Segment struct {
	Text     string  `json:"text"`
	Start    float64 `json:"start"`
	Duration float64 `json:"duration"`
}

type TranscriptResponse struct {
	Title      string    `json:"title"`
	Channel    string    `json:"channel"`
	Duration   int       `json:"duration"`
	Transcript []Segment `json:"transcript"`
}

func main() {
	apiKey := os.Getenv("YT_TRANSCRIPTS_API_KEY")
	videoURL := "https://www.youtube.com/watch?v=dQw4w9WgXcQ"

	reqURL := fmt.Sprintf(
		"https://api.youtubetranscripts.co/v1/transcript?url=%s",
		url.QueryEscape(videoURL),
	)

	req, _ := http.NewRequest("GET", reqURL, nil)
	req.Header.Set("x-api-key", apiKey)

	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		log.Fatal(err)
	}
	defer resp.Body.Close()

	var data TranscriptResponse
	json.NewDecoder(resp.Body).Decode(&data)

	fmt.Printf("Title: %s\nChannel: %s\n", data.Title, data.Channel)
	for _, s := range data.Transcript {
		fmt.Printf("[%.1fs] %s\n", s.Start, s.Text)
	}
}

Key Features for Go Developers

Zero external dependencies with net/http

Struct tags for automatic JSON unmarshalling

Ideal for high-concurrency microservices

Works great with goroutines for parallel processing

Batch API for processing many videos concurrently

Compile to a single binary for easy deployment

Start Building with Go Today

Sign up in 30 seconds. Get 150 free API requests. No credit card required. Your Go integration can be live in minutes.