Python Client SDK Generated by fastpix.
Project description
FastPix Python SDK
A robust, type-safe Python SDK designed for seamless integration with the FastPix API platform.
Introduction
The FastPix Python SDK simplifies integration with the FastPix platform. It provides a clean, Python 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 Python 3.9.2 and above.
Prerequisites
Environment and Version Support
| Requirement | Version | Description |
|---|---|---|
| Python | 3.9.2+ |
Core runtime environment |
| pip/uv/poetry | Latest |
Package manager for dependencies |
| Internet | Required |
API communication and authentication |
Pro Tip: We recommend using Python 3.11+ for optimal performance and the latest language features.
Getting Started with FastPix
To get started with the FastPix Python 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.
Environment Variables (Optional)
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.
Table of Contents
Setup
Installation
Install the FastPix Python SDK using your preferred package manager:
uv
uv is a fast Python package installer and resolver, designed as a drop-in replacement for pip and pip-tools. It's recommended for its speed and modern Python tooling capabilities.
uv add fastpix-python
pip
pip is the default package installer for Python, enabling easy installation and management of packages from PyPI via the command line.
pip install fastpix-python
Poetry
Poetry is a modern tool that simplifies dependency management and package publishing by using a single pyproject.toml file to handle project metadata and dependencies.
poetry add fastpix-python
Shell and Script Usage with uv
You can use this SDK in a Python shell with uv and the uvx command that comes with it like so:
uvx --from fastpix-python python
It's also possible to write a standalone Python script without needing to set up a whole project like so:
#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.9"
# dependencies = [
# "fastpix-python",
# ]
# ///
from fastpix_python import Fastpix, models
sdk = Fastpix(
security=models.Security(
username="your-access-token",
password="your-secret-key",
),
)
# Rest of script here...
Once that is saved to a file, you can run it with uv run script.py where script.py can be replaced with the actual file name.
IDE Support
PyCharm
Generally, the SDK will work well with most IDEs out of the box. However, when using PyCharm, you can enjoy much better integration with Pydantic by installing an additional plugin.
Initialization
Initialize the FastPix SDK with your credentials:
from fastpix_python import Fastpix, models
fastpix = Fastpix(
security=models.Security(
username="your-access-token",
password="your-secret-key",
),
)
Or using environment variables:
import os
from fastpix_python import Fastpix, models
fastpix = Fastpix(
security=models.Security(
username=os.getenv("FASTPIX_USERNAME"), # Your Access Token
password=os.getenv("FASTPIX_PASSWORD"), # Your Secret Key
),
)
Example Usage
import os
import sys
import json
# Add the src directory to the Python path so we can import fastpix_python
sys.path.append(os.path.join(os.path.dirname(__file__), "..", "src"))
from fastpix_python import Fastpix, models
with Fastpix(
security=models.Security(
username="your-access-token",
password="your-secret-key",
),
) as fastpix:
res = fastpix.input_video.create_from_url(
inputs=[
{
"type": "video",
"url": "https://static.fastpix.io/fp-sample-video.mp4",
},
],
metadata={
"key1": "value1",
},
)
print(json.dumps(res.model_dump(mode="json", by_alias=True), indent=2))
Available Resources and Operations
Comprehensive Python SDK for FastPix platform integration with full API coverage.
Media API
Upload, manage, and transform video content with comprehensive media management capabilities.
For detailed documentation, see FastPix Video on Demand Overview.
Input Video
- Create from URL - Upload video content from external URL
- Upload from Device - Upload video files directly from device
Manage Videos
- 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
Playback
- 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
Playlist
- 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
Signing Keys
- 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
DRM Configurations
- List DRM Configs - Get all DRM configuration options
- Get DRM Config - Retrieve specific DRM configuration
Live API
Stream, manage, and transform live video content with real-time broadcasting capabilities.
For detailed documentation, see FastPix Live Stream Overview.
Start Live Stream
- Create Stream - Initialize new live streaming session with DVR mode support
Manage Live Stream
- 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
Live Playback
- Create Playback ID - Generate secure live playback access
- Delete Playback ID - Revoke live playback access
- Get Playback ID - Retrieve live playback configuration
Simulcast Stream
- Create Simulcast - Set up multi-platform streaming
- Delete Simulcast - Remove simulcast configuration
- Get Simulcast - Retrieve simulcast settings
- Update Simulcast - Modify simulcast parameters
Video Data API
Monitor video performance and quality with comprehensive analytics and real-time metrics.
For detailed documentation, see FastPix Video Data Overview.
Metrics
- 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
Views
- 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
Dimensions
- List Dimensions - Get available data dimensions for filtering and analysis
- List Filter Values - Get specific values for a particular dimension
Errors
- List Errors - Retrieve playback errors and issues
Transformations
Transform and enhance your video content with powerful AI and editing capabilities.
In-Video AI Features
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
Media Clips
- Get Media Clips - Retrieve all clips associated with a source media
Subtitles
- Generate Subtitles - Create automatic subtitles for media
Media Tracks
- Add Track - Add audio or subtitle tracks to media
- Update Track - Modify existing audio or subtitle tracks
- Delete Track - Remove audio or subtitle tracks
Access Control
- Update Source Access - Control access permissions for media source
Format Support
- Update MP4 Support - Configure MP4 download capabilities
Retries
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 sys
import json
# Add the src directory to the Python path so we can import fastpix_python
sys.path.append(os.path.join(os.path.dirname(__file__), "..", "src"))
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_from_url(
inputs=[
{
"type": "video",
"url": "https://static.fastpix.io/fp-sample-video.mp4",
},
],
metadata={
"key1": "value1",
},
retries=RetryConfig(
"backoff",
BackoffStrategy(1, 50, 1.1, 100),
False
),
)
print(json.dumps(res.model_dump(mode="json", by_alias=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 sys
import json
# Add the src directory to the Python path so we can import fastpix_python
sys.path.append(os.path.join(os.path.dirname(__file__), "..", "src"))
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_from_url(
inputs=[
{
"type": "video",
"url": "https://static.fastpix.io/fp-sample-video.mp4",
},
],
metadata={
"key1": "value1",
},
)
print(json.dumps(res.model_dump(mode="json", by_alias=True), indent=2))
Error Handling
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 |
Example
import os
import sys
import json
# Add the src directory to the Python path so we can import fastpix_python
sys.path.append(os.path.join(os.path.dirname(__file__), "..", "src"))
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_from_url(
inputs=[
{
"type": "video",
"url": "https://static.fastpix.io/fp-sample-video.mp4",
},
],
metadata={
"key1": "value1",
},
)
print(json.dumps(res.model_dump(mode="json", by_alias=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)
Error Classes
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.
Server Selection
Override Server URL Per-Client
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 sys
import json
# Add the src directory to the Python path so we can import fastpix_python
sys.path.append(os.path.join(os.path.dirname(__file__), "..", "src"))
from fastpix_python import Fastpix, models
with Fastpix(
server_url="https://api.fastpix.io/v1/",
security=models.Security(
username="your-access-token",
password="your-secret-key",
),
) as fastpix:
res = fastpix.input_video.create_from_url(
inputs=[
{
"type": "video",
"url": "https://static.fastpix.io/fp-sample-video.mp4",
},
],
metadata={
"key1": "value1",
},
)
print(json.dumps(res.model_dump(mode="json", by_alias=True), indent=2))
Custom HTTP Client
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",
),
)
Debugging
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.
Development
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.
Detailed Usage
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fastpix_python-1.1.0.tar.gz.
File metadata
- Download URL: fastpix_python-1.1.0.tar.gz
- Upload date:
- Size: 173.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb44404e843ce905eb63b001f0cebb540e4333abaec9c241b713507247afe6c1
|
|
| MD5 |
5c7cd0c3fa539a186ec66f3a86ae1bda
|
|
| BLAKE2b-256 |
53a379afe2790acb5b4bdc8d88a602c3823654b5ee2508c66751bcf6aac0ab5b
|
File details
Details for the file fastpix_python-1.1.0-py3-none-any.whl.
File metadata
- Download URL: fastpix_python-1.1.0-py3-none-any.whl
- Upload date:
- Size: 291.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
58ba9b433de396a8eecd00279a6dac8bde2fcfa48ed2ae8d4ede6392d7c85429
|
|
| MD5 |
71b1e24ef36e482a8bed8f9ef4a4d03f
|
|
| BLAKE2b-256 |
4a550a0a092dc9604342b5ed3d3afb071eb62ffdaf23a561da76acccd5fd5740
|