Skip to content

Go SDK simplifies integration with the FastPix platform. This SDK is designed for secure and efficient communication with the FastPix API, enabling easy management of media uploads, live streaming, and simulcasting

License

Notifications You must be signed in to change notification settings

FastPix/fastpix-go

Repository files navigation

FastPix Go SDK

Homepage

Developer-friendly & type-safe Go SDK specifically designed to leverage the FastPix platform API.

Introduction

The FastPix Go SDK simplifies integration with the FastPix platform. This SDK is designed for secure and efficient communication with the FastPix API, enabling easy management of media uploads, live streaming, and simulcasting.

Key Features

  • Media API
    • Upload Media: Upload media files seamlessly from URLs or devices
    • Manage Media: List, fetch, update, and delete media assets
    • Playback IDs: Generate and manage playback IDs for media access
  • Live API
    • Create & Manage Live Streams: Create, list, update, and delete live streams
    • Control Stream Access: Generate playback IDs for live streams to control and manage access
    • Simulcast to Multiple Platforms: Stream content to multiple platforms simultaneously

For detailed usage, refer to the FastPix API Reference.

Prerequisites

  • Go 1.20 or later
  • FastPix API credentials (Username and Password)

Getting Started with FastPix

To get started with the FastPix Go SDK, ensure you have the following:

  • FastPix APIs are authenticated using a Username and Password (HTTP Basic Auth). You must generate these credentials to use the SDK.
  • Follow the steps in the Authentication section to obtain your credentials.

Table of Contents

SDK Installation

go get github.com/FastPix/fastpix-go@v0.1.0

Initialization

You can set the security parameters using the WithSecurity option when initializing the SDK client instance. For example:

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.WithSecurity(components.Security{
			Username: fastpixgo.String("your-username"),
			Password: fastpixgo.String("your-password"),
		}),
	)
	// Use sdk...
}

SDK Example Usage

package main

import (
	"context"
	fastpixgo "github.com/FastPix/fastpix-go"
	"github.com/FastPix/fastpix-go/models/components"
	"log"
)

func main() {
	ctx := context.Background()

	s := fastpixgo.New(
		fastpixgo.WithSecurity(components.Security{
			Username: fastpixgo.String(""),
			Password: fastpixgo.String(""),
		}),
	)

	res, err := s.StartLiveStream.CreateNewStream(ctx, &components.CreateLiveStreamRequest{
		PlaybackSettings: components.PlaybackSettings{},
		InputMediaSettings: components.InputMediaSettings{
			Metadata: &components.CreateLiveStreamRequestMetadata{},
		},
	})
	if err != nil {
		log.Fatal(err)
	}
	if res.LiveStreamResponseDTO != nil {
		// handle response
	}
}

Available Resources and Operations

InputVideo

ManageLiveStream

ManageVideos

Playback

SimulcastStream

StartLiveStream

Error Handling

All operations return a response object or an error. By default, an API error will return an apierrors.APIError. When custom error responses are specified for an operation, the SDK may also return their associated error. You can refer to the respective Errors tables in the SDK docs for more details on possible error types for each operation.

For example, the CreateNewStream function may return the following errors:

Error Type Status Code Content Type
apierrors.UnauthorizedError 401 application/json
apierrors.InvalidPermissionError 403 application/json
apierrors.ValidationErrorResponse 422 application/json
apierrors.APIError 4XX, 5XX /

Server Selection

The default server can be overridden globally using the WithServerURL(serverURL string) option when initializing the SDK client instance. For example:

sdk := fastpixgo.New(
	fastpixgo.WithServerURL("https://api.fastpix.io/v1/on-demand"),
	fastpixgo.WithSecurity(components.Security{
		Username: fastpixgo.String("your-username"),
		Password: fastpixgo.String("your-password"),
	}),
)

Development

Maturity

This SDK is currently in beta, and breaking changes may occur between versions even without a major version update. To avoid unexpected issues, we recommend pinning your dependency to a specific version. This ensures consistent behavior unless you intentionally update to a newer release.

Detailed Usage

For a complete understanding of each API's functionality, including request and response details, parameter descriptions, and additional examples, please refer to the FastPix API Reference.

About

Go SDK simplifies integration with the FastPix platform. This SDK is designed for secure and efficient communication with the FastPix API, enabling easy management of media uploads, live streaming, and simulcasting

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages