FastPix Unity SDK
The FastPix Unity SDK enables seamless integration of the FastPix platform into your Unity projects. Designed with Unity developers in mind, it provides a type-safe and intuitive interface for secure and efficient interaction with the FastPix API. With this SDK, you can easily manage media uploads, live streams, on-demand content, playlists, video analytics, and signing keys for secure access and token management—all directly from your Unity environment.
Prerequisites
Import the SDK
Available Resources and Operations
Server selection
Error Handling
Server Selection
Let’s talk features:
Media API
- Upload Media: Easily upload media files from local devices or external URLs.
- Manage Media: List, retrieve, update, and delete media assets with minimal effort.
- Playback IDs: Create and manage playback IDs for flexible, secure access to your content.
- Advanced Media Tools: Generate video summaries, chapters, named entities, subtitles, and run content moderation.
- Playlist Management: Build and manage playlists, add or remove media, and control playback order.
- DRM Support: Configure and manage Digital Rights Management for secure content protection.
Live API
- Create & Manage Live Streams: Quickly create, update, list, and delete live streams.
- Access Control: Use playback IDs to securely manage viewer access.
- Stream Controls: Enable, disable, or end streams with precise control.
- Simulcast Support: Stream to multiple platforms simultaneously for wider reach.
Signing Keys
- Generate Signing Keys: Create keys to enable secure, token-based access.
- Retrieve & Manage Keys: List, fetch details, and manage individual signing keys.
- Access Control Maintenance: Delete or revoke keys to maintain security and control.
Video Data API
- View & Analytics: Track video views, retrieve detailed view data, and identify top-performing content.
- Concurrent Viewers: Access time-series insights for both live and on-demand streams.
- Custom Reporting: Filter by dimensions, generate breakdowns, and compare datasets for deeper insights.
- Error Diagnostics: Retrieve logs and monitor errors to ensure reliability and performance.
For complete usage instructions, see the FastPix API Reference.
Prerequisites
Before you start using the FastPix Node.js SDK, make sure you have the following:
- To authenticate with the FastPix APIs, you'll need an Access Token and a Secret Key. You can generate these credentials by following the steps in the Authentication with Access Tokens guide.
Installation:
The FastPix Unity SDK can be integrated into your project in two ways:
- Using a compiled DLL: Compile the SDK using dotnet build, then copy the resultant .dll file into your Unity project's Assets folder.
- Using source code: Copy the SDK source code directly into your Unity project.
Dependencies:
The SDK relies on Newtonsoft's JSON.NET package for JSON serialization and deserialization. To install it via the Unity Package Manager:
- Open the Package Manager via Window > Package Manager.
- Click the + button and select Add package from git URL...
- Enter the following URL: com.unity.nuget.newtonsoft-json
- Click Add to install the package.
Once installed, your Unity project is ready to use the FastPix Unity SDK.
Import and Initialize the SDK
using fastpix.io;
using fastpix.io.Models.Components;
using System.Collections.Generic;
using System.Threading.Tasks;
// Initialize FastPix Unity SDK with AccessToken and SecretKey
var sdk = new Fastpix(
security: new Security
{
Username = "your-access-token",
Password = "secret-key"
}
);
Example Usage:
using fastpix.io;
using fastpix.io.Models.Components;
using System.Collections.Generic;
// Initialize FastPix Unity SDK with AccessToken and SecretKey
var sdk = new Fastpix(
security: new Security
{
Username = "your-access-token",
Password = "secret-key"
}
);
var req = new CreateMediaRequest
{
Inputs = new List<Input>
{
Input.CreateVideoInput(
new VideoInput
{
Type = "video",
Url = "https://static.fastpix.io/sample.mp4"
}
)
},
Metadata = new Dictionary<string, string>
{
{ "key1", "value1" }
},
AccessPolicy = CreateMediaRequestAccessPolicy.Public,
MaxResolution = CreateMediaRequestMaxResolution.OneThousandAndEightyp
};
using (var res = await sdk.InputVideo.CreateMediaAsync(req))
{
// Handle response here
}
Available Resources and Operations
The FastPix SDK provides resources and methods to manage media workflows, live streaming, analytics, DRM, and secure access.
Below, resources are categorized by their primary use for easier navigation.
1.Video On-Demand
Resources for uploading, managing, and enhancing on-demand videos.
Input Video
Upload and create media assets from URLs or local files.
Method | Description | HTTP request |
---|---|---|
CreateMedia | Create media from a remote URL | POST /on-demand |
DirectUploadVideoMedia | Upload video directly from your device | POST /on-demand/upload |
In-Video AI Features
Enhance videos with AI-powered analysis.
Method | Description | HTTP request |
---|---|---|
UpdateMediaSummary | Generate video summary | PATCH /on-demand/{mediaId}/summary |
UpdateMediaChapters | Generate video chapters | PATCH /on-demand/{mediaId}/chapters |
UpdateMediaNamedEntities | Generate named entities | PATCH /on-demand/{mediaId}/named-entities |
UpdateMediaModeration | Enable video moderation | PATCH /on-demand/{mediaId}/moderation |
Manage Videos
Full lifecycle management of uploaded media.
Media Management APIs
Method | Description | HTTP request |
---|---|---|
ListMedia | Get list of all media | GET /on-demand |
ListLiveClips | Get all clips of a live stream | GET /on-demand/{livestreamId}/live-clips |
GetMedia | Get a media by ID | GET /on-demand/{mediaId} |
UpdatedMedia | Update a media by ID | PATCH /on-demand/{mediaId} |
DeleteMedia | Delete a media by ID | DELETE /on-demand/{mediaId} |
AddMediaTrack | Add audio / subtitle track | POST /on-demand/{mediaId}/tracks |
CancelUpload | Cancel ongoing upload | POST /on-demand/{mediaId}/cancel |
UpdateMediaTrack | Update audio / subtitle track | PATCH /on-demand/{mediaId}/tracks/{trackId} |
DeleteMediaTrack | Delete audio / subtitle track | DELETE /on-demand/{mediaId}/tracks/{trackId} |
GenerateSubtitleTrack | Generate track subtitle | POST /on-demand/{mediaId}/tracks/generate-subtitle |
UpdatedSourceAccess | Update the source access of a media | PATCH /on-demand/{mediaId}/source-access |
UpdatedMp4Support | Update the mp4Support of a media | PATCH /on-demand/{mediaId}/update-mp4Support |
RetrieveMediaInputInfo | Get info of media inputs | GET /on-demand/{mediaId}/input-info |
ListUploads | Get all unused upload URLs | GET /on-demand/uploads |
GetMediaClips | Get all clips of a media | GET /on-demand/{mediaId}/media-clips |
Playback
Manage secure playback access.
Method | Description | HTTP request |
---|---|---|
CreateMediaPlaybackId | Create a playback ID | POST /on-demand/{mediaId}/playback-ids |
DeleteMediaPlaybackId | Delete a playback ID | DELETE /on-demand/{mediaId}/playback-ids/{playbackId} |
GetPlaybackId | Get a playback ID | GET /on-demand/{mediaId}/playback-ids/{playbackId} |
playlist
Organize videos into playlists.
Method | Description | HTTP request |
---|---|---|
CreateAPlaylist | Create a new playlist | POST /on-demand/playlists |
GetAllPlaylists | Get all playlists | GET /on-demand/playlists |
GetPlaylistById | Get a playlist by ID | GET /on-demand/playlists/{playlistId} |
UpdateAPlaylist | Update a playlist by ID | PATCH /on-demand/playlists/{playlistId} |
DeleteAPlaylist | Delete a playlist by ID | DELETE /on-demand/playlists/{playlistId} |
AddMediaToPlaylist | Add media to a playlist by ID | POST /on-demand/playlists/{playlistId}/media |
ChangeMediaOrderInPlaylist | Change media order in a playlist by ID | PATCH /on-demand/playlists/{playlistId}/media |
DeleteMediaFromPlaylist | Delete media in a playlist by ID | DELETE /on-demand/playlists/{playlistId}/media |
DRM Configurations
Manage DRM for protected content.
Method | Description | HTTP request |
---|---|---|
GetDrmConfiguration | Get list of DRM configuration IDs | GET /on-demand/drm-configurations |
GetDrmConfigurationById | Get DRM configuration by ID | GET /on-demand/drm-configurations/{drmId} |
2.Live Stream
Resources for live streaming, simulcasting, and playback.
Start Live Stream
Method | Description | HTTP Request |
---|---|---|
CreateNewStream | Create a new stream | POST /live/streams |
Simulcast Stream
Method | Description | HTTP Request |
---|---|---|
CreateSimulcastOfStream | Create a simulcast | POST /live/streams/{streamId}/simulcast |
DeleteSimulcastOfStream | Delete a simulcast | DELETE /live/streams/{streamId}/simulcast/{simulcastId} |
GetSpecificSimulcastOfStream | Get a specific simulcast | GET /live/streams/{streamId}/simulcast/{simulcastId} |
UpdateSpecificSimulcastOfStream | Update a simulcast | PATCH /live/streams/{streamId}/simulcast/{simulcastId} |
Manage Live Stream
Method | Description | HTTP Request |
---|---|---|
GetAllStreams | Get all live streams | GET /live/streams |
GetLiveStreamViewerCountById | Get stream views by ID | GET /live/streams/{streamId}/viewer-count |
GetLiveStreamById | Get stream by ID | GET /live/streams/{streamId} |
DeleteLiveStream | Delete a stream | DELETE /live/streams/{streamId} |
UpdateLiveStream | Update a stream | PATCH /live/streams/{streamId} |
DisableLiveStream | Disable a stream | PUT /live/streams/{streamId}/live-disable |
CompleteLiveStream | Complete a stream | PUT /live/streams/{streamId}/finish |
Live Playback
Method | Description | HTTP Request |
---|---|---|
CreatePlaybackIdOfStream | Create a playbackId | POST /live/streams/{streamId}/playback-ids |
DeletePlaybackIdOfStream | Delete a playbackId | DELETE /live/streams/{streamId}/playback-ids/{playbackId} |
GetLiveStreamPlaybackId | Get playbackId details | GET /live/streams/{streamId}/playback-ids/{playbackId} |
3. Systems
Signing Keys
Securely manage token-based access.
Method | Description | HTTP Request |
---|---|---|
CreateSigningKey | Create a signing key | POST /iam/signing-keys |
ListSigningKeys | Get list of signing keys | GET /iam/signing-keys |
DeleteSigningKey | Delete a signing key | DELETE /iam/signing-keys/{signingKeyId} |
GetSigningKeyById | Get signing key by ID | GET /iam/signing-keys/{signingKeyId} |
4.Video Data
Resources for analytics, insights, and system monitoring.
Views
Viewer analytics for on-demand and live content.
Method | Description | HTTP Request |
---|---|---|
ListVideoViews | List video views | GET /data/viewlist |
GetVideoViewDetails | Get details of a video view | GET /data/viewlist/{viewId} |
ListByTopContent | List by top content | GET /data/viewlist/top-content |
GetDataViewlistCurrentViewsGetTimeseriesViews | Get concurrent viewers timeseries | GET /data/viewlist/current-views/getTimeseriesViews |
GetDataViewlistCurrentViewsFilter | Get concurrent viewers breakdown by dimension | GET /data/viewlist/current-views/filter |
Dimensions
Categorize and filter video data for analytics.
Method | Description | HTTP Request |
---|---|---|
ListDimensions | List the dimensions | GET /data/dimensions |
ListFilterValuesForDimension | List the filter values for a dimension | GET /data/dimensions/{dimensionId} |
Errors
Monitor and troubleshoot system errors.
Method | Description | HTTP Request |
---|---|---|
ListErrors | List errors | GET /data/errors |
Metrics
Access analytics and performance metrics.
Method | Description | HTTP Request |
---|---|---|
ListBreakdownValues | List breakdown values | GET /data/metrics/{metricId}/breakdown |
ListOverallValues | List overall values | GET /data/metrics/{metricId}/overall |
GetTimeseriesData | Get timeseries data | GET /data/metrics/{metricId}/timeseries |
ListComparisonValues | List comparison values | GET /data/metrics/comparison |
Error Handling
Handling errors in the FastPix Unity SDK follows standard .NET/Unity conventions. Most operations return a response object or throw an exception if the request fails.
By default, an API error will raise a fastpix.io.Models.Errors.APIException exception with the following properties:
Property | Type | Description |
---|---|---|
Message | string | The error message |
StatusCode | int | The raw HTTP response status code |
RawResponse | HttpResponseMessage | The full raw HTTP response |
Body | string | The response content |
When custom error responses are specified for an operation, the SDK may throw their associated exception. For example, the CreateMediaAsync method can throw the following exceptions:
Error Type | Status Code | Content Type |
---|---|---|
BadRequestException | 400 | application/json |
InvalidPermissionException | 401 | application/json |
ForbiddenException | 403 | application/json |
ValidationErrorResponse | 422 | application/json |
APIException | 4XX, 5XX | / |
Example:
using fastpix.io;
using fastpix.io.Models.Components;
using fastpix.io.Models.Errors;
using System;
using System.Collections.Generic;
// Initialize FastPix Unity SDK with AccessToken and SecretKey
var sdk = new Fastpix(
security: new Security
{
Username = "your-access-token",
Password = "secret-key"
}
);
var req = new CreateMediaRequest
{
Inputs = new List<Input>
{
Input.CreateVideoInput(
new VideoInput
{
Type = "video",
Url = "https://static.fastpix.io/sample.mp4"
}
)
},
Metadata = new Dictionary<string, string>
{
{ "key1", "value1" }
},
AccessPolicy = CreateMediaRequestAccessPolicy.Public,
MaxResolution = CreateMediaRequestMaxResolution.OneThousandAndEightyp
};
try
{
using (var res = await sdk.InputVideo.CreateMediaAsync(req))
{
// Handle response
}
}
catch (Exception ex)
{
if (ex is BadRequestException)
{
// Handle BadRequest
}
else if (ex is InvalidPermissionException)
{
// Handle InvalidPermission
}
else if (ex is ForbiddenException)
{
// Handle Forbidden
}
else if (ex is ValidationErrorResponse)
{
// Handle ValidationError
}
else if (ex is APIException)
{
// Handle APIException
}
}
Server Selection
Override Server URL Per-Client
using fastpix.io;
using fastpix.io.Models.Components;
using System.Collections.Generic;
// Initialize FastPix SDK with custom server URL and security
var sdk = new Fastpix(
serverUrl: "https://api.fastpix.io/v1/",
security: new Security
{
Username = "your-access-token",
Password = "secret-key"
}
);
var req = new CreateMediaRequest
{
Inputs = new List<Input>
{
Input.CreateVideoInput(
new VideoInput
{
Type = "video",
Url = "https://static.fastpix.io/sample.mp4"
}
)
},
Metadata = new Dictionary<string, string>
{
{ "key1", "value1" }
},
AccessPolicy = CreateMediaRequestAccessPolicy.Public,
MaxResolution = CreateMediaRequestMaxResolution.OneThousandAndEightyp
};
using (var res = await sdk.InputVideo.CreateMediaAsync(req))
{
// Handle response
}
Updated about 3 hours ago