A robust, type-safe Python SDK designed for seamless integration with the FastPix API platform.
The FastPix Python SDK is a type-safe Python client for the FastPix video API. From any Python application you can upload and manage videos, run live streams and simulcasts, create and secure playback IDs, manage playlists and signing keys, pull video analytics (views, metrics, dimensions, and errors), and drive in-video AI features such as subtitles, chapters, summaries, and content moderation.
Supported Python: 3.9.2 and later
Package: fastpix-python
Authentication: HTTP Basic Authentication
Clients: Synchronous and asynchronous
📖 Docs: https://fastpix.com/docs/language-sdks/python-sdk · 🚀 Free account: https://dashboard.fastpix.com
If you are using the FastPix Python SDK for the first time, follow these steps in order:
- Check your Python version.
- Create a Python environment.
- Install the SDK.
- Configure your FastPix credentials.
- Verify that the SDK can be imported.
- Initialize the FastPix client.
- Create your first media asset.
- Save the returned media ID.
- Use the media ID for subsequent operations.
Do not skip the verification step. If installation or authentication fails, troubleshoot that problem before continuing to the next API operation.
To use the SDK make sure you have:
- Python 3.9.2 or later.
- Internet access.
- A FastPix account.
- A FastPix Access Token.
- A FastPix Secret Key.
FastPix uses Basic Authentication:
| SDK value | FastPix credential |
|---|---|
username |
Access Token |
password |
Secret Key |
You can obtain your credentials from the FastPix Dashboard. Follow the steps in the Authentication with Basic Auth guide to obtain your credentials.
- Check your Python version
python3 --versionOutput is similar to:
Python 3.9.2
or a later version.
If your Python version is earlier than 3.9.2, install a supported version before continuing.
- Create a Python project
a. Create a new directory for your FastPix application:
mkdir fastpix-python-demo
cd fastpix-python-demob. Create a virtual environment:
python3 -m venv .venvc. Activate the virtual environment.
source .venv/bin/activate.venv\Scripts\activated. Verify that the virtual environment is active:
python --version- Install the SDK
pip install fastpix-pythonuv add fastpix-pythonpoetry add fastpix-python- Verify the installation
Before making an API request, verify that Python can import the SDK:
python -c "import fastpix_python; print('FastPix SDK installed successfully')"Output is similar to:
FastPix SDK installed successfully
If this command fails, do not continue to API calls.
Check:
- The virtual environment is active.
fastpix-pythonis installed.- The Python interpreter belongs to the expected virtual environment.
- Your Python version is supported.
You can verify the installed package with:
pip show fastpix-python- Configure authentication
FastPix uses Basic Authentication.
Set the Access Token and Secret Key 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 these variables as follows:
FASTPIX_USERNAME → Access Token
FASTPIX_PASSWORD → Secret Key
Do not print the actual credential values.
Instead, run:
python -c "import os; print('Access Token:', 'set' if os.getenv('FASTPIX_USERNAME') else 'missing'); print('Secret Key:', 'set' if os.getenv('FASTPIX_PASSWORD') else 'missing')"Output is similar to:
Access Token: set
Secret Key: set
Never:
- Commit credentials to Git.
- Put credentials directly into source code.
- Include credentials in screenshots, logs, or bug reports.
- Print authentication headers during debugging in production.
Use environment variables or a secure credential-management system.
- Initialize the FastPix client
a. Create a file named example.py:
import os
from fastpix_python import Fastpix, models
fastpix = Fastpix(
security=models.Security(
username=os.getenv("FASTPIX_USERNAME"),
password=os.getenv("FASTPIX_PASSWORD"),
),
)
print("FastPix client initialized")b. Run:
python example.pyOutput is similar to:
FastPix client initialized
Fastpix is the top-level SDK client.
models.Security contains the credentials used to authenticate API requests.
The SDK client does not make an API request simply because it is initialized.
An API request occurs when you call an operation such as:
fastpix.input_video.create_media(...)- Make your first API request
The easiest way to verify the complete 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
a. Replace the contents of example.py with:
import json
import os
from fastpix_python import Fastpix, models
with Fastpix(
security=models.Security(
username=os.getenv("FASTPIX_USERNAME"),
password=os.getenv("FASTPIX_PASSWORD"),
),
) as fastpix:
response = fastpix.input_video.create_media(
inputs=[
{
"type": "video",
"url": "https://static.fastpix.com/fp-sample-video.mp4",
},
],
access_policy="public",
metadata={
"source": "fastpix-python-demo",
},
)
print(
json.dumps(
response.model_dump(
mode="json",
by_alias=True,
exclude_unset=True,
),
indent=2,
)
)b. Save the file and run:
python example.py- Verify the API response
A successful request returns a response containing a media ID.
The response has the following general structure:
{
"success": true,
"data": {
"id": "..."
}
}The value of:
data.id
is the unique ID assigned to the media.
You will need the media ID for subsequent media operations.
For example:
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.
- Understand the media workflow
Creating media is usually the first operation in an on-demand video workflow.
The basic workflow is:
Create media
|
v
Receive media ID
|
v
Retrieve media
|
v
Check media status
|
v
Create playback ID
|
v
Play the video
The media ID is the identifier you carry from one operation to the next.
A playback ID is created separately when you need playback access.
Goal: Create a FastPix media asset from a video URL.
SDK method:
fastpix.input_video.create_media(...)Required information:
- Video URL.
- Access policy.
Example:
response = fastpix.input_video.create_media(
inputs=[
{
"type": "video",
"url": "https://static.fastpix.com/fp-sample-video.mp4",
},
],
access_policy="public",
)Result:
Save the media ID from:
response.data.id
After verifying your integration, you can use the SDK to:
- Manage media — list, retrieve, update, and delete media.
- Create playback IDs — generate playback access for your media.
- Manage live streams — create and manage live streaming sessions.
- Create playlists — organize media into playlists.
- Manage signing keys — create and manage keys for secure playback.
- Analyze video performance — retrieve metrics, views, dimensions, and errors.
- Use in-video AI — generate subtitles, summaries, chapters, and named entities.
- Manage media tracks — add, update, and delete audio or subtitle tracks.
See Available Resources and Operations for the complete list.
Comprehensive Python 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
- Get Summary - Retrieve AI-generated video summary
- List Uploads - Get all available upload URLs
- Create Playback ID - Generate secure playback identifier
- Delete Playback ID - Remove playback access
- Get Playback ID - Retrieve playback configuration details
- List Playback IDs - Get all playback IDs for a media
- Update Domain Restrictions - Configure domain-based access control
- Update User-Agent Restrictions - Configure user-agent-based access control
- 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
- List Live Clips - Get all clips of a live 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 Comparison Values - Compare metrics across different time periods
- 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
- List Dimensions - Get available data dimensions for filtering and analysis
- List Filter Values - Get specific values for a particular dimension
- List Errors - Retrieve playback errors and issues
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
Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.
To change the default retry strategy for a single API call, simply provide a RetryConfig object to the call:
import os
import json
from fastpix_python import Fastpix, models
from fastpix_python.utils import BackoffStrategy, RetryConfig
with Fastpix(
security=models.Security(
username="your-access-token",
password="your-secret-key",
),
) as fastpix:
res = fastpix.input_video.create_media(
inputs=[
{
"type": "video",
"url": "https://static.fastpix.com/fp-sample-video.mp4",
},
],
access_policy="public",
metadata={
"key1": "value1",
},
retries=RetryConfig(
"backoff",
BackoffStrategy(1, 50, 1.1, 100),
False
),
)
print(json.dumps(res.model_dump(mode="json", by_alias=True, exclude_unset=True), indent=2))If you'd like to override the default retry strategy for all operations that support retries, you can use the retry_config optional parameter when initializing the SDK:
import os
import json
from fastpix_python import Fastpix, models
from fastpix_python.utils import BackoffStrategy, RetryConfig
with Fastpix(
retry_config=RetryConfig(
"backoff",
BackoffStrategy(1, 50, 1.1, 100),
False
),
security=models.Security(
username="your-access-token",
password="your-secret-key",
),
) as fastpix:
res = fastpix.input_video.create_media(
inputs=[
{
"type": "video",
"url": "https://static.fastpix.com/fp-sample-video.mp4",
},
],
access_policy="public",
metadata={
"key1": "value1",
},
)
print(json.dumps(res.model_dump(mode="json", by_alias=True, exclude_unset=True), indent=2))FastpixError is the base class for all HTTP error responses. It has the following properties:
| Property | Type | Description |
|---|---|---|
err.message |
str |
Error message |
err.status_code |
int |
HTTP response status code eg 404 |
err.headers |
httpx.Headers |
HTTP response headers |
err.body |
str |
HTTP body. Can be empty string if no body is returned. |
err.raw_response |
httpx.Response |
Raw HTTP response |
import os
import json
from fastpix_python import Fastpix, errors, models
with Fastpix(
security=models.Security(
username="your-access-token",
password="your-secret-key",
),
) as fastpix:
try:
res = fastpix.input_video.create_media(
inputs=[
{
"type": "video",
"url": "https://static.fastpix.com/fp-sample-video.mp4",
},
],
access_policy="public",
metadata={
"key1": "value1",
},
)
print(json.dumps(res.model_dump(mode="json", by_alias=True, exclude_unset=True), indent=2))
except errors.FastpixError as e:
print(e.message)
print(e.status_code)
print(e.body)
print(e.headers)
print(e.raw_response)Primary error:
FastpixError: The base class for HTTP error responses.
Less common errors (5)
Network errors:
httpx.RequestError: Base class for request errors.httpx.ConnectError: HTTP client was unable to make a request to a server.httpx.TimeoutException: HTTP request timed out.
Inherit from FastpixError:
ResponseValidationError: Type mismatch between the response data and the expected Pydantic model. Provides access to the Pydantic validation error via thecauseattribute.
The default server can be overridden globally by passing a URL to the server_url: str optional parameter when initializing the SDK client instance. For example:
import os
import json
from fastpix_python import Fastpix, models
with Fastpix(
server_url="https://api.fastpix.com/v1/",
security=models.Security(
username="your-access-token",
password="your-secret-key",
),
) as fastpix:
res = fastpix.input_video.create_media(
inputs=[
{
"type": "video",
"url": "https://static.fastpix.com/fp-sample-video.mp4",
},
],
access_policy="public",
metadata={
"key1": "value1",
},
)
print(json.dumps(res.model_dump(mode="json", by_alias=True, exclude_unset=True), indent=2))The Python SDK makes API calls using the httpx HTTP library. In order to provide a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration, you can initialize the SDK client with your own HTTP client instance.
Depending on whether you are using the sync or async version of the SDK, you can pass an instance of HttpClient or AsyncHttpClient respectively, which are Protocol's ensuring that the client has the necessary methods to make API calls.
This allows you to wrap the client with your own custom logic, such as adding custom headers, logging, or error handling, or you can just pass an instance of httpx.Client or httpx.AsyncClient directly.
For example, you could specify a header for every request that this SDK makes as follows:
from fastpix_python import Fastpix, models
import httpx
http_client = httpx.Client(headers={"x-custom-header": "someValue"})
s = Fastpix(
client=http_client,
security=models.Security(
username="your-access-token",
password="your-secret-key",
),
)Or you could wrap the client with your own custom logic:
from fastpix_python import Fastpix, models
from fastpix_python.httpclient import AsyncHttpClient
import httpx
from typing import Union, Optional, Any
class CustomClient(AsyncHttpClient):
client: AsyncHttpClient
def __init__(self, client: AsyncHttpClient):
self.client = client
async def send(
self,
request: httpx.Request,
*,
stream: bool = False,
auth: Union[
httpx._types.AuthTypes, httpx._client.UseClientDefault, None
] = httpx.USE_CLIENT_DEFAULT,
follow_redirects: Union[
bool, httpx._client.UseClientDefault
] = httpx.USE_CLIENT_DEFAULT,
) -> httpx.Response:
request.headers["Client-Level-Header"] = "added by client"
return await self.client.send(
request, stream=stream, auth=auth, follow_redirects=follow_redirects
)
def build_request(
self,
method: str,
url: httpx._types.URLTypes,
*,
content: Optional[httpx._types.RequestContent] = None,
data: Optional[httpx._types.RequestData] = None,
files: Optional[httpx._types.RequestFiles] = None,
json: Optional[Any] = None,
params: Optional[httpx._types.QueryParamTypes] = None,
headers: Optional[httpx._types.HeaderTypes] = None,
cookies: Optional[httpx._types.CookieTypes] = None,
timeout: Union[
httpx._types.TimeoutTypes, httpx._client.UseClientDefault
] = httpx.USE_CLIENT_DEFAULT,
extensions: Optional[httpx._types.RequestExtensions] = None,
) -> httpx.Request:
return self.client.build_request(
method,
url,
content=content,
data=data,
files=files,
json=json,
params=params,
headers=headers,
cookies=cookies,
timeout=timeout,
extensions=extensions,
)
s = Fastpix(
async_client=CustomClient(httpx.AsyncClient()),
security=models.Security(
username="your-access-token",
password="your-secret-key",
),
)You can setup your SDK to emit debug logs for SDK requests and responses.
You can pass your own logger class directly into your SDK.
Warning
Beware that debug logging will reveal secrets, like API tokens in headers, in log messages printed to a console or files. It's recommended to use this feature only during local development and not in production.
from fastpix_python import Fastpix, models
import logging
logging.basicConfig(level=logging.DEBUG)
s = Fastpix(
debug_logger=logging.getLogger("fastpix_python"),
security=models.Security(
username="your-access-token",
password="your-secret-key",
),
)You can also enable a default debug logger by setting an environment variable FASTPIX_DEBUG to true.
How do I install the FastPix Python SDK?
Run pip install fastpix-python (or uv add fastpix-python / poetry add fastpix-python). See Start here.
How do I authenticate the SDK?
FastPix uses Basic Auth: pass your access token as username and your secret key as password in models.Security when constructing the client. See Before you begin.
How do I upload a video in Python?
Create media from a URL or a direct upload through fastpix.input_video, for example fastpix.input_video.create_media(...). See Create media and Available Resources and Operations.
Does the SDK support async? Yes - it provides both synchronous and asynchronous clients. See Custom HTTP Client.
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 get video analytics and metrics in Python? 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/except and catch errors.FastpixError, which exposes the message, status code, headers, and body. See Error Handling.
How do I configure automatic retries?
Pass a RetryConfig per call or at client initialization to control the backoff strategy. See Retries.
How do I use a custom HTTP client, proxy, or timeout?
Pass your own httpx client (sync or async) to configure timeouts, proxies, and custom headers. See Custom HTTP Client.
How do I enable debug logging?
Pass a logger to the client or set the FASTPIX_DEBUG environment variable. See Debugging.
Which Python versions are supported? Python 3.9.2 and above. See Before you begin.
FastPix publishes a server SDK for every major backend language, each generated from the same API specification:
| Language | Repo | Install |
|---|---|---|
| Python (this repo) | fastpix-python | pip install fastpix-python |
| Node.js / TypeScript | node-sdk | npm install @fastpix/fastpix-node |
| PHP | fastpix-php | composer require fastpix/sdk |
| 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 Python 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.