Developer-friendly & type-safe C# SDK specifically designed to leverage the FastPix platform API.
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.
-
- 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
-
- 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.
To add a reference to a local instance of the SDK in a .NET project:
dotnet add reference src/Fastpix/Fastpix.csproj
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
- CreateMedia - Create media from URL
- DirectUploadVideoMedia - Upload media from device
- GetAllStreams - Get all live streams
- GetLiveStreamById - Get stream by ID
- DeleteLiveStream - Delete a stream
- UpdateLiveStream - Update a stream
- ListMedia - Get list of all media
- GetMedia - Get a media by ID
- UpdatedMedia - Update a media by ID
- DeleteMedia - Delete a media by ID
- RetrieveMediaInputInfo - Get info of media inputs
- CreatePlaybackIdOfStream - Create a playbackId
- DeletePlaybackIdOfStream - Delete a playbackId
- GetLiveStreamPlaybackId - Get stream's playbackId
- CreateMediaPlaybackId - Create a playback ID
- DeleteMediaPlaybackId - Delete a playback ID
- CreateSimulcastOfStream - Create a simulcast
- DeleteSimulcastOfStream - Delete a simulcast
- GetSpecificSimulcastOfStream - Get a specific simulcast of a stream
- UpdateSpecificSimulcastOfStream - Update a specific simulcast of a stream
- CreateNewStream - Create a new stream
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 | */* |
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;
}
}
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
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.