Skip to content

Transcripts and Summaries

Igor Sazonov edited this page Sep 6, 2026 · 1 revision

Transcript and summary operations share the same basic pattern across supported platforms: construct a typed request, pass a context, check the error, and consume the typed result. The SDK offers transcript methods for YouTube, TikTok, Instagram, Facebook, X/Twitter, LinkedIn, and direct video URLs. It offers summary methods for YouTube, TikTok, Instagram, Facebook, and direct video URLs. 1 2

Fetch a transcript

For most video sources, use FetchRequest. A successful result is a *Transcript containing the full text and, when supplied by the API, timed segments and additional details such as language or credit use. 3

transcript, meta, err := client.TikTok.Transcript(ctx, &socialkit.FetchRequest{
    URL: "https://www.tiktok.com/@creator/video/123456789",
})
if err != nil {
    return err
}

fmt.Println(transcript.Transcript)
for _, segment := range transcript.TranscriptSegments {
    fmt.Printf("%.2fs: %s\n", segment.Start, segment.Text)
}

if meta.CreditsUsed != nil {
    log.Printf("credits used: %.0f", *meta.CreditsUsed)
}

TranscriptSegment has Text, Start, Duration, and an optional Timestamp. Treat the timestamp as display-oriented data; Start and Duration are more suitable for time calculations. 3

Choose the appropriate transcript method

Source SDK call Result type Important detail
YouTube client.YouTube.Transcript(ctx, req) *Transcript Supply a video URL.
TikTok client.TikTok.Transcript(ctx, req) *Transcript Supply a video URL.
Instagram client.Instagram.Transcript(ctx, req) *Transcript Supply an eligible video or reel URL.
Facebook client.Facebook.Transcript(ctx, req) *Transcript Supply an eligible video URL.
X/Twitter client.Twitter.Transcript(ctx, req) *TwitterTranscript Uses the standard aggregate transcript shape.
LinkedIn client.LinkedIn.Transcript(ctx, req) *LinkedInTranscript Segments do not include a Timestamp field.
Direct video client.Video.Transcript(ctx, req) *Transcript Supply a direct, accessible video-file URL.

The upstream API can report that a source is unsupported or that content is unavailable. In those cases, handle the returned typed error rather than assuming every public URL has a transcript. SocialKit documents this class of condition as a possible 404 response. 4

Generate a summary

SummaryRequest extends a simple URL request with optional CustomPrompt and CustomResponse fields. A *Summary includes normalized fields such as Summary, MainTopics, KeyPoints, Tone, TargetAudience, and Quotes when returned by the service. 3

summary, meta, err := client.YouTube.Summarize(ctx, &socialkit.SummaryRequest{
    URL:          "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
    CustomPrompt: socialkit.StringPtr("Summarize the implementation choices and risks."),
})
if err != nil {
    return err
}

fmt.Println(summary.Summary)
for _, point := range summary.KeyPoints {
    fmt.Println("-", point)
}

if meta.CreditsUsed != nil {
    fmt.Printf("credits used: %.0f\n", *meta.CreditsUsed)
}
Source SDK call Result type
YouTube client.YouTube.Summarize(ctx, req) *Summary
TikTok client.TikTok.Summarize(ctx, req) *Summary
Instagram client.Instagram.Summarize(ctx, req) *Summary
Facebook client.Facebook.Summarize(ctx, req) *Summary
Direct video client.Video.Summarize(ctx, req) *Summary

Custom response fields

Use CustomResponse to request application-specific summary fields. The field accepts any JSON-marshallable Go value. The SDK collects non-standard top-level fields from the response in Summary.Extra as json.RawMessage, keeping the model forward-compatible. 3

summary, _, err := client.YouTube.Summarize(ctx, &socialkit.SummaryRequest{
    URL: videoURL,
    CustomResponse: map[string]interface{}{
        "sentiment":  "",
        "keyTakeaway": "",
        "entities":   []string{},
    },
})
if err != nil {
    return err
}

var sentiment string
if raw, ok := summary.Extra["sentiment"]; ok {
    if err := json.Unmarshal(raw, &sentiment); err != nil {
        return err
    }
}

Avoid treating an Extra field as a permanent contract unless your application controls and validates the requested response shape. A robust application should unmarshal it into a small local struct and tolerate an absent field.

Apply server-side caching deliberately

FetchRequest and SummaryRequest include Cache and CacheTTL. The SDK forwards values only when you set them. SocialKit documents these as endpoint-level server-side caching parameters, so confirm their current availability in the specific endpoint documentation before making them a dependency of your workflow. 2 5

summary, _, err := client.Video.Summarize(ctx, &socialkit.SummaryRequest{
    URL:      directVideoURL,
    Cache:    socialkit.BoolPtr(true),
    CacheTTL: socialkit.IntPtr(3600),
})

Production considerations

Use a context deadline that reflects the latency your application can tolerate. Log only useful operational data, such as the source URL identifier, response status, elapsed time, and ResponseMeta counters. Do not log full raw responses without a privacy review, even though the SDK redacts authentication values. Use an error branch for 404 content unavailability and a separate branch for 429/5xx transient failures. 4 6

References

Clone this wiki locally