Go SDK

Learn how the FastPix Go SDK enables video uploads, live streaming, and playback management in Go applications.

Add secure, scalable video to your Go project

The FastPix Go SDK gives you everything you need to manage video from your backend. Upload files from a public URL, attach metadata, and retrieve playback links, all without building encoding pipelines or managing storage. With this SDK, you can:

  • Upload and organize video assets
  • Define access control and metadata
  • Generate HLS playback URLs
  • Streamline video delivery from your Go server

Find more in the SDK reference

To explore more examples, API methods, and advanced usage, see the FastPix Go SDK on GitHub.


Prerequisites

Before you start using the FastPix Golang SDK, make sure you have the following:

  1. Go 1.20 or later: This SDK is compatible with Go 1.20 or higher
  2. Go modules enabled: Ensure your project uses Go modules for dependency management
  3. FastPix API credentials: You’ll need an Access Key and a Secret Key (HTTP Basic Auth). You can generate these credentials by following the steps in the Authentication guide.
  4. Basic understanding of Go and REST APIs: Familiarity with Go development and API integration concepts

Installation

Install the SDK using go get:

1go get github.com/FastPix/fastpix-go

Import the SDK

1import (
2 "context"
3 "github.com/FastPix/fastpix-go"
4 "github.com/FastPix/fastpix-go/models/components"
5)

Example

Let’s create a file named main.go

This example shows how to upload a video from a public URL with metadata and public access:

NOTE
In the following example, replace your-access-token-id and your-secret-key with the Access Token ID and Secret Key values from the .env file you downloaded.

1package main
2
3import (
4 "bytes"
5 "context"
6 "encoding/json"
7 "fmt"
8 "io"
9 "log"
10
11 "github.com/FastPix/fastpix-go/models/components"
12 fastpixgo "github.com/FastPix/fastpix-go"
13)
14
15func main() {
16 ctx := context.Background()
17
18 s := fastpixgo.New(
19 fastpixgo.WithSecurity(components.Security{
20 Username: fastpixgo.Pointer("your-access-token"),
21 Password: fastpixgo.Pointer("your-secret-key"),
22 }),
23 )
24
25 res, err := s.InputVideo.Create(ctx, components.CreateMediaRequest{
26 Inputs: []components.Input{
27 components.CreateInputPullVideoInput(
28 components.PullVideoInput{},
29 ),
30 },
31 Metadata: map[string]string{
32 "your-metadata-key": "your-metadata-value",
33 },
34 })
35 if err != nil {
36 log.Fatal(err)
37 }
38 if res.CreateMediaSuccessResponse != nil {
39 // Read raw response body to preserve API's JSON field order
40 if res.HTTPMeta.Response != nil && res.HTTPMeta.Response.Body != nil {
41 rawBody, err := io.ReadAll(res.HTTPMeta.Response.Body)
42 if err == nil && len(rawBody) > 0 {
43 var buf bytes.Buffer
44 if err := json.Indent(&buf, rawBody, "", " "); err == nil {
45 fmt.Println(buf.String())
46 } else {
47 fmt.Println(string(rawBody))
48 }
49 } else {
50 responseJSON, err := json.MarshalIndent(res.CreateMediaSuccessResponse, "", " ")
51 if err != nil {
52 log.Printf("Error marshaling response: %v", err)
53 fmt.Printf("Response: %+v\n", res.CreateMediaSuccessResponse)
54 } else {
55 fmt.Println(string(responseJSON))
56 }
57 }
58 } else {
59 responseJSON, err := json.MarshalIndent(res.CreateMediaSuccessResponse, "", " ")
60 if err != nil {
61 log.Printf("Error marshaling response: %v", err)
62 fmt.Printf("Response: %+v\n", res.CreateMediaSuccessResponse)
63 } else {
64 fmt.Println(string(responseJSON))
65 }
66 }
67 } else if res.DefaultError != nil {
68 fmt.Printf("Error: %+v\n", res.DefaultError)
69 }
70}

After the video is processed, you can use the media ID to fetch playback info, monitor status, or transform content via API.


Run the example

To execute the Go script, use the following command. Make sure to replace main.go with your actual file name if it’s different:

$go run main.go

NOTE

Some methods might throw errors when you are on a trial plan.


Changelog

All notable changes to this project will be documented in this file.

[1.1.4]

Changed

  • SDK version bump: 1.1.31.1.4. A maintenance release that updates the SDK’s internal version identifiers. It contains no functional, API, or behavioral changes and is fully backward compatible with 1.1.3.

    Updated identifiers:

    • SDKVersion constant — now reports 1.1.4.
    • User-Agent header — outbound requests now identify as fastpix-sdk/go 1.1.4.

Compatibility

  • No changes to public types, method signatures, request/response models, default server URLs, hooks, or retry logic.
  • No action required for existing integrations — update the dependency and rebuild.

[1.1.3]

Changed — FastPix .io.com migration

FastPix is moving its hosts and documentation to the .com TLD. This release updates every reference in the SDK and its docs:

Old (.io)New (.com)
api.fastpix.ioapi.fastpix.com
stream.fastpix.iostream.fastpix.com
images.fastpix.ioimages.fastpix.com
static.fastpix.iostatic.fastpix.com
docs.fastpix.io/...fastpix.com/docs/...
  • The default server URL is now https://api.fastpix.com/v1/ (was https://api.fastpix.io/v1/). If you rely on SDK defaults, no code change is required — upgrading and rebuilding is enough.
  • If you pass an explicit override (e.g. fastpixgo.New(fastpixgo.WithServerURL("https://api.fastpix.io/v1/"))), change it to https://api.fastpix.com/v1/.
  • All README and per-service documentation links now point at https://fastpix.com/docs/....

The .io hosts still serve traffic during the transition but are slated for deprecation — update any hard-coded .io references (server URL, playback/asset URLs) in your application.

Fixed

  • Added missing frameRate field to video tracks in the list media response (VideoTrackForGetAll).
  • Added missing data.message field to the delete signing key response (DeleteSigningKeyResponse).

[1.1.2]

Fixed

  • Fixed data event field remapping in hooks.

[1.1.1]

  • Replaced documentation placeholders from your-video-id to your-media-id.

[1.1.0]

Fixed

  • Fixed missing parameters in multiple API methods.

Improved

  • Improved overall developer experience through more accurate typings.

[1.0.0]

Added

  • Complete API coverage for Media, Live Streaming, Video Data, and Signing Keys
  • Go 1.22+ support with comprehensive type safety
  • Media upload, management, and processing capabilities
  • Live streaming with simulcasting support
  • Video analytics and performance tracking
  • Cryptographic signing keys for secure authentication
  • In-video AI processing features
  • DRM configuration and management
  • Playlist creation and management
  • Comprehensive error handling with specific error types
  • Built-in retry mechanisms and timeout handling
  • Comprehensive test suite with 14 test files
  • Full API specification compliance

Changed

  • Reorganized package structure for better maintainability
  • Updated dependencies to modern Go packages
  • Improved API design with better error handling
  • Enhanced documentation and examples
  • Updated SDK version to 1.0.0
  • Updated minimum Go version requirement to 1.22+ for better compatibility and performance

Fixed

  • Direct upload metadata handling
  • Response object access patterns
  • Type mismatches in method parameters
  • Error handling for validation responses
  • Test data structure alignment with API expectations
  • Improved error handling with specific error types
  • Fixed type annotation issues for better IDE support
  • Ensured consistent API patterns across modules

[0.0.1]

Added

  • Initial release of FastPix Go SDK
  • HTTP client support with Go standard library
  • Media API integration with upload, management, and processing
  • Playback ID management for media files
  • Media operations (list, get, update, delete)
  • Direct upload support for video files
  • Live stream API integration
  • Live stream management (create, update, delete)
  • Playback ID management for live streams
  • Simulcast configuration for live streams
  • HTTP Basic authentication support
  • Server URL override support
  • Comprehensive error handling and custom error classes
  • Example usage and quick start documentation
  • Go Modules integration
  • Type checking integration
  • Test framework integration