Skip to content

Latest commit

 

History

History
402 lines (285 loc) · 27.9 KB

File metadata and controls

402 lines (285 loc) · 27.9 KB

Media

Overview

Available Operations

list

This endpoint returns a list of all media files uploaded to FastPix within a specific workspace. Each media entry contains data such as the media id, createdAt, status, type and more. It allows you to retrieve an overview of your media assets, making it easier to manage and review them.

How it works

Use the access token and secret key related to the workspace in the request header. When called, the API provides a paginated response containing all the media items in that specific workspace. This is helpful for retrieving a large volume of media and managing content in bulk.

Example

If you manage a video platform and need to review all uploaded media in your library to ensure that outdated or low-quality content isn’t being served, you can use this endpoint to retrieve a complete list of media. You can then filter, sort, or update items as needed.

Example Usage

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.media.list({
    limit: 20,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { FastpixCore } from "@fastpix/fastpix-node/core.js";
import { mediaList } from "@fastpix/fastpix-node/funcs/mediaList.js";

// Use `FastpixCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const fastpix = new FastpixCore({
  security: {
    username: "your-access-token",
    password: "your-secret-key",
  },
});

async function run() {
  const res = await mediaList(fastpix, {
    limit: 20,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("mediaList failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.ListMediaRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.ListMediaResponse>

Errors

Error Type Status Code Content Type
errors.FastpixDefaultError 4XX, 5XX */*

deleteTrack

This endpoint allows you to delete an existing audio or subtitle track from a media file. Once deleted, the track must no longer be available for playback.

How it works

  1. Send a DELETE request to this endpoint, replacing {mediaId} with the media ID, and {trackId} with the ID of the track you want to remove.

  2. The track gets deleted from the media file, and you must receive a confirmation response.

Webhook events

  1. After successfully deleting a track, your system must receive the webhook event video.media.track.deleted.

  2. Once the media file is updated to reflect the track removal, a video.media.updated event must be triggered.

Example

Suppose you uploaded an audio track in Italian for a video but later realize it's incorrect or no longer needed. By calling this API, you can remove the specific track while keeping the rest of the media file unchanged. This is useful when:

  • A track was mistakenly added and needs to be removed.
  • The content owner requests the removal of a specific subtitle or audio track.
  • A new version of the track gets uploaded to replace the existing one.

Related guides: Add own subtitle tracks, Add own audio tracks

Example Usage

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.media.deleteTrack({
    mediaId: "your-media-id",
    trackId: "your-track-id",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { FastpixCore } from "@fastpix/fastpix-node/core.js";
import { mediaDeleteTrack } from "@fastpix/fastpix-node/funcs/mediaDeleteTrack.js";

// Use `FastpixCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const fastpix = new FastpixCore({
  security: {
    username: "your-access-token",
    password: "your-secret-key",
  },
});

async function run() {
  const res = await mediaDeleteTrack(fastpix, {
    mediaId: "your-media-id",
    trackId: "your-track-id",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("mediaDeleteTrack failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.DeleteMediaTrackRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.DeleteMediaTrackResponse>

Errors

Error Type Status Code Content Type
errors.FastpixDefaultError 4XX, 5XX */*

updateSourceAccess

This endpoint allows you to update the sourceAccess setting of an existing media file. The sourceAccess parameter determines whether the original media file is accessible or restricted. Setting this to true enables access to the media source, while setting it to false restricts access.

How it works

  1. Make a PATCH request to this endpoint, replacing {mediaId} with the ID of the media you want to update.

  2. Include the updated sourceAccess parameter in the request body.

  3. You receive a response confirming the update to the media’s source access status.

  4. Webhook events: video.media.source.ready, video.media.source.deleted

Example Usage

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.media.updateSourceAccess({
    mediaId: "your-media-id",
    body: {
      sourceAccess: true,
    },
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { FastpixCore } from "@fastpix/fastpix-node/core.js";
import { mediaUpdateSourceAccess } from "@fastpix/fastpix-node/funcs/mediaUpdateSourceAccess.js";

// Use `FastpixCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const fastpix = new FastpixCore({
  security: {
    username: "your-access-token",
    password: "your-secret-key",
  },
});

async function run() {
  const res = await mediaUpdateSourceAccess(fastpix, {
    mediaId: "your-media-id",
    body: {
      sourceAccess: true,
    },
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("mediaUpdateSourceAccess failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.UpdatedSourceAccessRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.UpdatedSourceAccessResponse>

Errors

Error Type Status Code Content Type
errors.FastpixDefaultError 4XX, 5XX */*

getClips

This endpoint retrieves a list of all media clips associated with a given source media ID. It helps you organize and manage media efficiently by providing metadata such as clip media IDs and other relevant details.

A media clip is a segmented portion of an original media file (source media). Clips are often created for various purposes such as previews, highlights, or customized edits. This API allows you to fetch all such clips linked to a specific source media, making it easier to track and manage clips.

How it works

  • The endpoint returns metadata for all media clips associated with the given mediaId.
  • Results are paginated to efficiently handle large datasets.
  • Each entry includes detailed metadata such as media id, duration, and status.
  • Helps in organizing clips effectively by providing structured information.

Example

Imagine you’re managing a video editing platform where users upload full-length videos and create short clips for social media sharing. To keep track of all clips linked to a particular video, you call this API with the sourceMediaId. The response provides a list of all associated clips, allowing you to manage, edit, or repurpose them as needed.

Related guide: Create clips from existing media

Example Usage

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.media.getClips({
    mediaId: "your-media-id",
    offset: 5,
    limit: 20,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { FastpixCore } from "@fastpix/fastpix-node/core.js";
import { mediaGetClips } from "@fastpix/fastpix-node/funcs/mediaGetClips.js";

// Use `FastpixCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const fastpix = new FastpixCore({
  security: {
    username: "your-access-token",
    password: "your-secret-key",
  },
});

async function run() {
  const res = await mediaGetClips(fastpix, {
    mediaId: "your-media-id",
    offset: 5,
    limit: 20,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("mediaGetClips failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.GetMediaClipsRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.GetMediaClipsResponse>

Errors

Error Type Status Code Content Type
errors.FastpixDefaultError 4XX, 5XX */*