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-nodepnpm add @fastpix/fastpix-nodebun add @fastpix/fastpix-nodeyarn add @fastpix/fastpix-nodeThis SDK supports both ES modules and CommonJS. Examples in this documentation use ES module syntax as it's the preferred format, but you can use either approach.
import { Fastpix } from "@fastpix/fastpix-node";
import type { CreateMediaRequest } from "@fastpix/fastpix-node/models";const { Fastpix } = require("@fastpix/fastpix-node");Why ES Modules? ES modules provide better tree-shaking, static analysis, and are the modern JavaScript standard.
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, // Your Access Token
password: process.env.FASTPIX_PASSWORD, // Your Secret Key
},
});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.create({
inputs: [
{
type: "video",
url: "https://static.fastpix.io/fp-sample-video.mp4",
},
],
metadata: {
"key1": "value1",
},
});
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
- Cancel Upload - Stop ongoing media upload process
- Get Input Info - Retrieve detailed input information
- 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
- 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
- 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
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 the methods listed above are available as standalone functions. These functions are ideal for use in applications running in the browser, serverless runtimes or other environments where application bundle size is a primary concern. When using a bundler to build your application, all unused functionality will be either excluded from the final bundle or tree-shaken away.
To read more about standalone functions, check FUNCTIONS.md.
Available standalone functions
aiFeaturesGenerateNamedEntities- Generate named entitiesaiFeaturesUpdateSummary- Generate video summarydimensionsList- List the dimensionsdimensionsListFilterValues- List the filter values for a dimensiondrmConfigurationsGet- Get DRM configuration by IDdrmConfigurationsList- Get list of DRM configuration IDserrorsList- List errorsinputVideoCreate- Create media from URLinputVideoUpload- Upload media from deviceinVideoAIfeaturesGenerateChapters- Generate video chaptersinVideoAIUpdateModeration- Enable video moderationlivePlaybackCreateId- Create a playbackIdlivePlaybackDelete- Delete a playbackIdlivePlaybackGet- Get playbackId detailsliveStreamsCreate- Create a new streamliveStreamsDelete- Delete a streamliveStreamsEnable- Enable a streamliveStreamsList- Get all live streamsliveStreamsListClips- Get all clips of a live streammanageLiveStreamComplete- Complete a streammanageLiveStreamDisable- Disable a streammanageLiveStreamGet- Get stream by IDmanageLiveStreamGetViewerCount- Get stream views by IDmanageLiveStreamUpdate- Update a streammanageVideosAddTrack- Add audio / subtitle trackmanageVideosCancelUpload- Cancel ongoing uploadmanageVideosDelete- Delete a media by IDmanageVideosGenerateSubtitleTrack- Generate track subtitlemanageVideosGet- Get a media by IDmanageVideosGetSummary- Get the summary of a videomanageVideosListUploads- Get all unused upload URLsmanageVideosRetrieveMediaInputInfo- Get info of media inputsmanageVideosUpdate- Update a media by IDmanageVideosUpdateMp4Support- Update the mp4Support of a media by IDmanageVideosUpdateTrack- Update audio / subtitle trackmediaDeleteTrack- Delete audio / subtitle trackmediaGetClips- Get all clips of a mediamediaList- Get list of all mediamediaUpdateSourceAccess- Update the source access of a media by IDmetricsGetTimeseriesData- Get timeseries datametricsListBreakdownValues- List breakdown valuesmetricsListCompares- List comparison valuesmetricsListOverallValues- List overall valuesplaybackCreate- Create a playback IDplaybackDelete- Delete a playback IDplaybackGet- Get a playback IDplaybackListIds- Get all playback IDs details for a mediaplaybackUpdateDomainRestrictions- Update domain restrictions for a playback IDplaybackUpdateUserAgentRestrictions- Update user-agent restrictions for a playback IDplaylistCreate- Create a new playlistplaylistDelete- Delete a playlist by IDplaylistGet- Get a playlist by IDplaylistList- Get all playlistsplaylistsAddMedia- Add media to a playlist by IDplaylistsDeleteMedia- Delete media in a playlist by IDplaylistUpdate- Update a playlist by IDplaylistUpdateMediaOrder- Change media order in a playlist by IDsigningKeysCreate- Create a signing keysigningKeysDelete- Delete a signing keysigningKeysGetById- Get signing key by IDsigningKeysList- Get list of signing keysimulcastsCreate- Create a simulcastsimulcastsGet- Get a specific simulcastsimulcastStreamsDelete- Delete a simulcastsimulcastsUpdate- Update a simulcastviewsGetDetails- Get details of video viewviewsList- List video viewsviewsListTopContent- List by top content
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: "your-secret-key",
},
});
async function run() {
const result = await fastpix.inputVideo.create({
inputs: [
{
type: "video",
url: "https://static.fastpix.io/fp-sample-video.mp4",
},
],
metadata: {
"key1": "value1",
},
}, {
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: "your-secret-key",
},
});
async function run() {
const result = await fastpix.inputVideo.create({
inputs: [
{
type: "video",
url: "https://static.fastpix.io/fp-sample-video.mp4",
},
],
metadata: {
"key1": "value1",
},
});
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 |
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: "your-secret-key",
},
});
async function run() {
try {
const result = await fastpix.inputVideo.create({
inputs: [
{
type: "video",
url: "https://static.fastpix.io/fp-sample-video.mp4",
},
],
metadata: {
"key1": "value1",
},
});
console.log(result);
} catch (error) {
if (error instanceof errors.FastpixError) {
console.log(error.message);
console.log(error.statusCode);
console.log(error.body);
console.log(error.headers);
}
}
}
run();Primary error:
FastpixError: The base class for HTTP error responses.
Less common errors (6)
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:
ResponseValidationError: Type mismatch between the data returned from the server and the structure expected by the SDK. Seeerror.rawValuefor the raw value anderror.pretty()for a nicely formatted multi-line string.
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: "your-secret-key",
},
});
async function run() {
const result = await fastpix.inputVideo.create({
inputs: [
{
type: "video",
url: "https://static.fastpix.io/fp-sample-video.mp4",
},
],
metadata: {
"key1": "value1",
},
});
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 });You can setup your SDK to emit debug logs for SDK requests and responses.
You can pass a logger that matches console's interface as an SDK option.
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.
import { Fastpix } from "@fastpix/fastpix-node";
const sdk = new Fastpix({ debugLogger: console });You can also enable a default debug logger by setting an environment variable FASTPIX_DEBUG to true.
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.