fastpix / sdk
Developer-friendly & type-safe PHP SDK for the FastPix platform API
Requires
- php: ^8.2
- brick/date-time: ^0.7.0
- brick/math: ^0.12.1
- galbar/jsonpath: ^3.0
- guzzlehttp/guzzle: ^7.0
- phpdocumentor/type-resolver: ^1.8
- speakeasy/serializer: ^4.0.3
- vlucas/phpdotenv: ^5.6
Requires (Dev)
- laravel/pint: ^1.21.2
- phpstan/phpstan: ^2.1.0
- phpunit/php-code-coverage: ^10.1
- phpunit/phpunit: ^10
- roave/security-advisories: dev-latest
This package is auto-updated.
Last update: 2025-05-22 10:47:04 UTC
README
Developer-friendly & type-safe PHP SDK specifically designed to leverage the FastPix platform API.
Introduction
The FastPix PHP 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.
Prerequisites:
- PHP 7.4 or later
- Composer package manager
- FastPix API credentials (Access Token and Secret Key)
Getting started with FastPix:
Table of Contents
SDK Installation
The SDK relies on Composer to manage its dependencies.
To install the SDK first add the below to your composer.json
file:
{ "repositories": [ { "type": "vcs", "url": "https://github.com/FastPix/fastpix-php.git" } ], "require": { "fastpix/sdk": "*" } }
Then run the following command:
composer update
Initialization
You can set the security parameters through the security
builder method when initializing the SDK client instance. For example:
declare(strict_types=1); require 'vendor/autoload.php'; use FastPix\Sdk; use FastPix\Sdk\Models\Components; $sdk = Sdk\FastPix::builder() ->setSecurity( new Components\Security( username: 'your-access-token-id', password: 'your-security-key', ) ) ->build();
SDK Example Usage
Example
declare(strict_types=1); require 'vendor/autoload.php'; use FastPix\Sdk; use FastPix\Sdk\Models\Components; $sdk = Sdk\FastPix::builder() ->setSecurity( new Components\Security( username: 'your-access-token-id', password: 'your-security-key', ) ) ->build(); $request = new Components\CreateLiveStreamRequest( playbackSettings: new Components\PlaybackSettings(), inputMediaSettings: new Components\InputMediaSettings( metadata: new Components\CreateLiveStreamRequestMetadata(), ), ); $response = $sdk->startLiveStream->createNewStream( request: $request ); if ($response->liveStreamResponseDTO !== null) { // handle response }
Available Resources and Operations
Available methods
inputVideo
- createMedia - Create media from URL
- directUploadVideoMedia - Upload media from device
manageLiveStream
- getAllStreams - Get all live streams
- getLiveStreamById - Get stream by ID
- deleteLiveStream - Delete a stream
- updateLiveStream - Update a stream
manageVideos
- 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
playback
- createPlaybackIdOfStream - Create a playbackId
- deletePlaybackIdOfStream - Delete a playbackId
- getLiveStreamPlaybackId - Get stream's playbackId
- createMediaPlaybackId - Create a playback ID
- deleteMediaPlaybackId - Delete a playback ID
simulcastStream
- createSimulcastOfStream - Create a simulcast
- deleteSimulcastOfStream - Delete a simulcast
- getSpecificSimulcastOfStream - Get a specific simulcast of a stream
- updateSpecificSimulcastOfStream - Update a specific simulcast of a stream
startLiveStream
- createNewStream - Create a new stream
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 Errors\APIException
exception, which has the following properties:
Property | Type | Description |
---|---|---|
$message |
string | The error message |
$statusCode |
int | The HTTP status code |
$rawResponse |
?\Psr\Http\Message\ResponseInterface | The raw HTTP response |
$body |
string | The response content |
When custom error responses are specified for an operation, the SDK may also throw their associated exception. You can refer to respective Errors tables in SDK docs for more details on possible exception types for each operation. For example, the createNewStream
method throws the following exceptions:
Error Type | Status Code | Content Type |
---|---|---|
Errors\UnauthorizedException | 401 | application/json |
Errors\InvalidPermissionException | 403 | application/json |
Errors\ValidationErrorResponse | 422 | application/json |
Errors\APIException | 4XX, 5XX | */* |
Example
declare(strict_types=1); require 'vendor/autoload.php'; use FastPix\Sdk; use FastPix\Sdk\Models\Components; use FastPix\Sdk\Models\Errors; $sdk = Sdk\FastPix::builder() ->setSecurity( new Components\Security( username: 'your-access-token-id', password: 'your-security-key', ) ) ->build(); try { $request = new Components\CreateLiveStreamRequest( playbackSettings: new Components\PlaybackSettings(), inputMediaSettings: new Components\InputMediaSettings( metadata: new Components\CreateLiveStreamRequestMetadata(), ), ); $response = $sdk->startLiveStream->createNewStream( request: $request ); if ($response->liveStreamResponseDTO !== null) { // handle response } } catch (Errors\UnauthorizedExceptionThrowable $e) { // handle $e->$container data throw $e; } catch (Errors\InvalidPermissionExceptionThrowable $e) { // handle $e->$container data throw $e; } catch (Errors\ValidationErrorResponseThrowable $e) { // handle $e->$container data throw $e; } catch (Errors\APIException $e) { // handle default exception throw $e; }
Server Selection
Override Server URL Per-Client
The default server can be overridden globally using the setServerUrl(string $serverUrl)
builder method when initializing the SDK client instance. For example:
declare(strict_types=1); require 'vendor/autoload.php'; use FastPix\Sdk; use FastPix\Sdk\Models\Components; $sdk = Sdk\FastPix::builder() ->setServerURL('https://v1.fastpix.io/live') ->setSecurity( new Components\Security( username: 'your-access-token-id', password: 'your-security-key', ) ) ->build(); $request = new Components\CreateLiveStreamRequest( playbackSettings: new Components\PlaybackSettings(), inputMediaSettings: new Components\InputMediaSettings( metadata: new Components\CreateLiveStreamRequestMetadata(), ), ); $response = $sdk->startLiveStream->createNewStream( request: $request ); if ($response->liveStreamResponseDTO !== null) { // 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.
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.
The API reference provides comprehensive documentation for all available endpoints and features, ensuring developers can integrate and utilize FastPix APIs efficiently.