Skip to content

Latest commit

 

History

History
388 lines (264 loc) · 27.8 KB

README.md

File metadata and controls

388 lines (264 loc) · 27.8 KB

Multistream

(multistream)

Overview

Operations related to multistream api

Available Operations

  • getAll - Retrieve Multistream Targets
  • create - Create a multistream target
  • get - Retrieve a multistream target
  • update - Update Multistream Target
  • delete - Delete a multistream target

getAll

Retrieve Multistream Targets

Example Usage

import { Livepeer } from "livepeer";

const livepeer = new Livepeer({
  apiKey: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await livepeer.multistream.getAll();
  
  // Handle the result
  console.log(result)
}

run();

Standalone function

The standalone function version of this method:

import { LivepeerCore } from "livepeer/core.js";
import { multistreamGetAll } from "livepeer/funcs/multistreamGetAll.js";

// Use `LivepeerCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const livepeer = new LivepeerCore({
  apiKey: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const res = await multistreamGetAll(livepeer);

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
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.GetMultistreamTargetsResponse>

Errors

Error Object Status Code Content Type
errors.SDKError 4xx-5xx /

create

Create a multistream target

Example Usage

import { Livepeer } from "livepeer";

const livepeer = new Livepeer({
  apiKey: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await livepeer.multistream.create({
    url: "rtmps://live.my-service.tv/channel/secretKey",
  });
  
  // Handle the result
  console.log(result)
}

run();

Standalone function

The standalone function version of this method:

import { LivepeerCore } from "livepeer/core.js";
import { multistreamCreate } from "livepeer/funcs/multistreamCreate.js";

// Use `LivepeerCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const livepeer = new LivepeerCore({
  apiKey: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const res = await multistreamCreate(livepeer, {
    url: "rtmps://live.my-service.tv/channel/secretKey",
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request components.MultistreamTargetInput ✔️ 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.CreateMultistreamTargetResponse>

Errors

Error Object Status Code Content Type
errors.SDKError 4xx-5xx /

get

Retrieve a multistream target

Example Usage

import { Livepeer } from "livepeer";

const livepeer = new Livepeer({
  apiKey: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await livepeer.multistream.get("<id>");
  
  // Handle the result
  console.log(result)
}

run();

Standalone function

The standalone function version of this method:

import { LivepeerCore } from "livepeer/core.js";
import { multistreamGet } from "livepeer/funcs/multistreamGet.js";

// Use `LivepeerCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const livepeer = new LivepeerCore({
  apiKey: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const res = await multistreamGet(livepeer, "<id>");

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
id string ✔️ ID of the multistream target
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.GetMultistreamTargetResponse>

Errors

Error Object Status Code Content Type
errors.SDKError 4xx-5xx /

update

Update Multistream Target

Example Usage

import { Livepeer } from "livepeer";

const livepeer = new Livepeer({
  apiKey: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await livepeer.multistream.update("<id>", {
    url: "rtmps://live.my-service.tv/channel/secretKey",
  });
  
  // Handle the result
  console.log(result)
}

run();

Standalone function

The standalone function version of this method:

import { LivepeerCore } from "livepeer/core.js";
import { multistreamUpdate } from "livepeer/funcs/multistreamUpdate.js";

// Use `LivepeerCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const livepeer = new LivepeerCore({
  apiKey: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const res = await multistreamUpdate(livepeer, "<id>", {
    url: "rtmps://live.my-service.tv/channel/secretKey",
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
id string ✔️ ID of the multistream target
multistreamTargetPatchPayload components.MultistreamTargetPatchPayload ✔️ N/A
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.UpdateMultistreamTargetResponse>

Errors

Error Object Status Code Content Type
errors.SDKError 4xx-5xx /

delete

Make sure to remove any references to the target on existing streams before actually deleting it from the API.

Example Usage

import { Livepeer } from "livepeer";

const livepeer = new Livepeer({
  apiKey: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await livepeer.multistream.delete("<id>");
  
  // Handle the result
  console.log(result)
}

run();

Standalone function

The standalone function version of this method:

import { LivepeerCore } from "livepeer/core.js";
import { multistreamDelete } from "livepeer/funcs/multistreamDelete.js";

// Use `LivepeerCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const livepeer = new LivepeerCore({
  apiKey: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const res = await multistreamDelete(livepeer, "<id>");

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
id string ✔️ ID of the multistream target
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.DeleteMultistreamTargetResponse>

Errors

Error Object Status Code Content Type
errors.SDKError 4xx-5xx /