A robust, type-safe Node.js SDK designed for seamless integration with the FastPix API platform.
The FastPix Node.js SDK simplifies integration with the FastPix platform. It provides a clean, TypeScript 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 Node.js 18 and above.
Requirement | Version | Description |
---|---|---|
Node.js | 18+ |
Core runtime environment |
npm/yarn/pnpm | Latest |
Package manager for dependencies |
Internet | Required |
API communication and authentication |
Pro Tip: We recommend using Node.js 20+ for optimal performance and the latest language features.
To get started with the FastPix Node.js 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.
Install the FastPix Node.js SDK using your preferred package manager:
npm install @fastpix/fastpix-node
pnpm add @fastpix/fastpix-node
bun add @fastpix/fastpix-node
yarn add @fastpix/fastpix-node
Import the necessary modules for your FastPix integration:
// Basic imports
import { Fastpix } from "@fastpix/fastpix-node";
import type { CreateMediaRequest } from "@fastpix/fastpix-node/models/operations";
Initialize the FastPix SDK with your credentials:
import { Fastpix } from "@fastpix/fastpix-node";
const fastpix = new Fastpix({
security: {
username: "your-access-token",
password: "your-secret-key",
},
});
Or using environment variables:
import { Fastpix } from "@fastpix/fastpix-node";
const fastpix = new Fastpix({
security: {
username: process.env.FASTPIX_USERNAME,
password: process.env.FASTPIX_PASSWORD,
},
});
import { Fastpix } from "@fastpix/fastpix-node";
const fastpix = new Fastpix({
security: {
username: "your-access-token",
password: "your-secret-key",
},
});
async function run() {
const result = await fastpix.inputVideo.createMedia({
inputs: [
{
type: "video",
url: "https://static.fastpix.io/sample.mp4",
},
],
metadata: {
"key1": "value1",
},
accessPolicy: "public",
});
// handle response
console.log(result);
}
run();
Comprehensive Node.js 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
- Add Track - Add audio or subtitle tracks to media
- Cancel Upload - Stop ongoing media upload process
- Update Track - Modify existing audio or subtitle tracks
- Delete Track - Remove audio or subtitle tracks
- Generate Subtitles - Create automatic subtitles for media
- Update Source Access - Control access permissions for media source
- Update MP4 Support - Configure MP4 download capabilities
- Get Input Info - Retrieve detailed input information
- List Uploads - Get all available upload URLs
- Get Media Clips - Retrieve all video clips for media
- Create Playback ID - Generate secure playback identifier
- Delete Playback ID - Remove playback access
- Get Playback ID - Retrieve playback configuration details
- 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
- 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 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
- Get Concurrent Viewers - Monitor real-time viewer counts over time
- Get Viewer Breakdown - Analyze viewers by device, location, and other dimensions
- List Dimensions - Get available data dimensions for filtering and analysis
- List Filter Values - Get specific values for a particular dimension
Enhance video content with AI-powered features including moderation, summarization, and intelligent categorization.
For detailed documentation, see Video Moderation Guide.
- Generate 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
Handle and manage errors with comprehensive error handling capabilities and detailed error information for all API operations.
- List Errors - Retrieve comprehensive error logs and diagnostics
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 { Fastpix } from "@fastpix/fastpix-node";
const fastpix = new Fastpix({
security: {
username: "your-access-token",
password: "secret-key",
},
});
async function run() {
const result = await fastpix.inputVideo.createMedia({
inputs: [
{
type: "video",
url: "https://static.fastpix.io/sample.mp4",
},
],
metadata: {
"key1": "value1",
},
accessPolicy: "public",
}, {
retries: {
strategy: "backoff",
backoff: {
initialInterval: 1,
maxInterval: 50,
exponent: 1.1,
maxElapsedTime: 100,
},
retryConnectionErrors: false,
},
});
console.log(result);
}
run();
If you'd like to override the default retry strategy for all operations that support retries, you can provide a retryConfig at SDK initialization:
import { Fastpix } from "@fastpix/fastpix-node";
const fastpix = new Fastpix({
retryConfig: {
strategy: "backoff",
backoff: {
initialInterval: 1,
maxInterval: 50,
exponent: 1.1,
maxElapsedTime: 100,
},
retryConnectionErrors: false,
},
security: {
username: "your-access-token",
password: "secret-key",
},
});
async function run() {
const result = await fastpix.inputVideo.createMedia({
inputs: [
{
type: "video",
url: "https://static.fastpix.io/sample.mp4",
},
],
metadata: {
"key1": "value1",
},
accessPolicy: "public",
});
console.log(result);
}
run();
FastpixError
is the base class for all HTTP error responses. It has the following properties:
Property | Type | Description |
---|---|---|
error.message |
string |
Error message |
error.statusCode |
number |
HTTP response status code eg 404 |
error.headers |
Headers |
HTTP response headers |
error.body |
string |
HTTP body. Can be empty string if no body is returned. |
error.rawResponse |
Response |
Raw HTTP response |
error.data$ |
Optional. Some errors may contain structured data. See Error Classes. |
import { Fastpix } from "@fastpix/fastpix-node";
import * as errors from "@fastpix/fastpix-node/models/errors";
const fastpix = new Fastpix({
security: {
username: "your-access-token",
password: "secret-key",
},
});
async function run() {
try {
const result = await fastpix.inputVideo.createMedia({
inputs: [
{
type: "video",
url: "https://static.fastpix.io/sample.mp4",
},
],
metadata: {
"key1": "value1",
},
accessPolicy: "public",
});
console.log(result);
} catch (error) {
// The base class for HTTP error responses
if (error instanceof errors.FastpixError) {
console.log(error.message);
console.log(error.statusCode);
console.log(error.body);
console.log(error.headers);
// Depending on the method different errors may be thrown
if (error instanceof errors.BadRequestError) {
console.log(error.data$.success); // boolean
console.log(error.data$.error); // models.BadRequestError
}
}
}
}
run();
Primary errors:
FastpixError
: The base class for HTTP error responses.InvalidPermissionError
: *ValidationErrorResponse
: Status code422
. *
Less common errors (28)
Network errors:
ConnectionError
: HTTP client was unable to make a request to a server.RequestTimeoutError
: HTTP request timed out due to an AbortSignal signal.RequestAbortedError
: HTTP request was aborted by the client.InvalidRequestError
: Any input used to create a request is invalid.UnexpectedClientError
: Unrecognised or unexpected error.
Inherit from FastpixError
:
ForbiddenError
: Status code403
. Applicable to 26 of 66 methods.*UnauthorizedError
: Applicable to 24 of 66 methods.*MediaNotFoundError
: Status code404
. Applicable to 17 of 66 methods.*BadRequestError
: Bad Request. Status code400
. Applicable to 10 of 66 methods.*NotFoundError
: Status code404
. Applicable to 8 of 66 methods.*ViewNotFoundError
: View Not Found. Status code404
. Applicable to 7 of 66 methods.*LiveNotFoundError
: Stream Not Found. Status code404
. Applicable to 6 of 66 methods.*InvalidPlaylistIdResponseError
: Payload Validation Failed. Status code422
. Applicable to 6 of 66 methods.*UnAuthorizedResponseError
: response for unauthorized request. Status code401
. Applicable to 4 of 66 methods.*ForbiddenResponseError
: response for forbidden request. Status code403
. Applicable to 4 of 66 methods.*TrackDuplicateRequestError
: Duplicate language name. Status code400
. Applicable to 3 of 66 methods.*NotFoundErrorSimulcast
: Stream/Simulcast Not Found. Status code404
. Applicable to 3 of 66 methods.*MediaOrPlaybackNotFoundError
: Status code404
. Applicable to 2 of 66 methods.*NotFoundErrorPlaybackId
: Status code404
. Applicable to 2 of 66 methods.*SigningKeyNotFoundError
: Bad Request. Status code404
. Applicable to 2 of 66 methods.*DuplicateMp4SupportError
: Mp4Support value already exists. Status code400
. Applicable to 1 of 66 methods.*TrialPlanRestrictionError
: Bad Request – Stream is either already enabled or cannot be enabled on trial plan. Status code400
. Applicable to 1 of 66 methods.*StreamAlreadyEnabledError
: Bad Request – Stream is either already enabled or cannot be enabled on trial plan. Status code400
. Applicable to 1 of 66 methods.*StreamAlreadyDisabledError
: Stream already disabled. Status code400
. Applicable to 1 of 66 methods.*SimulcastUnavailableError
: Simulcast is not available for trial streams. Status code400
. Applicable to 1 of 66 methods.*MediaClipNotFoundError
: media workspace relation not found. Status code404
. Applicable to 1 of 66 methods.*DuplicateReferenceIdErrorResponse
: Displays the result of the request. Status code409
. Applicable to 1 of 66 methods.*ResponseValidationError
: Type mismatch between the data returned from the server and the structure expected by the SDK. Seeerror.rawValue
for the raw value anderror.pretty()
for a nicely formatted multi-line string.
* Check the method documentation to see if the error is applicable.
The default server can be overridden globally by passing a URL to the serverURL: string
optional parameter when initializing the SDK client instance. For example:
import { Fastpix } from "@fastpix/fastpix-node";
const fastpix = new Fastpix({
serverURL: "https://api.fastpix.io/v1/",
security: {
username: "your-access-token",
password: "secret-key",
},
});
async function run() {
const result = await fastpix.inputVideo.createMedia({
inputs: [
{
type: "video",
url: "https://static.fastpix.io/sample.mp4",
},
],
metadata: {
"key1": "value1",
},
accessPolicy: "public",
});
console.log(result);
}
run();
The TypeScript SDK makes API calls using an HTTPClient
that wraps the native
Fetch API. This
client is a thin wrapper around fetch
and provides the ability to attach hooks
around the request lifecycle that can be used to modify the request or handle
errors and response.
The HTTPClient
constructor takes an optional fetcher
argument that can be
used to integrate a third-party HTTP client or when writing tests to mock out
the HTTP client and feed in fixtures.
The following example shows how to use the "beforeRequest"
hook to to add a
custom header and a timeout to requests and how to use the "requestError"
hook
to log errors:
import { Fastpix } from "@fastpix/fastpix-node";
import { HTTPClient } from "@fastpix/fastpix-node/lib/http";
const httpClient = new HTTPClient({
// fetcher takes a function that has the same signature as native `fetch`.
fetcher: (request) => {
return fetch(request);
}
});
httpClient.addHook("beforeRequest", (request) => {
const nextRequest = new Request(request, {
signal: request.signal || AbortSignal.timeout(5000)
});
nextRequest.headers.set("x-custom-header", "custom value");
return nextRequest;
});
httpClient.addHook("requestError", (error, request) => {
console.group("Request Error");
console.log("Reason:", `${error}`);
console.log("Endpoint:", `${request.method} ${request.url}`);
console.groupEnd();
});
const sdk = new Fastpix({ httpClient: httpClient });
This Node.js 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.