Developer-friendly & type-safe PHP SDK for the FastPix platform API
The FastPix PHP SDK simplifies integration with the FastPix platform. It provides a clean, PHP 8+ interface for secure and efficient communication with the FastPix API, enabling easy management of media uploads, live streaming, on‑demand content, playlists, video analytics, and signing keys for secure access and token management. It is intended for use with PHP 8.2 and above.
| Requirement | Version | Description |
|---|---|---|
| PHP | 8.2+ |
Core runtime environment |
| Composer | Latest |
Package manager for dependencies |
| Internet | Required |
API communication and authentication |
Pro Tip: We recommend using PHP 8.3+ for optimal performance and the latest language features.
To get started with the FastPix PHP SDK, ensure you have the following:
- The FastPix APIs are authenticated using a Username and a Password. You must generate these credentials to use the SDK.
- Follow the steps in the Authentication with Basic Auth guide to obtain your credentials.
Configure your FastPix credentials using environment variables for enhanced security and convenience:
# Set your FastPix credentials
export FASTPIX_USERNAME="your-access-token"
export FASTPIX_PASSWORD="your-secret-key"Security Note: Never commit your credentials to version control. Use environment variables or secure credential management systems.
The SDK relies on Composer to manage its dependencies.
Add the SDK to your project:
{
"require": {
"fastpix/sdk": "*"
}
}Then run:
composer updateIf you host the package in a private repository, add the repository to your composer.json:
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/your-org/fastpix-sdk-php.git"
}
],
"require": {
"fastpix/sdk": "*"
}
}Use the SDK via Composer’s autoload and the FastPix namespaces:
<?php
require 'vendor/autoload.php';
use FastPix\Sdk;
use FastPix\Sdk\Models\Components;
use FastPix\Sdk\Models\Operations;Initialize the FastPix SDK with your credentials:
<?php
declare(strict_types=1);
require 'vendor/autoload.php';
use FastPix\Sdk;
use FastPix\Sdk\Models\Components;
$sdk = Sdk\Fastpixsdk::builder()
->setSecurity(
new Components\Security(
username: 'your-access-token',
password: 'your-secret-key',
)
)
->build();Or using environment variables:
<?php
declare(strict_types=1);
require 'vendor/autoload.php';
use FastPix\Sdk;
use FastPix\Sdk\Models\Components;
$username = getenv('FASTPIX_USERNAME') ?: 'your-access-token';
$password = getenv('FASTPIX_PASSWORD') ?: 'your-secret-key';
$sdk = Sdk\Fastpixsdk::builder()
->setSecurity(
new Components\Security(
username: $username,
password: $password,
)
)
->build();<?php
declare(strict_types=1);
require 'vendor/autoload.php';
use FastPix\Sdk;
use FastPix\Sdk\Models\Components;
try {
$sdk = Sdk\Fastpixsdk::builder()
->setSecurity(
new Components\Security(
username: 'your-access-token',
password: 'your-secret-key',
)
)
->build();
$request = new Components\CreateMediaRequest(
inputs: [
new Components\PullVideoInput(),
],
metadata: [
'key1' => 'value1',
],
);
$response = $sdk->inputVideo->createMedia(
request: $request
);
if ($response->statusCode >= 200 && $response->statusCode < 300) {
$rawBody = (string) $response->rawResponse->getBody();
$decoded = json_decode($rawBody, true);
echo ($decoded !== null ? json_encode($decoded, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) : $rawBody) . "\n";
} else {
$errorPayload = $response->defaultError ?? $response->error ?? null;
if ($errorPayload !== null) {
$errorResponse = json_decode(json_encode($errorPayload), true);
echo json_encode($errorResponse, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . "\n";
} else {
echo json_encode(['message' => 'No response data'], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . "\n";
}
}
} catch (\Exception $e) {
// Extract API error response
$errorBody = null;
if (property_exists($e, 'body') && property_exists($e, 'statusCode')) {
$body = $e->body;
$errorBody = json_decode($body, true);
if (json_last_error() !== JSON_ERROR_NONE) {
$errorBody = $body;
}
} elseif (method_exists($e, 'getResponse')) {
$response = $e->getResponse();
if ($response !== null) {
$body = (string)$response->getBody();
$errorBody = json_decode($body, true);
if (json_last_error() !== JSON_ERROR_NONE) {
$errorBody = $body;
}
}
}
// Output API error response
if ($errorBody !== null) {
echo json_encode($errorBody, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . "\n";
} else {
echo json_encode(['error' => $e->getMessage()], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . "\n";
}
exit(1);
}Comprehensive PHP SDK for FastPix platform integration with full API coverage.
Upload, manage, and transform video content with comprehensive media management capabilities.
For detailed documentation, see FastPix Video on Demand Overview.
- Create from URL - Upload video content from external URL
- Upload from Device - Upload video files directly from device
- List All Media - Retrieve complete list of all media files
- Get Media by ID - Get detailed information for specific media
- Update Media - Modify media metadata and settings
- Delete Media - Remove media files from library
- Cancel Upload - Stop ongoing media upload process
- Get Input Info - Retrieve detailed input information
- List Uploads - Get all available upload URLs
- Get Media Summary - Get summary for a media
- List Live Clips - List live clips for a livestream
- Create Playback ID - Generate secure playback identifier
- List Playback IDs - List all playback IDs for a media
- Get Playback ID - Retrieve playback configuration details
- Delete Playback ID - Remove playback access
- Update Domain Restrictions - Update domain allow/deny list for playback
- Update User Agent Restrictions - Update user-agent allow/deny list for playback
- Create Playlist - Create new video playlist
- List Playlists - Get all available playlists
- Get Playlist - Retrieve specific playlist details
- Update Playlist - Modify playlist settings and metadata
- Delete Playlist - Remove playlist from library
- Add Media - Add media items to playlist
- Reorder Media - Change order of media in playlist
- Remove Media - Remove media from playlist
- Create Key - Generate new signing key pair
- List Keys - Get all available signing keys
- Delete Key - Remove signing key from system
- Get Key - Retrieve specific signing key details
- List DRM Configs - Get all DRM configuration options
- Get DRM Config - Retrieve specific DRM configuration
Stream, manage, and transform live video content with real-time broadcasting capabilities.
For detailed documentation, see FastPix Live Stream Overview.
- Create Stream - Initialize new live streaming session with DVR mode support
- List Streams - Retrieve all active live streams
- Get Viewer Count - Get real-time viewer statistics
- Get Stream - Retrieve detailed stream information
- Delete Stream - Terminate and remove live stream
- Update Stream - Modify stream settings and configuration
- Enable Stream - Activate live streaming
- Disable Stream - Pause live streaming
- Complete Stream - Finalize and archive stream
- Create Playback ID - Generate secure live playback access
- Delete Playback ID - Revoke live playback access
- Get Playback ID - Retrieve live playback configuration
- Create Simulcast - Set up multi-platform streaming
- Delete Simulcast - Remove simulcast configuration
- Get Simulcast - Retrieve simulcast settings
- Update Simulcast - Modify simulcast parameters
Monitor video performance and quality with comprehensive analytics and real-time metrics.
For detailed documentation, see FastPix Video Data Overview.
- List Breakdown Values - Get detailed breakdown of metrics by dimension
- List Overall Values - Get aggregated metric values across all content
- Get Timeseries Data - Retrieve time-based metric trends and patterns
- List Video Views - Get comprehensive list of video viewing sessions
- Get View Details - Retrieve detailed information about specific video views
- List Top Content - Find your most popular and engaging content
- Get Concurrent Viewers - Monitor real-time viewer counts over time
- List Dimensions - Get available data dimensions for filtering and analysis
- List Filter Values - Get specific values for a particular dimension
- List Errors - List playback errors for diagnostics and monitoring
Transform and enhance your video content with powerful AI and editing capabilities.
Enhance video content with AI-powered features including moderation, summarization, and intelligent categorization.
- Update Summary - Create AI-generated video summaries
- Create Chapters - Automatically generate video chapter markers
- Extract Entities - Identify and extract named entities from content
- Enable Moderation - Activate content moderation and safety checks
- Get Media Clips - Retrieve all clips associated with a source media
- Generate Subtitles - Create automatic subtitles for media
- Add Track - Add audio or subtitle tracks to media
- Update Track - Modify existing audio or subtitle tracks
- Delete Track - Remove audio or subtitle tracks
- Update Source Access - Control access permissions for media source
- Update MP4 Support - Configure MP4 download capabilities
All operations return a response object or throw an exception. By default, an API error will raise an Errors\APIException (or operation-specific error types).
| 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 |
<?php
declare(strict_types=1);
require 'vendor/autoload.php';
use FastPix\Sdk;
use FastPix\Sdk\Models\Components;
$sdk = Sdk\Fastpixsdk::builder()
->setSecurity(
new Components\Security(
username: 'your-access-token',
password: 'your-secret-key',
)
)
->build();
try {
$request = new Components\CreateMediaRequest(
inputs: [new Components\PullVideoInput(url: 'https://static.fastpix.io/fp-sample-video.mp4')],
metadata: ['key1' => 'value1'],
);
$response = $sdk->inputVideo->createMedia(request: $request);
if ($response->createMediaSuccessResponse !== null) {
$rawBody = (string) $response->rawResponse->getBody();
$decoded = json_decode($rawBody, true);
echo json_encode($decoded, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
}
} catch (\FastPix\Sdk\Models\Errors\APIException $e) {
echo "Error: " . $e->getMessage() . "\n";
echo "Status: " . $e->statusCode . "\n";
echo "Body: " . $e->body . "\n";
}Refer to the Errors tables in each operation’s SDK doc for possible exception types.
Override the default server by passing a URL when building the SDK:
<?php
declare(strict_types=1);
require 'vendor/autoload.php';
use FastPix\Sdk;
use FastPix\Sdk\Models\Components;
$sdk = Sdk\Fastpixsdk::builder()
->setServerUrl('https://api.fastpix.io/v1/')
->setSecurity(
new Components\Security(
username: 'your-access-token',
password: 'your-secret-key',
)
)
->build();This PHP SDK is programmatically generated from our API specifications. Any manual modifications to internal files will be overwritten during subsequent generation cycles.
We value community contributions and feedback. Feel free to submit pull requests or open issues with your suggestions, and we'll do our best to include them in future releases.
For comprehensive understanding of each API's functionality, including detailed request and response specifications, parameter descriptions, and additional examples, please refer to the FastPix API Reference.
The API reference offers complete documentation for all available endpoints and features, enabling developers to integrate and leverage FastPix APIs effectively.