Skip to content

Latest commit

 

History

History
292 lines (222 loc) · 21 KB

File metadata and controls

292 lines (222 loc) · 21 KB

Simulcasts

Overview

Available Operations

  • create - Create a simulcast
  • get - Get a specific simulcast
  • update - Update a simulcast

create

Creates a simulcast for a parent live stream. Simulcasting allows you to broadcast a live stream to multiple social platforms simultaneously (for example, YouTube, Facebook, or Twitch). This helps expand your audience reach across platforms. A simulcast can only be created when the parent live stream is in the idle state (not currently live or disabled). Only one simulcast target can be created per API call.

How it works

  1. Change to: When you call this endpoint, provide the parent streamId along with the simulcast target details (such as platform and credentials). The API returns a unique simulcastId, which you can use to manage the simulcast later.

  2. To notify your application about the status of simulcast related events check for the webhooks for simulcast target events.

Example

An event manager sets up a live stream for a virtual conference and wants to simulcast the stream on YouTube and Facebook Live. They first create the primary live stream in FastPix, ensuring it's in the idle state. Then, they use the API to create a simulcast target for YouTube.

Related guide: Simulcast to 3rd party platforms

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.simulcasts.create({
    streamId: "your-stream-id",
    body: {
      url: "your-rtmp-url",
      streamKey: "your-stream-key",
      metadata: {
        "livestream_name": "Tech-Connect Summit",
      },
    },
  });

  console.log(JSON.stringify(result, null, 2));
}

run();

Standalone function

The standalone function version of this method:

import { FastpixCore } from "@fastpix/fastpix-node/core.js";
import { simulcastsCreate } from "@fastpix/fastpix-node/funcs/simulcastsCreate.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 simulcastsCreate(fastpix, {
    streamId: "your-stream-id",
    body: {
      url: "your-rtmp-url",
      streamKey: "your-stream-key",
      metadata: {
        "livestream_name": "Tech-Connect Summit",
      },
    },
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(JSON.stringify(result, null, 2));
  } else {
    console.log("simulcastsCreate failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.CreateSimulcastOfStreamRequest ✔️ 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.CreateSimulcastOfStreamResponse>

Errors

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

get

Retrieves the details of a specific simulcast associated with a parent live stream. By providing both the streamId of the parent stream and the simulcastId, FastPix returns detailed information about the simulcast, such as the stream URL, the status of the simulcast, and metadata.

Example

This endpoint can be used to verify the status of the simulcast on external platforms before the live stream begins. For example, before starting a live gaming event, the organizer wants to ensure that the simulcast to Twitch is set up correctly. They retrieve the simulcast information to confirm that everything is properly configured.

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.simulcasts.get({
    streamId: "your-stream-id",
    simulcastId: "your-simulcast-id",
  });

  console.log(JSON.stringify(result, null, 2));
}

run();

Standalone function

The standalone function version of this method:

import { FastpixCore } from "@fastpix/fastpix-node/core.js";
import { simulcastsGet } from "@fastpix/fastpix-node/funcs/simulcastsGet.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 simulcastsGet(fastpix, {
    streamId: "your-stream-id",
    simulcastId: "your-simulcast-id",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(JSON.stringify(result, null, 2));
  } else {
    console.log("simulcastsGet failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.GetSpecificSimulcastOfStreamRequest ✔️ 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.GetSpecificSimulcastOfStreamResponse>

Errors

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

update

Updates the status of a specific simulcast linked to a parent live stream. You can enable or disable the simulcast at any time while the parent stream is active or idle. After the live stream is disabled, the simulcast can no longer be modified.

Webhook event: video.live_stream.simulcast_target.updated

Example

When a PATCH request is made to this endpoint, the API updates the status of the simulcast. This can be useful for pausing or resuming a simulcast on a particular platform without stopping the parent live stream.

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.simulcasts.update({
    streamId: "your-stream-id",
    simulcastId: "your-simulcast-id",
    body: {
      metadata: {
        "simulcast_name": "your-simulcast-name",
      },
    },
  });

  console.log(JSON.stringify(result, null, 2));
}

run();

Standalone function

The standalone function version of this method:

import { FastpixCore } from "@fastpix/fastpix-node/core.js";
import { simulcastsUpdate } from "@fastpix/fastpix-node/funcs/simulcastsUpdate.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 simulcastsUpdate(fastpix, {
    streamId: "your-stream-id",
    simulcastId: "your-simulcast-id",
    body: {
      metadata: {
        "simulcast_name": "Tech today",
      },
    },
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(JSON.stringify(result, null, 2));
  } else {
    console.log("simulcastsUpdate failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.UpdateSpecificSimulcastOfStreamRequest ✔️ 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.UpdateSpecificSimulcastOfStreamResponse>

Errors

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