Skip to content

FastPix C# SDK offers a secure, high-performance interface to the FastPix API—simplifying media uploads, live streaming, and simulcasting.

License

Notifications You must be signed in to change notification settings

FastPix/fastpix-sdk-csharp

Repository files navigation

FastPix C# SDK

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

Introduction

The FastPix C# 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: Perform operations such as listing, fetching, updating, and deleting 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 effortlessly
    • 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.

SDK Installation

To add a reference to a local instance of the SDK in a .NET project:

dotnet add reference src/Fastpix/Fastpix.csproj

SDK Example Usage

Example

using Fastpix;
using Fastpix.Models.Components;

var sdk = new FastPix(security: new Security() {
    username("your-access-token-id")
    password("your-secret-key")
});

CreateLiveStreamRequest req = new CreateLiveStreamRequest() {
    PlaybackSettings = new PlaybackSettings() {},
    InputMediaSettings = new InputMediaSettings() {
        Metadata = new CreateLiveStreamRequestMetadata() {},
    },
};

var res = await sdk.StartLiveStream.CreateNewStreamAsync(req);

// handle response

Available Resources and Operations

Error Handling

Handling errors in this SDK should largely match your expectations. All operations return a response object or throw an exception.

By default, an API error will raise a Fastpix.Models.Errors.APIException exception, which has the following properties:

Property Type Description
Message string The error message
Request HttpRequestMessage The HTTP request
Response HttpResponseMessage The HTTP response

When custom error responses are specified for an operation, the SDK may also throw their associated exceptions. You can refer to respective Errors tables in SDK docs for more details on possible exception types for each operation. For example, the CreateNewStreamAsync method throws the following exceptions:

Error Type Status Code Content Type
Fastpix.Models.Errors.UnauthorizedException 401 application/json
Fastpix.Models.Errors.InvalidPermissionException 403 application/json
Fastpix.Models.Errors.ValidationErrorResponse 422 application/json
Fastpix.Models.Errors.APIException 4XX, 5XX */*

Example

using Fastpix;
using Fastpix.Models.Components;
using Fastpix.Models.Errors;

var sdk = new FastPix(security: new Security() {
    Username = "your-access-token-id",
    Password = "your-secret-key",
});

try
{
    CreateLiveStreamRequest req = new CreateLiveStreamRequest() {
        PlaybackSettings = new PlaybackSettings() {},
        InputMediaSettings = new InputMediaSettings() {
            Metadata = new CreateLiveStreamRequestMetadata() {},
        },
    };

    var res = await sdk.StartLiveStream.CreateNewStreamAsync(req);

    // handle response
}
catch (Exception ex)
{
    if (ex is UnauthorizedException)
    {
        // Handle exception data
        throw;
    }
    else if (ex is InvalidPermissionException)
    {
        // Handle exception data
        throw;
    }
    else if (ex is ValidationErrorResponse)
    {
        // Handle exception data
        throw;
    }
    else if (ex is Fastpix.Models.Errors.APIException)
    {
        // Handle default exception
        throw;
    }
}

Server Selection

Override Server URL Per-Client

The default server can be overridden globally by passing a URL to the serverUrl: string optional parameter when initializing the SDK client instance. For example:

using Fastpix;
using Fastpix.Models.Components;

var sdk = new FastPix(
    serverUrl: "https://v1.fastpix.io/live",
    security: new Security() {
        Username = "your-access-token-id",
        Password = "your-secret-key",
    }
);

CreateLiveStreamRequest req = new CreateLiveStreamRequest() {
    PlaybackSettings = new PlaybackSettings() {},
    InputMediaSettings = new InputMediaSettings() {
        Metadata = new CreateLiveStreamRequestMetadata() {},
    },
};

var res = await sdk.StartLiveStream.CreateNewStreamAsync(req);

// handle response

Development

Maturity

This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.

About

FastPix C# SDK offers a secure, high-performance interface to the FastPix API—simplifying media uploads, live streaming, and simulcasting.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages