Skip to content

Latest commit

 

History

History
301 lines (205 loc) · 23.1 KB

README.md

File metadata and controls

301 lines (205 loc) · 23.1 KB

Session

(session)

Overview

Operations related to session api

Available Operations

getClips

Retrieve clips of a session

Example Usage

import { Livepeer } from "livepeer";

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

async function run() {
  const result = await livepeer.session.getClips("<id>");

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

run();

Standalone function

The standalone function version of this method:

import { LivepeerCore } from "livepeer/core.js";
import { sessionGetClips } from "livepeer/funcs/sessionGetClips.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 sessionGetClips(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 parent session
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.GetSessionClipsResponse>

Errors

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

getAll

Retrieve sessions

Example Usage

import { Livepeer } from "livepeer";

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

async function run() {
  const result = await livepeer.session.getAll();

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

run();

Standalone function

The standalone function version of this method:

import { LivepeerCore } from "livepeer/core.js";
import { sessionGetAll } from "livepeer/funcs/sessionGetAll.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 sessionGetAll(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.GetSessionsResponse>

Errors

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

get

Retrieve a session

Example Usage

import { Livepeer } from "livepeer";

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

async function run() {
  const result = await livepeer.session.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 { sessionGet } from "livepeer/funcs/sessionGet.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 sessionGet(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 session
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.GetSessionResponse>

Errors

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

getRecorded

Retrieve Recorded Sessions

Example Usage

import { Livepeer } from "livepeer";

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

async function run() {
  const result = await livepeer.session.getRecorded("<value>", true);

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

run();

Standalone function

The standalone function version of this method:

import { LivepeerCore } from "livepeer/core.js";
import { sessionGetRecorded } from "livepeer/funcs/sessionGetRecorded.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 sessionGetRecorded(livepeer, "<value>", true);

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

  const { value: result } = res;

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

run();

Parameters

Parameter Type Required Description Example
parentId string ✔️ ID of the parent stream
record operations.RecordT Flag indicating if the response should only include recorded
sessions
[object Object]
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.GetRecordedSessionsResponse>

Errors

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