A robust, type-safe Go SDK designed for seamless integration with the FastPix API platform.
The FastPix Go SDK simplifies integration with the FastPix platform. It provides a clean, strongly-typed interface for secure and efficient communication with the FastPix API, enabling easy management of media uploads, live streaming, on‑demand content, playlists, video analytics, and signing keys for secure access and token management. It is intended for use with Go 1.21 and above.
| Requirement | Version | Description |
|---|---|---|
| Go | 1.21+ |
Core runtime environment |
| Go Modules | Enabled |
Dependency management |
| Internet | Required |
API communication and authentication |
Pro Tip: We recommend using Go 1.21+ for optimal performance and the latest language features.
To get started with the FastPix Go SDK, ensure you have the following:
- The FastPix APIs are authenticated using a Username and a Password. You must generate these credentials to use the SDK.
- Follow the steps in the Authentication with Basic Auth guide to obtain your credentials.
Configure your FastPix credentials using environment variables for enhanced security and convenience:
# Set your FastPix credentials
export FASTPIX_USERNAME="your-access-token"
export FASTPIX_PASSWORD="your-secret-key"Security Note: Never commit your credentials to version control. Use environment variables or secure credential management systems.
Install the FastPix Go SDK using Go modules:
go get github.com/FastPix/fastpix-goThe SDK uses standard Go packages. Import the necessary packages at the top of your files:
import (
"context"
"github.com/FastPix/fastpix-go"
"github.com/FastPix/fastpix-go/models/components"
)Initialize the FastPix SDK with your credentials:
package main
import (
"context"
"github.com/FastPix/fastpix-go"
"github.com/FastPix/fastpix-go/models/components"
)
func main() {
ctx := context.Background()
s := fastpixgo.New(
fastpixgo.WithSecurity(components.Security{
Username: fastpixgo.Pointer("your-access-token"),
Password: fastpixgo.Pointer("your-secret-key"),
}),
)
}Or using environment variables:
package main
import (
"context"
"os"
"github.com/FastPix/fastpix-go"
"github.com/FastPix/fastpix-go/models/components"
)
func main() {
ctx := context.Background()
s := fastpixgo.New(
fastpixgo.WithSecurity(components.Security{
Username: fastpixgo.Pointer(os.Getenv("FASTPIX_USERNAME")), // Your Access Token
Password: fastpixgo.Pointer(os.Getenv("FASTPIX_PASSWORD")), // Your Secret Key
}),
)
}package main
import (
"bytes"
"context"
"encoding/json"
"fmt"
"io"
"log"
"github.com/FastPix/fastpix-go/models/components"
fastpixgo "github.com/FastPix/fastpix-go"
)
func main() {
ctx := context.Background()
s := fastpixgo.New(
fastpixgo.WithSecurity(components.Security{
Username: fastpixgo.Pointer("your-access-token"),
Password: fastpixgo.Pointer("your-secret-key"),
}),
)
res, err := s.InputVideo.Create(ctx, components.CreateMediaRequest{
Inputs: []components.Input{
components.CreateInputPullVideoInput(
components.PullVideoInput{},
),
},
Metadata: map[string]string{
"your-metadata-key": "your-metadata-value",
},
})
if err != nil {
log.Fatal(err)
}
if res.CreateMediaSuccessResponse != nil {
// Read raw response body to preserve API's JSON field order
if res.HTTPMeta.Response != nil && res.HTTPMeta.Response.Body != nil {
rawBody, err := io.ReadAll(res.HTTPMeta.Response.Body)
if err == nil && len(rawBody) > 0 {
var buf bytes.Buffer
if err := json.Indent(&buf, rawBody, "", " "); err == nil {
fmt.Println(buf.String())
} else {
fmt.Println(string(rawBody))
}
} else {
responseJSON, err := json.MarshalIndent(res.CreateMediaSuccessResponse, "", " ")
if err != nil {
log.Printf("Error marshaling response: %v", err)
fmt.Printf("Response: %+v\n", res.CreateMediaSuccessResponse)
} else {
fmt.Println(string(responseJSON))
}
}
} else {
responseJSON, err := json.MarshalIndent(res.CreateMediaSuccessResponse, "", " ")
if err != nil {
log.Printf("Error marshaling response: %v", err)
fmt.Printf("Response: %+v\n", res.CreateMediaSuccessResponse)
} else {
fmt.Println(string(responseJSON))
}
}
} else if res.DefaultError != nil {
fmt.Printf("Error: %+v\n", res.DefaultError)
}
}Comprehensive Go SDK for FastPix platform integration with full API coverage.
Upload, manage, and transform video content with comprehensive media management capabilities.
For detailed documentation, see FastPix Video on Demand Overview.
- Create from URL - Upload video content from external URL
- Upload from Device - Upload video files directly from device
- List All Media - Retrieve complete list of all media files
- Get Media by ID - Get detailed information for specific media
- Update Media - Modify media metadata and settings
- Delete Media - Remove media files from library
- Cancel Upload - Stop ongoing media upload process
- Get Input Info - Retrieve detailed input information
- List Uploads - Get all available upload URLs
- List Clips - Get all clips of a media
- Create Playback ID - Generate secure playback identifier
- List Playback IDs - Get all playback IDs for a media
- Delete Playback ID - Remove playback access
- Get Playback ID - Retrieve playback configuration details
- Update Domain Restrictions - Update domain restrictions for a playback ID
- Update User-Agent Restrictions - Update user-agent restrictions for a playback ID
- Create Playlist - Create new video playlist
- List Playlists - Get all available playlists
- Get Playlist - Retrieve specific playlist details
- Update Playlist - Modify playlist settings and metadata
- Delete Playlist - Remove playlist from library
- Add Media - Add media items to playlist
- Reorder Media - Change order of media in playlist
- Remove Media - Remove media from playlist
- Create Key - Generate new signing key pair
- List Keys - Get all available signing keys
- Delete Key - Remove signing key from system
- Get Key - Retrieve specific signing key details
- List DRM Configs - Get all DRM configuration options
- Get DRM Config - Retrieve specific DRM configuration
Stream, manage, and transform live video content with real-time broadcasting capabilities.
For detailed documentation, see FastPix Live Stream Overview.
- Create Stream - Initialize new live streaming session
- List Streams - Retrieve all active live streams
- Get Viewer Count - Get real-time viewer statistics
- Get Stream - Retrieve detailed stream information
- Delete Stream - Terminate and remove live stream
- Update Stream - Modify stream settings and configuration
- Enable Stream - Activate live streaming
- Disable Stream - Pause live streaming
- Complete Stream - Finalize and archive stream
- Create Playback ID - Generate secure live playback access
- Delete Playback ID - Revoke live playback access
- Get Playback ID - Retrieve live playback configuration
- Create Simulcast - Set up multi-platform streaming
- Delete Simulcast - Remove simulcast configuration
- Get Simulcast - Retrieve simulcast settings
- Update Simulcast - Modify simulcast parameters
Monitor video performance and quality with comprehensive analytics and real-time metrics.
For detailed documentation, see FastPix Video Data Overview.
- List Breakdown Values - Get detailed breakdown of metrics by dimension
- List Overall Values - Get aggregated metric values across all content
- Get Timeseries Data - Retrieve time-based metric trends and patterns
- Compare Values - List comparison values
- List Video Views - Get comprehensive list of video viewing sessions
- Get View Details - Retrieve detailed information about specific video views
- List Top Content - Find your most popular and engaging content
- List Dimensions - Get available data dimensions for filtering and analysis
- List Filter Values - Get specific values for a particular dimension
- List Errors - Get list of playback errors
Transform and enhance your video content with powerful AI and editing capabilities.
Enhance video content with AI-powered features including moderation, summarization, and intelligent categorization.
- Generate Summary - Create AI-generated video summaries
- Update Chapters - Automatically generate video chapter markers
- Extract Entities - Identify and extract named entities from content
- Enable Moderation - Activate content moderation and safety checks
- List Live Clips - Get all clips of a live stream
- List Media Clips - Retrieve all clips associated with a source media
- Generate Subtitles - Create automatic subtitles for media
- Add Track - Add audio or subtitle tracks to media
- Update Track - Modify existing audio or subtitle tracks
- Delete Track - Remove audio or subtitle tracks
- Update Source Access - Control access permissions for media source
- Update MP4 Support - Configure MP4 download capabilities
Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.
To change the default retry strategy for a single API call, simply provide a retry.Config object to the call by using the WithRetries option:
package main
import (
"context"
"log"
"github.com/FastPix/fastpix-go/models/components"
"github.com/FastPix/fastpix-go/models/operations"
"github.com/FastPix/fastpix-go/retry"
fastpixgo "github.com/FastPix/fastpix-go"
)
func main() {
ctx := context.Background()
s := fastpixgo.New(
fastpixgo.WithSecurity(components.Security{
Username: fastpixgo.Pointer("your-access-token"),
Password: fastpixgo.Pointer("your-secret-key"),
}),
)
res, err := s.InputVideo.Create(ctx, components.CreateMediaRequest{
Inputs: []components.Input{
components.CreateInputPullVideoInput(
components.PullVideoInput{},
),
},
Metadata: map[string]string{
"your-metadata-key": "your-metadata-value",
},
}, operations.WithRetries(
retry.Config{
Strategy: "backoff",
Backoff: &retry.BackoffStrategy{
InitialInterval: 1,
MaxInterval: 50,
Exponent: 1.1,
MaxElapsedTime: 100,
},
RetryConnectionErrors: false,
}))
if err != nil {
log.Fatal(err)
}
if res.CreateMediaSuccessResponse != nil {
// handle response
}
}If you'd like to override the default retry strategy for all operations that support retries, you can use the WithRetryConfig option at SDK initialization:
package main
import (
"context"
"log"
"github.com/FastPix/fastpix-go/models/components"
"github.com/FastPix/fastpix-go/retry"
fastpixgo "github.com/FastPix/fastpix-go"
)
func main() {
ctx := context.Background()
s := fastpixgo.New(
fastpixgo.WithRetryConfig(
retry.Config{
Strategy: "backoff",
Backoff: &retry.BackoffStrategy{
InitialInterval: 1,
MaxInterval: 50,
Exponent: 1.1,
MaxElapsedTime: 100,
},
RetryConnectionErrors: false,
}),
fastpixgo.WithSecurity(components.Security{
Username: fastpixgo.Pointer("your-access-token"),
Password: fastpixgo.Pointer("your-secret-key"),
}),
)
res, err := s.InputVideo.Create(ctx, components.CreateMediaRequest{
Inputs: []components.Input{
components.CreateInputPullVideoInput(
components.PullVideoInput{},
),
},
Metadata: map[string]string{
"your-metadata-key": "your-metadata-value",
},
})
if err != nil {
log.Fatal(err)
}
if res.CreateMediaSuccessResponse != nil {
// handle response
}
}Handling errors in this SDK should largely match your expectations. All operations return a response object or an error, they will never return both.
By Default, an API error will return apierrors.APIError. When custom error responses are specified for an operation, the SDK may also return their associated error. You can refer to respective Errors tables in SDK docs for more details on possible error types for each operation.
For example, the Create function may return the following errors:
| Error Type | Status Code | Content Type |
|---|---|---|
| apierrors.APIError | 4XX, 5XX | */* |
package main
import (
"context"
"errors"
"log"
"github.com/FastPix/fastpix-go/models/apierrors"
"github.com/FastPix/fastpix-go/models/components"
fastpixgo "github.com/FastPix/fastpix-go"
)
func main() {
ctx := context.Background()
s := fastpixgo.New(
fastpixgo.WithSecurity(components.Security{
Username: fastpixgo.Pointer("your-access-token"),
Password: fastpixgo.Pointer("your-secret-key"),
}),
)
res, err := s.InputVideo.Create(ctx, components.CreateMediaRequest{
Inputs: []components.Input{
components.CreateInputPullVideoInput(
components.PullVideoInput{},
),
},
Metadata: map[string]string{
"your-metadata-key": "your-metadata-value",
},
})
if err != nil {
var e *apierrors.APIError
if errors.As(err, &e) {
// handle error
log.Fatal(e.Error())
}
}
if res.CreateMediaSuccessResponse != nil {
// handle response
}
}Primary exception:
apierrors.APIError: The base class for HTTP error responses.
Less common exceptions
-
Network connectivity errors: These are typically returned as
apierrors.APIErrorwith appropriate status codes. For network-level errors, check the underlying error message. -
Response validation errors: When the response data could not be deserialized into the expected type, the SDK will return an
apierrors.APIErrorwith details about the validation failure.
The default server can be overridden globally using the WithServerURL(serverURL string) option when initializing the SDK client instance. For example:
package main
import (
"context"
"log"
"github.com/FastPix/fastpix-go/models/components"
fastpixgo "github.com/FastPix/fastpix-go"
)
func main() {
ctx := context.Background()
s := fastpixgo.New(
fastpixgo.WithServerURL("your-server-url"),
fastpixgo.WithSecurity(components.Security{
Username: fastpixgo.Pointer("your-access-token"),
Password: fastpixgo.Pointer("your-secret-key"),
}),
)
res, err := s.InputVideo.Create(ctx, components.CreateMediaRequest{
Inputs: []components.Input{
components.CreateInputPullVideoInput(
components.PullVideoInput{},
),
},
Metadata: map[string]string{
"your-metadata-key": "your-metadata-value",
},
})
if err != nil {
log.Fatal(err)
}
if res.CreateMediaSuccessResponse != nil {
// handle response
}
}The Go SDK makes API calls using an HTTP client that wraps the standard net/http package. The requirements for the HTTP client are very simple. It must match this interface:
type HTTPClient interface {
Do(req *http.Request) (*http.Response, error)
}The built-in net/http client satisfies this interface and a default client based on the built-in is provided by default. To replace this default with a client of your own, you can implement this interface yourself or provide your own client configured as desired. Here's a simple example, which adds a client with a 30 second timeout:
package main
import (
"context"
"net/http"
"time"
"github.com/FastPix/fastpix-go/models/components"
fastpixgo "github.com/FastPix/fastpix-go"
)
func main() {
ctx := context.Background()
httpClient := &http.Client{Timeout: 30 * time.Second}
s := fastpixgo.New(
fastpixgo.WithClient(httpClient),
fastpixgo.WithSecurity(components.Security{
Username: fastpixgo.Pointer("your-access-token"),
Password: fastpixgo.Pointer("your-secret-key"),
}),
)
res, err := s.InputVideo.Create(ctx, components.CreateMediaRequest{
Inputs: []components.Input{
components.CreateInputPullVideoInput(
components.PullVideoInput{},
),
},
Metadata: map[string]string{
"your-metadata-key": "your-metadata-value",
},
})
if err != nil {
// handle error
}
if res.CreateMediaSuccessResponse != nil {
// handle response
}
}This can be a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration.
For simple debugging, you can enable request/response logging by implementing a custom client:
package main
import (
"fmt"
"net/http"
"time"
"github.com/FastPix/fastpix-go/models/components"
fastpixgo "github.com/FastPix/fastpix-go"
)
type LoggingHTTPClient struct {
client *http.Client
}
func (c *LoggingHTTPClient) Do(req *http.Request) (*http.Response, error) {
// Log request
fmt.Printf("Sending %s request to %s\n", req.Method, req.URL.String())
resp, err := c.client.Do(req)
// Log response
if err != nil {
fmt.Printf("Request failed: %v\n", err)
} else {
fmt.Printf("Received %s response\n", resp.Status)
}
return resp, err
}
func main() {
ctx := context.Background()
loggingClient := &LoggingHTTPClient{
client: &http.Client{Timeout: 30 * time.Second},
}
s := fastpixgo.New(
fastpixgo.WithClient(loggingClient),
fastpixgo.WithSecurity(components.Security{
Username: fastpixgo.Pointer("your-access-token"),
Password: fastpixgo.Pointer("your-secret-key"),
}),
)
// Use SDK as normal
}This Go SDK is programmatically generated from our API specifications. Any manual modifications to internal files will be overwritten during subsequent generation cycles.
We value community contributions and feedback. Feel free to submit pull requests or open issues with your suggestions, and we'll do our best to include them in future releases.
For comprehensive understanding of each API's functionality, including detailed request and response specifications, parameter descriptions, and additional examples, please refer to the FastPix API Reference.
The API reference offers complete documentation for all available endpoints and features, enabling developers to integrate and leverage FastPix APIs effectively.