Go SDK

Build video on FastPix from Go: a go video SDK

The official FastPix SDK for Go. Typed end-to-end, async-aware, retry-safe. Encodes a source URL into a playback ID in one call, provisions LL-HLS live streams, verifies webhooks with one helper, and ships with a migration path from the closest API peer (see comparison).

Go 1.21Min runtime
Typedend-to-end
Asyncthroughout

Trusted by product teams shipping video at scale

AAO NXTAadhanKnovorocketlaneDLICOMPractice by Numberssuperbit

Install

One install, one client, one call

Add the package, point the client at your API key, and you're talking to FastPix — strongly-typed, no scaffolding.

01

Install the package

bash · terminal

bash · terminal
go get github.com/fastpix/fastpix-go

Runtime

Go 1.21+.

Type safety

Typed structs for every request, response, and webhook event.

IDE support

VS Code with gopls, GoLand, full LSP support.

02

Initialize the client

Go · main.go

Go · main.go
import "github.com/fastpix/fastpix-go"

fp := fastpix.New(fastpix.Config{
    APIKey: os.Getenv("FASTPIX_API_KEY"),
    // optional: HTTPClient, MaxRetries, BaseURL
})

Common operations

From upload to playback in 4 calls

Encode, wait, stream, upload. The four most common flows, typed end-to-end.

1. Encode a source URL into a playback ID

fp.Assets.Create
ctx := context.Background()
asset, err := fp.Assets.Create(ctx, &fastpix.AssetCreateRequest{
    Inputs:         []fastpix.AssetInput{{URL: "https://your-cdn.com/source.mp4"}},
    PlaybackPolicy: fastpix.PlaybackPolicyPublic,
})
if err != nil { return err }

fmt.Println(asset.PlaybackID)  // "abc123"

2. Wait until the asset is ready

fp.Assets.WaitUntilReady
// Poll until the asset is ready, or listen for the asset.ready webhook.
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()

ready, err := fp.Assets.WaitUntilReady(ctx, asset.ID, &fastpix.WaitOptions{
    PollInterval: 2 * time.Second,
})

3. Provision a low-latency live stream

fp.Live.Create
stream, err := fp.Live.Create(ctx, &fastpix.LiveStreamCreateRequest{
    LatencyMode:           fastpix.LatencyModeLow,    //  LL-HLS
    ReconnectWindowSeconds: 60,
    PlaybackPolicy:        fastpix.PlaybackPolicyPublic,
})
// stream.StreamKey -> push to rtmp://global-live.fastpix.com/live

4. Resumable chunked upload

fastpix-go/upload
// Resumable chunked upload from a Go service
import "github.com/fastpix/fastpix-go/upload"

f, _ := os.Open("./source.mp4")
defer f.Close()

err := upload.Chunked(ctx, assetUploadURL, f, &upload.Options{
    ChunkSizeMB: 8,
    OnProgress:  func(pct int) { log.Printf("%d%%", pct) },
})

Security, compliance, and partnerships

PartnerNVIDIA Inception
PartnerGoogle Cloud Partner

Webhook signature verification

One helper, every event typed

Every webhook FastPix sends is signed. The SDK verifies the signature and returns a fully-typed event payload. Switch on event.type and reach the typed payload directly.

webhook.go
import "github.com/fastpix/fastpix-go/webhooks"

func fastpixWebhook(w http.ResponseWriter, r *http.Request) {
    body, _ := io.ReadAll(r.Body)
    event, err := webhooks.Verify(body,
        r.Header.Get("FastPix-Signature"),
        os.Getenv("FASTPIX_WEBHOOK_SECRET"))
    if err != nil { http.Error(w, err.Error(), 400); return }

    switch event.Type {
    case webhooks.EventAssetReady:
        // event.Data is fully typed
    }
    w.WriteHeader(http.StatusOK)
}

Concurrency model

Built for the Go runtime

Every method takes a context.Context as the first argument. Cancellation propagates to in-flight HTTP requests. The default *http.Client uses HTTP/2 with a connection pool of 16; override via fastpix.Config.HTTPClient. Goroutine-safe for concurrent use across requests.

Type safety + IDE support

Every API surface uses typed structs. Webhook events use a discriminated-union pattern via the Type field and a typed Data field; the typed switch in the example above is exhaustive at the language level (no runtime panics on unknown events; they pass through to the default branch).

Migration

Swap the client, keep the shape

FastPix exposes primitives that mirror the closest API peer. The Go SDK keeps the call shapes recognizable so the migration is a one-file swap, not a rewrite. FastPix vs Mux side-by-side.

migrate.go
// Before: import "github.com/muxinc/mux-go/v5"
// FastPix:
import "github.com/fastpix/fastpix-go"

fp := fastpix.New(fastpix.Config{APIKey: os.Getenv("FASTPIX_API_KEY")})

// Before: asset, _, err := mux.VideoAPI.CreateAsset(ctx, req)
// FastPix:
asset, err := fp.Assets.Create(ctx, &fastpix.AssetCreateRequest{
    Inputs:         []fastpix.AssetInput{{URL: url}},
    PlaybackPolicy: fastpix.PlaybackPolicyPublic,
})

// Before: asset.Data.PlaybackIds[0].Id
// FastPix:
asset.PlaybackID

Bulk migration tooling at /compare/mux and the docs migration guide handles asset re-ingest and playback-ID remap.

FAQ

Go SDK FAQ

  • What does the Go SDK ship with out of the box?

    All API surfaces (assets, live streams, playback policies, webhooks, simulcast, analytics query) plus the resumable chunked upload helper, webhook signature verification, automatic retries with exponential backoff, and configurable timeout / base URL / HTTP client. Type definitions are bundled.
  • Is the Go SDK production-ready?

    Yes. The client is used in production by FastPix customers shipping video on the Go runtime. The retry policy, connection pool defaults, and timeout shape are tuned against the same workload patterns that produce the numbers on the /performance page.
  • How do I authenticate against the FastPix API from Go?

    Set the FASTPIX_API_KEY environment variable and pass it to the client constructor. The SDK adds the Bearer header on every request. For server-side runtimes, fetching the API key from your secret store at startup and constructing the client once at module load is the recommended pattern.
  • Where do I get an API key?

    Sign up at the FastPix dashboard. The free trial provisions a key with no credit card; the trial plan covers 10 videos plus 100K streaming minutes plus AI samples. See /pricing for the full plan structure.

Read it, run it, ship it.

Every SDK, player, and integration lives on GitHub. Star the repos, file an issue, or open a PR — we build alongside the developers who use us.

Browse the repos