Files

Status

(status)

Overview

The status endpoints give you information about current playbacks, play history, and even terminating sessions.

Available Operations

listSessions

List all current playbacks on this server

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";

const plexAPI = new PlexAPI({
  token: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await plexAPI.status.listSessions();

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { statusListSessions } from "@lukehagar/plexjs/funcs/statusListSessions.js";

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

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

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.ListSessionsResponse>

Errors

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

getBackgroundTasks

Get the list of all background tasks

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";

const plexAPI = new PlexAPI({
  token: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await plexAPI.status.getBackgroundTasks();

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { statusGetBackgroundTasks } from "@lukehagar/plexjs/funcs/statusGetBackgroundTasks.js";

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

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

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.GetBackgroundTasksResponse>

Errors

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

listPlaybackHistory

List all playback history (Admin can see all users, others can only see their own). Pagination should be used on this endpoint. Additionally this endpoint supports includeFields, excludeFields, includeElements, and excludeElements parameters.

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/models/shared";

const plexAPI = new PlexAPI({
  accepts: Accepts.ApplicationXml,
  clientIdentifier: "abc123",
  product: "Plex for Roku",
  version: "2.4.1",
  platform: "Roku",
  platformVersion: "4.3 build 1057",
  device: "Roku 3",
  model: "4200X",
  deviceVendor: "Roku",
  deviceName: "Living Room TV",
  marketplace: "googlePlay",
  token: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await plexAPI.status.listPlaybackHistory({
    sort: [
      "v",
      "i",
      "e",
      "w",
      "e",
      "d",
      "A",
      "t",
      ":",
      "d",
      "e",
      "s",
      "c",
      ",",
      "a",
      "c",
      "c",
      "o",
      "u",
      "n",
      "t",
      "I",
      "D",
    ],
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { statusListPlaybackHistory } from "@lukehagar/plexjs/funcs/statusListPlaybackHistory.js";
import { Accepts } from "@lukehagar/plexjs/models/shared";

// Use `PlexAPICore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const plexAPI = new PlexAPICore({
  accepts: Accepts.ApplicationXml,
  clientIdentifier: "abc123",
  product: "Plex for Roku",
  version: "2.4.1",
  platform: "Roku",
  platformVersion: "4.3 build 1057",
  device: "Roku 3",
  model: "4200X",
  deviceVendor: "Roku",
  deviceName: "Living Room TV",
  marketplace: "googlePlay",
  token: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const res = await statusListPlaybackHistory(plexAPI, {
    sort: [
      "v",
      "i",
      "e",
      "w",
      "e",
      "d",
      "A",
      "t",
      ":",
      "d",
      "e",
      "s",
      "c",
      ",",
      "a",
      "c",
      "c",
      "o",
      "u",
      "n",
      "t",
      "I",
      "D",
    ],
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("statusListPlaybackHistory failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

terminateSession

Terminate a playback session kicking off the user

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/models/shared";

const plexAPI = new PlexAPI({
  accepts: Accepts.ApplicationXml,
  clientIdentifier: "abc123",
  product: "Plex for Roku",
  version: "2.4.1",
  platform: "Roku",
  platformVersion: "4.3 build 1057",
  device: "Roku 3",
  model: "4200X",
  deviceVendor: "Roku",
  deviceName: "Living Room TV",
  marketplace: "googlePlay",
  token: "<YOUR_API_KEY_HERE>",
});

async function run() {
  await plexAPI.status.terminateSession({
    sessionId: "cdefghijklmnopqrstuvwxyz",
    reason: "Stop Playing",
  });


}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { statusTerminateSession } from "@lukehagar/plexjs/funcs/statusTerminateSession.js";
import { Accepts } from "@lukehagar/plexjs/models/shared";

// Use `PlexAPICore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const plexAPI = new PlexAPICore({
  accepts: Accepts.ApplicationXml,
  clientIdentifier: "abc123",
  product: "Plex for Roku",
  version: "2.4.1",
  platform: "Roku",
  platformVersion: "4.3 build 1057",
  device: "Roku 3",
  model: "4200X",
  deviceVendor: "Roku",
  deviceName: "Living Room TV",
  marketplace: "googlePlay",
  token: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const res = await statusTerminateSession(plexAPI, {
    sessionId: "cdefghijklmnopqrstuvwxyz",
    reason: "Stop Playing",
  });
  if (res.ok) {
    const { value: result } = res;
    
  } else {
    console.log("statusTerminateSession failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

deleteHistory

Delete a single history item by id

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/models/shared";

const plexAPI = new PlexAPI({
  accepts: Accepts.ApplicationXml,
  clientIdentifier: "abc123",
  product: "Plex for Roku",
  version: "2.4.1",
  platform: "Roku",
  platformVersion: "4.3 build 1057",
  device: "Roku 3",
  model: "4200X",
  deviceVendor: "Roku",
  deviceName: "Living Room TV",
  marketplace: "googlePlay",
  token: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await plexAPI.status.deleteHistory({
    historyId: 953579,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { statusDeleteHistory } from "@lukehagar/plexjs/funcs/statusDeleteHistory.js";
import { Accepts } from "@lukehagar/plexjs/models/shared";

// Use `PlexAPICore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const plexAPI = new PlexAPICore({
  accepts: Accepts.ApplicationXml,
  clientIdentifier: "abc123",
  product: "Plex for Roku",
  version: "2.4.1",
  platform: "Roku",
  platformVersion: "4.3 build 1057",
  device: "Roku 3",
  model: "4200X",
  deviceVendor: "Roku",
  deviceName: "Living Room TV",
  marketplace: "googlePlay",
  token: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const res = await statusDeleteHistory(plexAPI, {
    historyId: 953579,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("statusDeleteHistory failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

getHistoryItem

Get a single history item by id

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/models/shared";

const plexAPI = new PlexAPI({
  accepts: Accepts.ApplicationXml,
  clientIdentifier: "abc123",
  product: "Plex for Roku",
  version: "2.4.1",
  platform: "Roku",
  platformVersion: "4.3 build 1057",
  device: "Roku 3",
  model: "4200X",
  deviceVendor: "Roku",
  deviceName: "Living Room TV",
  marketplace: "googlePlay",
  token: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await plexAPI.status.getHistoryItem({
    historyId: 832213,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { statusGetHistoryItem } from "@lukehagar/plexjs/funcs/statusGetHistoryItem.js";
import { Accepts } from "@lukehagar/plexjs/models/shared";

// Use `PlexAPICore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const plexAPI = new PlexAPICore({
  accepts: Accepts.ApplicationXml,
  clientIdentifier: "abc123",
  product: "Plex for Roku",
  version: "2.4.1",
  platform: "Roku",
  platformVersion: "4.3 build 1057",
  device: "Roku 3",
  model: "4200X",
  deviceVendor: "Roku",
  deviceName: "Living Room TV",
  marketplace: "googlePlay",
  token: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const res = await statusGetHistoryItem(plexAPI, {
    historyId: 832213,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("statusGetHistoryItem failed:", res.error);
  }
}

run();

Parameters

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

Errors

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