Go SDK
The FastPix Golang SDK provides a developer-friendly way to integrate video capabilities into your Go applications. With support for media upload, live streaming, simulcasting, and playback management, you can build video-based applications for your use case.
Features
Integration prerequisite
Step 1: Installation
Step 2: Importing the SDK
Step 3: Initialization
Perform media operations
Live stream operations
Error handling
Support & resource
Features
The FastPix Golang SDK provides the following key features:
Media APIs
- Upload Media: Easily upload media files from URLs or devices to the FastPix platform
- Manage Media: Perform various media operations such as listing, fetching, updating, and deleting media assets
- Playback IDs: Create and manage playback IDs to access your media
Live Streaming APIs
- Create & Manage Live Streams: Stream live events by creating, listing, updating, and deleting live streams
- Control Stream Access: Generate playback IDs to control who can access your live streams
- Simulcast: Stream content to multiple platforms simultaneously with ease
Key Benefits
- Type Safety: Full type hints and strict typing for better development experience
- Developer-Friendly: Intuitive API design with comprehensive error handling
- Production Ready: Built for high-performance applications with retry mechanisms
- Comprehensive Coverage: Complete access to all FastPix platform features
For detailed usage, refer to the FastPix API Reference.
Integration Prerequisite
Before you start using the FastPix Golang SDK, make sure you have the following:
- Go 1.20 or later: This SDK is compatible with Go 1.20 or higher
- Go modules enabled: Ensure your project uses Go modules for dependency management
- 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.
- Basic understanding of Go and REST APIs: Familiarity with Go development and API integration concepts
Step 1: Installation
The SDK is available through Go modules and can be installed using the go get command.
Using Go Modules
go get github.com/FastPix/fastpix-go\@v0.1.0
Using go.mod
Add this to your go.mod file:
require github.com/FastPix/fastpix-go v0.1.0
Then run:
go mod tidy
Step 2: Importing the SDK
Add the necessary import statements to your Go files:
import (
"context"
fastpixgo "github.com/FastPix/fastpix-go"
"github.com/FastPix/fastpix-go/models/components"
)
Step 3: Initialization
You can set the security parameters using the WithSecurity
option when initializing the SDK client instance. The SDK uses different server URLs for different operations:
For Media Operations
Use the base FastPix server URL:
package main
import (
"context"
fastpixgo "github.com/FastPix/fastpix-go"
"github.com/FastPix/fastpix-go/models/components"
)
func main() {
ctx := context.Background()
sdk := fastpixgo.New(
fastpixgo.WithServerURL("https://api.fastpix.io/v1"),
fastpixgo.WithSecurity(components.Security{
Username: fastpixgo.String("your-access-key"),
Password: fastpixgo.String("your-secret-key"),
}),
)
// Use sdk...
}
For Live Stream Operations
Use the live streaming specific server URL:
package main
import (
"context"
fastpixgo "github.com/FastPix/fastpix-go"
"github.com/FastPix/fastpix-go/models/components"
)
func main() {
ctx := context.Background()
sdk := fastpixgo.New(
fastpixgo.WithServerURL("https://api.fastpix.io/v1/live"),
fastpixgo.WithSecurity(components.Security{
Username: fastpixgo.String("your-access-key"),
Password: fastpixgo.String("your-secret-key"),
}),
)
// Use sdk...
}
Environment Variables (Recommended)
For production applications, use environment variables for security:
package main
import (
"context"
"os"
fastpixgo "github.com/FastPix/fastpix-go"
"github.com/FastPix/fastpix-go/models/components"
)
func main() {
ctx := context.Background()
sdk := fastpixgo.New(
fastpixgo.WithServerURL("https://api.fastpix.io/v1"), // or 'https://api.fastpix.io/v1/live' for live streams
fastpixgo.WithSecurity(components.Security{
Username: fastpixgo.String(os.Getenv("FASTPIX_ACCESS_KEY")),
Password: fastpixgo.String(os.Getenv("FASTPIX_SECRET_KEY")),
}),
)
// Use sdk...
}
Perform Media Operations
1.1 Create Media from URL
This endpoint allows developers or users to create a new video or audio media in FastPix using a publicly accessible URL. FastPix will fetch the media from the provided URL, process it, and store it on the platform for use.
Use the CreateMedia()
method to create media from a URL. This is useful when you want to import videos from external sources.
For more details refer to Create Media From URL API documentation.
package main
import (
"context"
"log"
fastpixgo "github.com/FastPix/fastpix-go"
"github.com/FastPix/fastpix-go/models/components"
)
func main() {
ctx := context.Background()
// Initialize SDK for media operations
sdk := fastpixgo.New(
fastpixgo.WithServerURL("https://api.fastpix.io/v1"),
fastpixgo.WithSecurity(components.Security{
Username: fastpixgo.String("your-access-key"),
Password: fastpixgo.String("your-secret-key"),
}),
)
// Create media from URL
videoInput := components.VideoInput{
Type: "video",
URL: "https://example.com/video.mp4",
}
input := components.CreateInputVideoInput(videoInput)
request := &components.CreateMediaRequest{
Inputs: []components.Input{input},
Metadata: &components.CreateMediaRequestMetadata{
Title: fastpixgo.String("My Video Title"),
Description: fastpixgo.String("Video description here"),
},
AccessPolicy: components.CreateMediaRequestAccessPolicyPublic,
MaxResolution: components.CreateMediaRequestMaxResolution("1080p").ToPointer(),
}
response, err := sdk.InputVideo.CreateMedia(ctx, request)
if err != nil {
log.Fatalf("Failed to create media: %v", err)
}
if response.Object != nil && response.Object.Data != nil {
log.Printf("Media created successfully!")
log.Printf("Media ID: %s", *response.Object.Data.ID)
log.Printf("Status: %s", *response.Object.Data.Status)
}
}
1.2 Upload Media from Device
This endpoint enables you to upload a video file directly from your local device to FastPix for processing and storage. When you invoke this API with your preferred media settings, the response returns an uploadId and a pre-signed URL, providing a streamlined experience for uploading.
Use the DirectUploadVideoMedia()
method to upload media directly from a device or file system.
For more details refer to Upload Media From Device API documentation.
package main
import (
"context"
"log"
fastpixgo "github.com/FastPix/fastpix-go"
"github.com/FastPix/fastpix-go/models/components"
"github.com/FastPix/fastpix-go/models/operations"
)
func main() {
ctx := context.Background()
// Upload media directly from device
request := &operations.DirectUploadVideoMediaRequest{
CorsOrigin: fastpixgo.String("*"),
PushMediaSettings: &operations.PushMediaSettings{
AccessPolicy: operations.DirectUploadVideoMediaAccessPolicyPublic,
MaxResolution: operations.MaxResolution("1080p").ToPointer(),
},
}
response, err := sdk.InputVideo.DirectUploadVideoMedia(ctx, request)
if err != nil {
log.Fatalf("Failed to get upload URL: %v", err)
}
if response.Object != nil && response.Object.Data != nil {
log.Printf("Media uploaded successfully!")
log.Printf("Upload ID: %s", *response.Object.Data.ID)
log.Printf("Upload URL: %s", *response.Object.Data.URL)
}
}
1.4 Get Media by ID
By calling this endpoint, you can retrieve detailed information about a specific media item, including its current status and a playbackId. This is particularly useful for retrieving specific media details when managing large content libraries.
Use the GetMedia()
method to retrieve details of a specific media file using its media ID.
For more details refer to Get Media by ID API documentation.
package main
import (
"context"
"log"
fastpixgo "github.com/FastPix/fastpix-go"
"github.com/FastPix/fastpix-go/models/operations"
)
func main() {
ctx := context.Background()
mediaID := "your-media-id"
response, err := sdk.ManageVideos.GetMedia(ctx, &operations.GetMediaRequest{
MediaID: mediaID,
})
if err != nil {
log.Fatalf("Failed to get media: %v", err)
}
if response.GetMediaResponse != nil && response.GetMediaResponse.Data != nil {
media := response.GetMediaResponse.Data
log.Printf("Title: %s", *media.Title)
log.Printf("Duration: %f", *media.Duration)
log.Printf("Status: %s", *media.Status)
log.Printf("Created At: %s", *media.CreatedAt)
}
}
1.5 Update Media
This endpoint allows you to update specific parameters of an existing media file. You can modify the key-value pairs of the metadata that were provided in the payload during the creation of media from a URL or when uploading the media as a file object.
Use the UpdatedMedia()
method to update metadata or settings for a specific media file.
For more details refer to Update Media API documentation.
package main
import (
"context"
"log"
fastpixgo "github.com/FastPix/fastpix-go"
"github.com/FastPix/fastpix-go/models/operations"
)
func main() {
ctx := context.Background()
mediaID := "your-media-id"
request := &operations.UpdatedMediaRequest{
MediaID: mediaID,
RequestBody: &operations.UpdatedMediaRequestBody{
Metadata: map[string]interface{}{
"title": "Updated Title",
"description": "Updated description",
},
},
}
response, err := sdk.ManageVideos.UpdatedMedia(ctx, request)
if err != nil {
log.Fatalf("Failed to update media: %v", err)
}
if response.UpdatedMediaResponse != nil && response.UpdatedMediaResponse.Data != nil {
log.Printf("Media updated successfully!")
}
}
1.6 Delete Media
This endpoint allows you to permanently delete a specific video or audio media file along with all associated data. If you wish to remove a media file from FastPix storage, use this endpoint with the mediaId (either uploadId or id) received during the media’s creation or upload.
Use the DeleteMedia()
method to remove a media file from your account.
For more details refer to Delete Media API documentation.
package main
import (
"context"
"log"
fastpixgo "github.com/FastPix/fastpix-go"
"github.com/FastPix/fastpix-go/models/operations"
)
func main() {
ctx := context.Background()
mediaID := "your-media-id"
request := &operations.DeleteMediaRequest{
MediaID: mediaID,
}
_, err := sdk.ManageVideos.DeleteMedia(ctx, request)
if err != nil {
log.Fatalf("Failed to delete media: %v", err)
}
log.Printf("Media deleted successfully!")
}
1.7 Create Media Playback ID
You can create a new playback ID for a specific media asset. If you have already retrieved an existing playbackId using the “Get Media by ID” endpoint for a media asset, you can use this endpoint to generate a new playback ID with a specified access policy.
Use the CreateMediaPlaybackID()
method to generate a playback ID for a media file.
For more details refer to Create Media Playback ID API documentation.
package main
import (
"context"
"log"
fastpixgo "github.com/FastPix/fastpix-go"
"github.com/FastPix/fastpix-go/models/operations"
)
func main() {
ctx := context.Background()
mediaID := "your-media-id"
request := &operations.CreateMediaPlaybackIDRequest{
MediaID: mediaID,
RequestBody: &operations.CreateMediaPlaybackIDRequestBody{
AccessPolicy: operations.CreateMediaPlaybackIDAccessPolicyPublic.ToPointer(),
},
}
response, err := sdk.Playback.CreateMediaPlaybackID(ctx, request)
if err != nil {
log.Fatalf("Failed to create playback ID: %v", err)
}
if response.CreateMediaPlaybackIDResponse != nil && response.CreateMediaPlaybackIDResponse.Data != nil {
log.Printf("Playback ID: %s", *response.CreateMediaPlaybackIDResponse.Data.ID)
log.Printf("Playback URL: https://stream.fastpix.io/%s.m3u8", *response.CreateMediaPlaybackIDResponse.Data.ID)
}
}
1.8 Delete Media Playback ID
This endpoint allows you to remove a specific playback ID associated with a media asset. Deleting a playbackId will revoke access to the media content linked to that ID.
Use the DeleteMediaPlaybackID()
method to remove a playback ID for a media file.
For more details refer to Delete Media Playback ID API documentation.
package main
import (
"context"
"log"
fastpixgo "github.com/FastPix/fastpix-go"
"github.com/FastPix/fastpix-go/models/operations"
)
func main() {
ctx := context.Background()
mediaID := "your-media-id"
playbackID := "your-playback-id"
request := &operations.DeleteMediaPlaybackIDRequest{
MediaID: mediaID,
PlaybackID: playbackID,
}
_, err := sdk.Playback.DeleteMediaPlaybackID(ctx, request)
if err != nil {
log.Fatalf("Failed to delete playback ID: %v", err)
}
log.Printf("Playback ID deleted successfully!")
}
Live Stream Operations
2.1 Create Live Stream
This endpoint allows you to create a new live stream with specified settings. You can configure various parameters such as the stream key, recording settings, and playback options to customize the live streaming experience according to your requirements.
Use the CreateNewStream()
method to create a new live stream with your desired configuration.
For more details refer to Create Live Stream API documentation.
package main
import (
"context"
"log"
fastpixgo "github.com/FastPix/fastpix-go"
"github.com/FastPix/fastpix-go/models/components"
)
func main() {
ctx := context.Background()
// Initialize SDK for live stream operations
sdk := fastpixgo.New(
fastpixgo.WithServerURL("https://api.fastpix.io/v1/live"),
fastpixgo.WithSecurity(components.Security{
Username: fastpixgo.String("your-access-key"),
Password: fastpixgo.String("your-secret-key"),
}),
)
// Create a new live stream
reconnectWindow := int64(60)
request := &components.CreateLiveStreamRequest{
PlaybackSettings: components.PlaybackSettings{},
InputMediaSettings: components.InputMediaSettings{
Metadata: &components.CreateLiveStreamRequestMetadata{
Title: fastpixgo.String("My Live Stream"),
Description: fastpixgo.String("This is my live stream description"),
},
ReconnectWindow: &reconnectWindow,
MediaPolicy: components.MediaPolicyPublic.ToPointer(),
Dvr: fastpixgo.Bool(true), // Enable DVR mode
},
}
response, err := sdk.StartLiveStream.CreateNewStream(ctx, request)
if err != nil {
log.Fatalf("Failed to create live stream: %v", err)
}
if response.LiveStreamResponseDTO != nil && response.LiveStreamResponseDTO.Data != nil {
log.Printf("Live stream created successfully!")
log.Printf("Stream ID: %s", *response.LiveStreamResponseDTO.Data.StreamID)
log.Printf("Stream Key: %s", *response.LiveStreamResponseDTO.Data.StreamKey)
log.Printf("RTMP URL: %s", *response.LiveStreamResponseDTO.Data.RtmpURL)
}
}
2.2 List All Live Streams
This endpoint returns a comprehensive list of all live streams within your organization. It provides detailed information about each stream, including their current status, creation date, and configuration settings, making it easy to manage and monitor your live streaming activities.
Use the GetAllStreams()
method to retrieve a list of all live streams in your account.
For more details refer to List All Live Streams API documentation.
package main
import (
"context"
"log"
fastpixgo "github.com/FastPix/fastpix-go"
"github.com/FastPix/fastpix-go/models/operations"
)
func main() {
ctx := context.Background()
response, err := sdk.ManageLiveStream.GetAllStreams(ctx, &operations.GetAllStreamsRequest{
Limit: fastpixgo.String("20"),
Offset: fastpixgo.String("1"),
OrderBy: operations.GetAllStreamsOrderByDesc.ToPointer(),
})
if err != nil {
log.Fatalf("Failed to get streams: %v", err)
}
if response.GetStreamsResponse != nil && response.GetStreamsResponse.Data != nil {
for _, stream := range response.GetStreamsResponse.Data {
log.Printf("Stream ID: %s", *stream.StreamID)
log.Printf("Title: %s", *stream.Title)
log.Printf("Status: %s", *stream.Status)
log.Printf("Created At: %s", *stream.CreatedAt)
}
}
}
2.3 Get Live Stream by ID
This endpoint allows you to retrieve detailed information about a specific live stream using its unique identifier. It returns comprehensive data including the stream’s current status, configuration settings, and associated metadata, providing you with complete visibility into the stream’s properties and state.
Use the GetLiveStreamByID()
method to retrieve details of a specific live stream using its stream ID.
For more details refer to Get Live Stream by ID API documentation.
package main
import (
"context"
"log"
fastpixgo "github.com/FastPix/fastpix-go"
"github.com/FastPix/fastpix-go/models/operations"
)
func main() {
ctx := context.Background()
streamID := "your-stream-id"
request := &operations.GetLiveStreamByIDRequest{
StreamID: streamID,
}
response, err := sdk.ManageLiveStream.GetLiveStreamByID(ctx, request)
if err != nil {
log.Fatalf("Failed to get live stream: %v", err)
}
if response.LivestreamgetResponse != nil && response.LivestreamgetResponse.Data != nil {
stream := response.LivestreamgetResponse.Data
log.Printf("Title: %s", *stream.Title)
log.Printf("Status: %s", *stream.Status)
log.Printf("Stream Key: %s", *stream.StreamKey)
log.Printf("RTMP URL: %s", *stream.RtmpURL)
}
}
2.4 Update Live Stream
This endpoint enables you to modify the configuration and settings of an existing live stream. You can update various parameters such as the stream name, recording preferences, and other configuration options to adapt the stream to changing requirements or preferences.
Use the UpdateLiveStream()
method to update settings for a specific live stream.
For more details refer to Update Live Stream API documentation.
package main
import (
"context"
"log"
fastpixgo "github.com/FastPix/fastpix-go"
"github.com/FastPix/fastpix-go/models/operations"
)
func main() {
ctx := context.Background()
streamID := "your-stream-id"
request := &operations.UpdateLiveStreamRequest{
StreamID: streamID,
RequestBody: &operations.UpdateLiveStreamRequestBody{
Metadata: &operations.PatchLiveStreamRequest{
Title: fastpixgo.String("Updated Stream Name"),
Description: fastpixgo.String("Updated stream description"),
},
},
}
response, err := sdk.ManageLiveStream.UpdateLiveStream(ctx, request)
if err != nil {
log.Fatalf("Failed to update live stream: %v", err)
}
if response.UpdateLiveStreamResponse != nil && response.UpdateLiveStreamResponse.Data != nil {
log.Printf("Live stream updated successfully!")
}
}
2.5 Delete Live Stream
This endpoint allows you to permanently remove a specific live stream and all its associated data from the FastPix platform. When you delete a live stream, it will be completely removed from your account, including any recordings or metadata associated with it.
Use the DeleteLiveStream()
method to remove a live stream from your account.
For more details refer to Delete Live Stream API documentation.
package main
import (
"context"
"log"
fastpixgo "github.com/FastPix/fastpix-go"
"github.com/FastPix/fastpix-go/models/operations"
)
func main() {
ctx := context.Background()
streamID := "your-stream-id"
request := &operations.DeleteLiveStreamRequest{
StreamID: streamID,
}
_, err := sdk.ManageLiveStream.DeleteLiveStream(ctx, request)
if err != nil {
log.Fatalf("Failed to delete live stream: %v", err)
}
log.Printf("Live stream deleted successfully!")
}
2.6 Create Live Stream Playback ID
This endpoint enables you to generate a new playback ID for a specific live stream. The playback ID provides a secure and controlled way to access the live stream content, allowing you to implement custom access policies and restrictions for your live streaming content.
Use the CreatePlaybackIDOfStream()
method to generate a playback ID for a live stream.
For more details refer to Create Live Stream Playback ID API documentation.
package main
import (
"context"
"log"
fastpixgo "github.com/FastPix/fastpix-go"
"github.com/FastPix/fastpix-go/models/operations"
)
func main() {
ctx := context.Background()
streamID := "your-stream-id"
request := &operations.CreatePlaybackIDOfStreamRequest{
StreamID: streamID,
RequestBody: &operations.CreatePlaybackIDOfStreamRequestBody{
AccessPolicy: operations.PlaybackIDRequestAccessPolicyPublic.ToPointer(),
},
}
response, err := sdk.Playback.CreatePlaybackIDOfStream(ctx, request)
if err != nil {
log.Fatalf("Failed to create playback ID: %v", err)
}
if response.PlaybackIDResponse != nil && response.PlaybackIDResponse.Data != nil {
log.Printf("Playback ID: %s", *response.PlaybackIDResponse.Data.ID)
log.Printf("Playback URL: https://stream.fastpix.io/%s.m3u8", *response.PlaybackIDResponse.Data.ID)
}
}
2.7 Delete Live Stream Playback ID
This endpoint allows you to remove a specific playback ID associated with a live stream. Deleting a playback ID will revoke access to the live stream content linked to that ID, providing you with control over who can access your live streaming content.
Use the DeletePlaybackIDOfStream()
method to remove a playback ID for a live stream.
For more details refer to Delete Live Stream Playback ID API documentation.
package main
import (
"context"
"log"
fastpixgo "github.com/FastPix/fastpix-go"
"github.com/FastPix/fastpix-go/models/operations"
)
func main() {
ctx := context.Background()
streamID := "your-stream-id"
playbackID := "your-playback-id"
request := &operations.DeletePlaybackIDOfStreamRequest{
StreamID: streamID,
PlaybackID: playbackID,
}
_, err := sdk.Playback.DeletePlaybackIDOfStream(ctx, request)
if err != nil {
log.Fatalf("Failed to delete playback ID: %v", err)
}
log.Printf("Live stream playback ID deleted successfully!")
}
2.8 Get Live Stream Playback ID
Retrieves details about a previously created playback ID. If you provide the distinct playback ID that was given back to you in the previous stream or playbackId create request, FastPix will provide the relevant playback details such as the access policy.
Use the GetLiveStreamPlaybackID()
method to retrieve the playback policy for a specific live stream playback ID.
For more details refer to Get Live Stream Playback ID API documentation.
package main
import (
"context"
"log"
fastpixgo "github.com/FastPix/fastpix-go"
"github.com/FastPix/fastpix-go/models/operations"
)
func main() {
ctx := context.Background()
streamID := "your-stream-id"
playbackID := "your-playback-id"
request := &operations.GetLiveStreamPlaybackIDRequest{
StreamID: streamID,
PlaybackID: playbackID,
}
response, err := sdk.Playback.GetLiveStreamPlaybackID(ctx, request)
if err != nil {
log.Fatalf("Failed to get playback ID: %v", err)
}
if response.PlaybackIDResponse != nil && response.PlaybackIDResponse.Data != nil {
log.Printf("Playback Policy: %s", *response.PlaybackIDResponse.Data.AccessPolicy)
}
}
2.9 Create Simulcast
Lets you to create a simulcast for a parent live stream. A simulcast enables you to broadcast the live stream to multiple platforms simultaneously (e.g., YouTube, Facebook, or Twitch). This feature is useful for expanding your audience reach across different platforms. However, a simulcast can only be created when the parent live stream is in an idle state (i.e., not currently live or disabled). Additionally, only one simulcast target can be created per API call.
Use the CreateSimulcastOfStream()
method to create a new simulcast for a live stream.
For more details refer to Create Simulcast API documentation.
package main
import (
"context"
"log"
fastpixgo "github.com/FastPix/fastpix-go"
"github.com/FastPix/fastpix-go/models/operations"
)
func main() {
ctx := context.Background()
streamID := "your-stream-id"
request := &operations.CreateSimulcastOfStreamRequest{
StreamID: streamID,
RequestBody: &operations.CreateSimulcastOfStreamRequestBody{
Platform: operations.SimulcastRequestPlatformYoutube.ToPointer(),
Credentials: &operations.SimulcastRequestCredentials{
StreamKey: fastpixgo.String("your-youtube-stream-key"),
},
},
}
response, err := sdk.SimulcastStream.CreateSimulcastOfStream(ctx, request)
if err != nil {
log.Fatalf("Failed to create simulcast: %v", err)
}
if response.SimulcastResponse != nil && response.SimulcastResponse.Data != nil {
log.Printf("Simulcast created successfully!")
log.Printf("Simulcast ID: %s", *response.SimulcastResponse.Data.ID)
}
}
2.10 Get Simulcast Details
Retrieves the details of a specific simulcast associated with a parent live stream. By providing both the streamId of the parent stream and the simulcastId, FastPix returns detailed information about the simulcast, such as the stream URL, the status of the simulcast (active or idle), and metadata.
Use the GetSpecificSimulcastOfStream()
method to retrieve details of a specific simulcast for a live stream.
For more details refer to Get Simulcast Details API documentation.
package main
import (
"context"
"log"
fastpixgo "github.com/FastPix/fastpix-go"
"github.com/FastPix/fastpix-go/models/operations"
)
func main() {
ctx := context.Background()
streamID := "your-stream-id"
simulcastID := "your-simulcast-id"
request := &operations.GetSpecificSimulcastOfStreamRequest{
StreamID: streamID,
SimulcastID: simulcastID,
}
response, err := sdk.SimulcastStream.GetSpecificSimulcastOfStream(ctx, request)
if err != nil {
log.Fatalf("Failed to get simulcast: %v", err)
}
if response.SimulcastResponse != nil && response.SimulcastResponse.Data != nil {
simulcast := response.SimulcastResponse.Data
log.Printf("Simulcast ID: %s", *simulcast.ID)
log.Printf("Platform: %s", *simulcast.Platform)
log.Printf("Status: %s", *simulcast.Status)
}
}
2.11 Update Simulcast
Allows you to enable or disable a specific simulcast associated with a parent live stream. The status of the simulcast can be updated at any point, whether the live stream is active or idle. However, once the live stream is disabled, the simulcast can no longer be modified.
Use the UpdateSpecificSimulcastOfStream()
method to modify the configuration of a simulcast stream.
For more details refer to Update Simulcast API documentation.
package main
import (
"context"
"log"
fastpixgo "github.com/FastPix/fastpix-go"
"github.com/FastPix/fastpix-go/models/operations"
)
func main() {
ctx := context.Background()
streamID := "your-stream-id"
simulcastID := "your-simulcast-id"
request := &operations.UpdateSpecificSimulcastOfStreamRequest{
StreamID: streamID,
SimulcastID: simulcastID,
RequestBody: &operations.UpdateSpecificSimulcastOfStreamRequestBody{
Status: operations.SimulcastUpdateRequestStatusIdle.ToPointer(),
},
}
response, err := sdk.SimulcastStream.UpdateSpecificSimulcastOfStream(ctx, request)
if err != nil {
log.Fatalf("Failed to update simulcast: %v", err)
}
if response.SimulcastResponse != nil && response.SimulcastResponse.Data != nil {
log.Printf("Simulcast updated successfully!")
}
}
2.12 Delete Simulcast
Allows you to delete a simulcast using its unique simulcastId, which was returned during the simulcast creation process. Deleting a simulcast stops the broadcast to the associated platform, but the parent stream will continue to run if it is live. This action is irreversible, and a new simulcast would need to be created if you want to resume streaming to the same platform.
Use the DeleteSimulcastOfStream()
method to remove a specific simulcast from a live stream.
For more details refer to Delete Simulcast API documentation.
package main
import (
"context"
"log"
fastpixgo "github.com/FastPix/fastpix-go"
"github.com/FastPix/fastpix-go/models/operations"
)
func main() {
ctx := context.Background()
streamID := "your-stream-id"
simulcastID := "your-simulcast-id"
request := &operations.DeleteSimulcastOfStreamRequest{
StreamID: streamID,
SimulcastID: simulcastID,
}
_, err := sdk.SimulcastStream.DeleteSimulcastOfStream(ctx, request)
if err != nil {
log.Fatalf("Failed to delete simulcast: %v", err)
}
log.Printf("Simulcast deleted successfully!")
}
Error Handling
Handling errors in this SDK should largely match your expectations. All operations return a response object or an error.
By default, an API error will return an apierrors.APIError error, which has the following properties:
Property | Type | Description |
---|---|---|
Message | string | The error message |
StatusCode | int | The HTTP status code |
RawResponse | http.Response | The raw HTTP response |
Body | string | The response content |
Example Error Handling
package main
import (
"context"
"log"
fastpixgo "github.com/FastPix/fastpix-go"
"github.com/FastPix/fastpix-go/models/components"
"github.com/FastPix/fastpix-go/models/apierrors"
)
func main() {
ctx := context.Background()
sdk := fastpixgo.New(
fastpixgo.WithSecurity(components.Security{
Username: fastpixgo.String("your-access-key"),
Password: fastpixgo.String("your-secret-key"),
}),
)
request := &components.CreateLiveStreamRequest{
PlaybackSettings: components.PlaybackSettings{},
InputMediaSettings: components.InputMediaSettings{
Metadata: &components.CreateLiveStreamRequestMetadata{},
},
}
response, err := sdk.StartLiveStream.CreateNewStream(ctx, request)
if err != nil {
switch e := err.(type) {
case *apierrors.UnauthorizedError:
log.Printf("Authentication failed: %s", e.Message)
case *apierrors.ValidationErrorResponse:
log.Printf("Validation error: %s", e.Message)
case *apierrors.APIError:
log.Printf("API error: %s", e.Message)
default:
log.Printf("Unexpected error: %v", err)
}
return
}
if response.LiveStreamResponseDTO != nil && response.LiveStreamResponseDTO.Data != nil {
log.Printf("Stream created: %s", *response.LiveStreamResponseDTO.Data.StreamID)
}
}
Support & Resources
Getting Help
- Documentation: Visit the FastPix API Reference for detailed API documentation
- GitHub Issues: Report bugs or request features on the GitHub repository
Additional Resources
- SDK Repository:
- API Documentation: https://docs.fastpix.io/reference
- FastPix Platform: https://dashboard.fastpix.io/
SDK Maturity
This SDK is currently in beta. While it’s production-ready, there may be breaking changes between versions without a major version update. We recommend:
- Pinning to specific versions for production applications
- Testing thoroughly before deploying updates
- Monitoring the changelog for any breaking changes
Updated 11 days ago