Skip to navigation

FastPix Node.js SDK

Learn how the FastPix Node.js SDK enables video uploads, live streaming, and playback management in Node.js applications.

The FastPix Node.js SDK is a type-safe Node.js client for the FastPix video API. From any Node.js 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, verify webhooks, and use in-video AI features. It ships TypeScript types and works with both ES modules (ESM) and CommonJS.


Find more in the SDK reference

For all methods, runnable examples, and advanced usage, see the FastPix Node.js SDK on GitHub.


Before you begin

Make sure you have:

FastPix uses HTTP Basic Authentication. The SDK maps your credentials as follows:

SDK valueFastPix credential
usernameAccess Token
passwordSecret Key

Security: Never commit your Access Token or Secret Key to source control. Use environment variables or a secure credential-management system.

Follow the steps below in order, and do not skip the verification steps. If installation, the ES module configuration, authentication, client initialization, or the first API request fails, fix that problem before continuing.


Check your Node.js version

node --version

The output is similar to v20.19.0 or a later version. The SDK supports Node.js 18 and later. If your version is earlier than 18, install a supported version before continuing.

You can also check your npm version:

npm --version

Create a Node.js project

Create a directory for your application and initialize a Node.js project:

mkdir fastpix-node-sdk-demo
cd fastpix-node-sdk-demo
npm init -y

npm init -y creates a package.json file. Configure the project to use ES modules by adding "type": "module" to package.json:

{
"name": "fastpix-node-sdk-demo",
"version": "1.0.0",
"type": "module",
"main": "example.js",
"scripts": {
"start": "node example.js"
}
}

The "type": "module" setting tells Node.js to treat .js files as ES modules, so you can use import { Fastpix } from "@fastpix/fastpix-node"; instead of require(...).


Install the FastPix SDK

Install the FastPix Node.js SDK with npm:

npm install @fastpix/fastpix-node

The SDK is added to your project’s dependencies and installed in node_modules. You can confirm the installed package:

npm list @fastpix/fastpix-node

Verify the SDK installation

Confirm that Node.js can import the SDK. Create a file named example.js:

import { Fastpix } from "@fastpix/fastpix-node";
console.log("FastPix SDK imported successfully");

Run it:

node example.js

The expected output is FastPix SDK imported successfully. If it fails, confirm that Node.js 18 or later is installed, "type": "module" is set in package.json, @fastpix/fastpix-node is installed, and you are running the command from the project directory.


Configure authentication

FastPix uses HTTP Basic Authentication, where username is your Access Token and password is your Secret Key. For local development, set these as environment variables so they stay out of your source code:

# macOS and Linux
export FASTPIX_USERNAME="<YOUR_ACCESS_TOKEN>"
export FASTPIX_PASSWORD="<YOUR_SECRET_KEY>"
# Windows PowerShell
$env:FASTPIX_USERNAME="<YOUR_ACCESS_TOKEN>"
$env:FASTPIX_PASSWORD="<YOUR_SECRET_KEY>"

Verify that your credentials are set

Check that both variables are set without printing their values:

node -e 'console.log("Access Token:", process.env.FASTPIX_USERNAME ? "set" : "missing"); console.log("Secret Key:", process.env.FASTPIX_PASSWORD ? "set" : "missing")'

Both should report set. If either is missing, set the corresponding environment variable before continuing.


Initialize the FastPix client

Replace the contents of example.js with:

import { Fastpix } from "@fastpix/fastpix-node";
const fastpix = new Fastpix({
security: {
username: process.env.FASTPIX_USERNAME,
password: process.env.FASTPIX_PASSWORD,
},
});
console.log("FastPix client initialized");

Run it:

node example.js

The expected output is FastPix client initialized. Initializing the client does not make an API request; a request happens only when you call an SDK operation such as fastpix.inputVideo.create(...).


Make your first API request

The easiest way to verify the integration is to create media from a publicly accessible video URL. FastPix provides a sample video at https://static.fastpix.com/fp-sample-video.mp4.

Replace the contents of example.js with:

import { Fastpix } from "@fastpix/fastpix-node";
const fastpix = new Fastpix({
security: {
username: process.env.FASTPIX_USERNAME,
password: process.env.FASTPIX_PASSWORD,
},
});
async function run() {
const response = await fastpix.inputVideo.create({
inputs: [
{
type: "video",
url: "https://static.fastpix.com/fp-sample-video.mp4",
},
],
metadata: {
source: "fastpix-node-sdk-demo",
},
});
console.log(JSON.stringify(response, null, 2));
}
run().catch((error) => {
console.error("FastPix API request failed");
console.error(error);
process.exit(1);
});

Run it:

node example.js

A successful request returns information about the newly created media asset, similar to:

{
"success": true,
"data": {
"id": "5157e363-5abb-414d-83c7-520ecdc9f5fd",
"status": "Created"
}
}

The exact fields depend on the API response and the installed SDK version. A media_id is not the same as a playback_id. They identify different resources and are used for different operations.


Retrieve the media asset

Use the media ID returned by the create operation to retrieve the media asset. Replace the contents of example.js with:

import { Fastpix } from "@fastpix/fastpix-node";
const fastpix = new Fastpix({
security: {
username: process.env.FASTPIX_USERNAME,
password: process.env.FASTPIX_PASSWORD,
},
});
async function run() {
console.log("Creating media...");
const createResult = await fastpix.inputVideo.create({
inputs: [
{
type: "video",
url: "https://static.fastpix.com/fp-sample-video.mp4",
},
],
metadata: {
source: "fastpix-node-sdk-demo",
},
});
console.log("CREATE MEDIA", JSON.stringify(createResult, null, 2));
const mediaId = createResult.data.id;
console.log("\nMEDIA ID:", mediaId);
console.log("\nRetrieving media...");
const mediaResult = await fastpix.manageVideos.get({ mediaId });
console.log("\nGET MEDIA", JSON.stringify(mediaResult, null, 2));
}
run().catch((error) => {
console.error("\nFastPix API request failed");
console.error(error);
process.exit(1);
});

Run it:

node example.js

A successful response from the get-media operation confirms that the SDK authenticated, the media was created, a media ID was returned, and the media ID can be used in a subsequent API operation.


Verify the integration

A successful create-then-get flow confirms that Node.js is installed and supported, your project is configured to use ES modules, the SDK is installed and importable, your credentials are configured, the client can authenticate, and you can create and retrieve a media asset.

FastPix Node.js SDK workflow: a Node.js application calls the FastPix Node.js SDK, which authenticates to the FastPix API over HTTP Basic Auth, creates a media asset, returns a media ID (data.id), then retrieves the media.

Creating media is usually the first step in a FastPix on-demand workflow: you create the media, poll it until processing finishes, then create a playback ID to play it. The initial SDK integration is now complete.


Resources, error handling, and reference

The SDK is generated from the FastPix API specification, so the complete and always-current reference lives in the repo and the API docs:

  • All resources, operations, error handling, retries, server selection, custom HTTP clients, standalone (tree-shakeable) functions, webhooks, and debugging: the FastPix Node.js SDK on GitHub, with runnable code in the examples directory.
  • Media (upload, manage, playback, playlists, signing keys, DRM): Video on Demand API.
  • Live (streams, simulcasts, live playback): Live Stream API.
  • Video Data (metrics, views, dimensions, errors): Video Data API.
  • In-video AI (summaries, chapters, named entities, moderation): In-Video AI.

Frequently asked questions

What is the difference between the FastPix Node.js SDK and the REST API?

The SDK is a type-safe Node.js wrapper around the same FastPix REST API. It handles authentication, request serialization, and response parsing for you, so you call methods like fastpix.inputVideo.create(...) instead of building raw HTTP requests. Anything the SDK does, you can also do by calling the REST API directly. See Make your first API request.

How do I install the FastPix Node.js SDK?

Run npm install @fastpix/fastpix-node in your project, or the pnpm, yarn, or bun equivalent. See Install the FastPix SDK.

How do I authenticate the SDK?

FastPix uses HTTP Basic Authentication. Pass your Access Token as the username and your Secret Key as the password in the security object when constructing the client. See Initialize the FastPix client.

Does it support TypeScript, ESM, and CommonJS?

Yes. The package ships TypeScript type definitions and works with both ES modules and CommonJS. For ESM, set "type": "module" in package.json. See Create a Node.js project.

How do I upload a video in Node.js?

Create media from a URL or a direct upload through the input-video resource on the client, for example fastpix.inputVideo.create(...). See Make your first API request.

What is the maximum video file size I can upload with Node.js?

FastPix uploads are not limited by your Node.js process memory. When you pull from a URL, FastPix fetches the file directly, and when you upload from a device, the SDK gives you a signed URL that the file goes to directly, so the bytes never pass through your Node.js application. Large multi-gigabyte files upload without extra configuration. See the Video on Demand API.

How do I start a live stream?

Use the Live API resources to create and manage streams, simulcasts, and live playback IDs. See the SDK reference on GitHub and the Live Stream API.

How do I create a secure playback ID?

Generate playback IDs and manage signing keys and DRM configurations through the Media API resources. See the SDK reference on GitHub and the Video on Demand API.

How do I keep a video private or stop it from being downloaded?

Create the media with a private access policy, then generate a signed playback ID so only holders of a valid token can play it. For stronger protection, enable DRM on the playback ID. You revoke access by deleting the playback ID. Handle all of this through the Media API resources. See the Video on Demand API.

How do I verify FastPix webhooks in Node.js?

The SDK includes webhook signature verification through the webhooks resource, which verifies the signature and returns the parsed, trusted event in one call. The signing secret is separate from your API credentials. See the SDK reference on GitHub.

How do I get video analytics and metrics in Node.js?

The Video Data API exposes metrics, views, dimensions, and errors for quality-of-experience monitoring. See the Video Data API.

How do I handle API errors?

Wrap calls in try/catch and check for the typed FastpixError, which exposes the message, status code, headers, and body. See the SDK reference on GitHub for the error types each operation can throw.

How do I configure automatic retries?

Pass a retry configuration per call or at client initialization to control the backoff strategy. See the SDK reference on GitHub.

How do I reduce bundle size with tree-shaking?

Every method is also available as a standalone function, so bundlers can tree-shake away everything you do not import. This is useful in serverless and browser-adjacent runtimes. See the SDK reference on GitHub.

Which Node.js versions are supported?

Node.js 18 and later. See Before you begin.


What’s next

Want to go further? Browse runnable, end-to-end samples for the FastPix Node.js SDK in the examples folder of the GitHub repository.


Release notes

For a complete history of releases, improvements, and fixes, see the FastPix Node.js SDK CHANGELOG on GitHub.