A robust, type-safe PHP SDK designed for seamless integration with the FastPix API platform.
The FastPix PHP SDK is a strongly typed PHP client for the FastPix video API. From any PHP application, you can upload and manage videos, run live streams and simulcasts, create and secure playback IDs, manage playlists and signing keys, retrieve video analytics, and use in-video AI features.
Supported PHP: 8.2 and later
Package: fastpix/sdk
Authentication: HTTP Basic Authentication
Dependency management: Composer
📖 Docs: FastPix PHP SDK · 🚀 Free account: FastPix Dashboard
Skip straight to a section without scrolling:
If you are using the FastPix PHP SDK for the first time, follow these steps in order:
- Check your PHP version
- Check your Composer installation
- Create a PHP project
- Install the FastPix SDK
- Verify the SDK installation
- Verify that PHP can load the SDK
- Configure authentication
- Verify that your credentials are set
- Initialize the FastPix client
- Make your first API request
- Capture the media ID
- Verify the integration
Do not skip the verification steps. If installation, dependency loading, authentication, client initialization, or the first API request fails, troubleshoot that problem before continuing.
Make sure you have:
- PHP 8.2 or later.
- Composer.
- Internet access.
- A FastPix account.
- A FastPix Access Token.
- A FastPix Secret Key.
FastPix uses HTTP Basic Authentication:
| SDK value | FastPix credential |
|---|---|
username |
Access Token |
password |
Secret Key |
You can obtain your credentials from the FastPix Dashboard. Follow the Authentication with Basic Auth guide for information about obtaining your credentials.
Security: Never commit your Access Token or Secret Key to source control. Use environment variables or a secure credential-management system.
Run:
php --versionOutput is similar to:
PHP 8.5.10 (cli) ...
The FastPix PHP SDK supports PHP 8.2 and later. If your PHP version is earlier than 8.2, install a supported PHP version before continuing.
You can also check the exact PHP version:
php -r 'echo PHP_VERSION, PHP_EOL;'Expected output is similar to:
8.5.10
The FastPix PHP SDK uses Composer to install and manage dependencies.
Run:
composer --versionExpected output is similar to:
Composer version 2.x.x
You can also verify where Composer is installed:
which composerOn Windows PowerShell:
Get-Command composerIf you see:
zsh: command not found: composer
Composer is not available in your shell. Install Composer before continuing.
Do not continue until this command works:
composer --versionCreate a new directory for your FastPix application:
mkdir fastpix-php-demo
cd fastpix-php-demoInitialize a Composer project:
composer initComposer prompts you for project information. For a simple SDK test application, you can accept the default values.
When Composer asks:
Package name (<vendor>/<name>) [your-name/fastpix-php-demo]:
Press Enter to accept the suggested package name.
Do not enter
lsat the package-name prompt.lsis a shell command, not a valid Composer package name.
When Composer asks whether you want to define dependencies interactively, you can select no. The FastPix SDK will be added explicitly in the next step.
After initialization, your project should contain:
fastpix-php-demo/
└── composer.json
Install the FastPix PHP SDK with Composer:
composer require fastpix/sdkComposer installs the SDK and its dependencies.
After installation, your project should contain:
fastpix-php-demo/
├── composer.json
├── composer.lock
└── vendor/
The vendor/ directory contains the installed SDK and Composer's autoloader.
Before writing application code, verify that Composer installed the FastPix SDK.
Run:
composer show fastpix/sdkThe output should identify the FastPix SDK package and installed version.
You can also search all installed packages:
composer show | grep fastpixcomposer show | Select-String fastpixIf fastpix/sdk is not listed, do not continue.
Run:
composer installThen verify again:
composer show fastpix/sdkBefore configuring authentication or making an API request, verify that PHP can load the SDK.
Create a file named verify.php:
<?php
require 'vendor/autoload.php';
use FastPix\Sdk;
echo "FastPix SDK loaded successfully" . PHP_EOL;Note: This example intentionally does not use
declare(strict_types=1);. The declaration is not required for this SDK verification example and can introduce an unnecessary PHP parsing issue if any output or whitespace appears before the PHP opening tag.
Run:
php verify.phpExpected output:
FastPix SDK loaded successfully
This verifies that:
- PHP can execute the application.
- Composer's autoloader is available.
- The FastPix SDK can be loaded.
If this command fails, do not continue to API requests. Check:
- PHP 8.2 or later is installed.
composer require fastpix/sdkcompleted successfully.vendor/autoload.phpexists.fastpix/sdkis listed bycomposer show.- You are running the command from the
fastpix-php-demodirectory.
FastPix uses HTTP Basic Authentication.
The SDK expects:
username → Access Token
password → Secret Key
For local development, configure these values as environment variables.
export FASTPIX_USERNAME="<YOUR_ACCESS_TOKEN>"
export FASTPIX_PASSWORD="<YOUR_SECRET_KEY>"$env:FASTPIX_USERNAME="<YOUR_ACCESS_TOKEN>"
$env:FASTPIX_PASSWORD="<YOUR_SECRET_KEY>"The SDK maps the environment variables as follows:
FASTPIX_USERNAME → Access Token
FASTPIX_PASSWORD → Secret Key
Do not print the actual credential values.
Run:
if [ -n "$FASTPIX_USERNAME" ]; then
echo "Access Token: set"
else
echo "Access Token: missing"
fi
if [ -n "$FASTPIX_PASSWORD" ]; then
echo "Secret Key: set"
else
echo "Secret Key: missing"
fiExpected output:
Access Token: set
Secret Key: set
If either value is reported as missing, set the corresponding environment variable before continuing.
Run:
if ($env:FASTPIX_USERNAME) {
Write-Output "Access Token: set"
} else {
Write-Output "Access Token: missing"
}
if ($env:FASTPIX_PASSWORD) {
Write-Output "Secret Key: set"
} else {
Write-Output "Secret Key: missing"
}Expected output:
Access Token: set
Secret Key: set
Never:
- Commit credentials to Git.
- Put credentials directly into source code.
- Include credentials in screenshots.
- Print credentials in logs.
- Include credentials in bug reports or support requests.
- Log HTTP authentication headers in production.
Use environment variables or a secure credential-management system.
Create or replace main.php with:
<?php
require 'vendor/autoload.php';
use FastPix\Sdk;
use FastPix\Sdk\Models\Components;
$username = getenv('FASTPIX_USERNAME');
$password = getenv('FASTPIX_PASSWORD');
if ($username === false || $username === '') {
throw new RuntimeException('FASTPIX_USERNAME is not set');
}
if ($password === false || $password === '') {
throw new RuntimeException('FASTPIX_PASSWORD is not set');
}
$sdk = Sdk\Fastpixsdk::builder()
->setSecurity(
new Components\Security(
username: $username,
password: $password,
)
)
->build();
echo "FastPix client initialized" . PHP_EOL;Run:
php main.phpExpected output:
FastPix client initialized
Sdk\Fastpixsdk::builder() creates the FastPix SDK client.
setSecurity() configures the credentials used for HTTP Basic Authentication.
build() creates the configured SDK client.
Initializing the client does not make an API request. An API request occurs when you call an SDK operation such as:
$sdk->inputVideo->createMedia(...)The easiest way to verify the complete PHP SDK integration is to create media from a publicly accessible video URL.
FastPix provides a sample video URL:
https://static.fastpix.com/fp-sample-video.mp4
The PHP SDK exposes media creation through:
$sdk->inputVideo->createMedia()Replace the contents of main.php with:
<?php
require 'vendor/autoload.php';
use FastPix\Sdk;
use FastPix\Sdk\Models\Components;
$username = getenv('FASTPIX_USERNAME');
$password = getenv('FASTPIX_PASSWORD');
if ($username === false || $username === '') {
throw new RuntimeException('FASTPIX_USERNAME is not set');
}
if ($password === false || $password === '') {
throw new RuntimeException('FASTPIX_PASSWORD is not set');
}
$sdk = Sdk\Fastpixsdk::builder()
->setSecurity(
new Components\Security(
username: $username,
password: $password,
)
)
->build();
try {
$request = new Components\CreateMediaRequest(
inputs: [
new Components\PullVideoInput(
url: 'https://static.fastpix.com/fp-sample-video.mp4',
),
],
metadata: [
'source' => 'fastpix-php-demo',
],
);
$response = $sdk->inputVideo->createMedia(
request: $request,
);
if ($response->statusCode >= 200 && $response->statusCode < 300) {
$rawBody = (string) $response->rawResponse->getBody();
$decoded = json_decode($rawBody, true);
echo json_encode(
$decoded ?? $rawBody,
JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES,
) . PHP_EOL;
} else {
$errorPayload = $response->defaultError
?? $response->error
?? null;
if ($errorPayload !== null) {
echo json_encode(
$errorPayload,
JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES,
) . PHP_EOL;
} else {
echo json_encode(
['message' => 'No response data'],
JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES,
) . PHP_EOL;
}
exit(1);
}
} catch (\Exception $e) {
echo json_encode(
['error' => $e->getMessage()],
JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES,
) . PHP_EOL;
exit(1);
}Run:
php main.phpA successful request returns information about the newly created media asset. The response contains information similar to:
{
"success": true,
"data": {
"id": "..."
}
}The exact response fields depend on the API response and installed SDK version.
The create-media response contains the unique ID assigned to the media asset.
The media ID is available at:
data.id
For example:
{
"success": true,
"data": {
"id": "12345678-1234-1234-1234-123456789abc"
}
}The value of:
data.id
is the media_id.
Save the value for subsequent API operations:
MEDIA_ID=<value returned in data.id>
Do not confuse a media_id with a playback_id.
They identify different resources and are used for different operations.
At this point, you have verified the initial FastPix PHP SDK integration.
A successful create-media request confirms that:
- PHP is installed and supported.
- Composer is installed.
- The PHP project is initialized.
- The FastPix PHP SDK is installed.
- Composer dependencies are available.
- PHP can load the FastPix SDK.
- Your FastPix credentials are configured.
- The FastPix client can be initialized.
- Your application can authenticate with the FastPix API.
- Your application can create a media asset.
- FastPix returns a media ID.
The completed workflow is:
At this point, the initial SDK integration is complete.
More examples: For additional runnable examples, see the
examples/directory in this repository.
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
- Update Domain Restrictions - Update domain allow/deny list for live playback
- Update User Agent Restrictions - Update user-agent allow/deny list for live playback
- 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.com/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.com/v1/')
->setSecurity(
new Components\Security(
username: 'your-access-token',
password: 'your-secret-key',
)
)
->build();How do I install the FastPix PHP SDK?
It is a Composer package - add fastpix/sdk to your composer.json and run composer update (or composer require fastpix/sdk). See Install the FastPix SDK.
How do I authenticate the SDK?
FastPix uses Basic Auth: pass your access token as the username and your secret key as the password in Components\Security when building the client. See Initialize the FastPix client.
How do I upload a video in PHP?
Create media from a URL or a direct upload through the input-video resource on the built $sdk. See Make your first API request and Available Resources and Operations.
How do I start a live stream? Use the Live API resources to create and manage streams, simulcasts, and live playback IDs. See Available Resources and Operations.
How do I create a secure playback ID? Generate playback IDs and manage signing keys and DRM configurations through the Media API resources. See Available Resources and Operations.
How do I get video analytics and metrics in PHP? The Video Data API exposes metrics, views, dimensions, and errors for quality-of-experience monitoring. See Available Resources and Operations.
How do I handle API errors? Wrap calls in try/catch; the SDK throws a typed error exposing the message, status code, and response body. See Error Handling.
How do I change the API base URL?
Pass a server URL with setServerUrl(...) when building the client. See Server Selection.
Which PHP versions are supported? PHP 8.2 and above. See Before you begin.
Is the SDK strongly typed? Yes - it is a type-safe client generated from the FastPix API specification. See Development.
FastPix publishes a server SDK for every major backend language, each generated from the same API specification:
| Language | Repo | Install |
|---|---|---|
| PHP (this repo) | fastpix-php | composer require fastpix/sdk |
| Python | fastpix-python | pip install fastpix-python |
| Go | fastpix-go | go get github.com/FastPix/fastpix-go |
| Java | fastpix-java | io.fastpix:sdk (Maven/Gradle) |
| C# / .NET | fastpix-sdk-csharp | dotnet add package Fastpix |
| Ruby | fastpix-ruby | gem install fastpixapi |
To upload and play the media these SDKs create, use the FastPix browser libraries: web-uploads-sdk, react-web-uploader, and web-player-component. Browse everything in the FastPix organization.
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.
