Files
plexjs/docs/sdks/library
speakeasybot 3994020ebb ## Typescript SDK Changes:
* `plex-api.libraryPlaylists.addPlaylistItems()`:  `response.mediacontainer.metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.hubs.getMetadataHubs()`: 
  *  `request.onlyTransient` **Changed**
  *  `response.mediacontainer.hub.[].metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.libraryCollections.moveCollectionItem()`:  `response.mediacontainer.metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.libraryCollections.deleteCollectionItem()`:  `response.mediacontainer.metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.libraryCollections.addCollectionItems()`:  `response.mediacontainer.metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.content.getSonicallySimilar()`:  `response.mediacontainer.metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.butler.stopTask()`:  `request` **Changed** **Breaking** ⚠️
* `plex-api.butler.startTask()`:  `request` **Changed** **Breaking** ⚠️
* `plex-api.content.getSonicPath()`:  `response.mediacontainer.metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.downloadQueue.getItemDecision()`:  `response.mediacontainer.metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.hubs.getAllHubs()`: 
  *  `request.onlyTransient` **Changed**
  *  `response.mediacontainer.hub.[].metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.hubs.getContinueWatching()`:  `response.mediacontainer.hub.[].metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.hubs.getPromotedHubs()`:  `response.mediacontainer.hub.[].metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.content.getAllLeaves()`:  `response.mediacontainer.metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.hubs.getPostplayHubs()`: 
  *  `request.onlyTransient` **Changed**
  *  `response.mediacontainer.hub.[].metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.hubs.getRelatedHubs()`: 
  *  `request.onlyTransient` **Changed**
  *  `response.mediacontainer.hub.[].metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.hubs.getSectionHubs()`: 
  *  `request.onlyTransient` **Changed**
  *  `response.mediacontainer.hub.[].metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.content.listContent()`: 
  *  `request` **Changed**
  *  `response.mediacontainer.metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.content.getAlbums()`:  `response.mediacontainer.metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.search.searchHubs()`:  `response.mediacontainer.hub.[].metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.search.voiceSearchHubs()`: 
  *  `request.type` **Changed** **Breaking** ⚠️
  *  `response.mediacontainer.hub.[].metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.library.getLibraryItems()`: 
  *  `request.mediaQuery` **Changed**
  *  `response.mediacontainer.metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.library.ingestTransientItem()`: 
  *  `request` **Changed**
  *  `response.mediacontainer.metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.library.getLibraryMatches()`: 
  *  `request` **Changed** **Breaking** ⚠️
  *  `response.mediacontainer.metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.content.getMetadataItem()`: 
  *  `request` **Changed**
  *  `response.mediacontainer.metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.library.getSections()`:  `response.mediacontainer.directory.[]` **Changed** **Breaking** ⚠️
* `plex-api.library.addSection()`: 
  *  `request` **Changed**
  *  `response.mediacontainer.directory.[]` **Changed** **Breaking** ⚠️
* `plex-api.library.getTags()`: 
  *  `request.type` **Changed** **Breaking** ⚠️
* `plex-api.content.getCollectionItems()`:  `response.mediacontainer.metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.library.getAllItemLeaves()`:  `response.mediacontainer.metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.status.listSessions()`:  `response.mediacontainer.metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.playQueue.movePlayQueueItem()`:  `response.mediacontainer.metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.library.getExtras()`:  `response.mediacontainer.metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.playQueue.deletePlayQueueItem()`:  `response.mediacontainer.metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.playQueue.unshuffle()`:  `response.mediacontainer.metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.library.listMatches()`: 
  *  `request.manual` **Changed**
  *  `response.mediacontainer.metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.library.listSonicallySimilar()`:  `response.mediacontainer.metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.playQueue.resetPlayQueue()`:  `response.mediacontainer.metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.library.getRelatedItems()`:  `response.mediacontainer.hub.[].metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.library.listSimilar()`:  `response.mediacontainer.metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.playQueue.clearPlayQueue()`:  `response.mediacontainer.metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.library.getItemTree()`:  `response.mediacontainer.metadataItem.[]` **Changed** **Breaking** ⚠️
* `plex-api.playQueue.addToPlayQueue()`: 
  *  `request.next` **Changed**
  *  `response.mediacontainer.metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.playQueue.getPlayQueue()`: 
  *  `request` **Changed**
  *  `response.mediacontainer.metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.libraryPlaylists.movePlaylistItem()`:  `response.mediacontainer.metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.library.getPerson()`:  `response.mediacontainer.directory.[]` **Changed** **Breaking** ⚠️
* `plex-api.library.listPersonMedia()`:  `response.mediacontainer.metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.libraryPlaylists.getPlaylistGeneratorItems()`:  `response.mediacontainer.metadata` **Changed** **Breaking** ⚠️
* `plex-api.library.getLibraryDetails()`: 
  *  `request.includeDetails` **Changed**
  *  `response.mediacontainer.directory.[]` **Changed** **Breaking** ⚠️
* `plex-api.libraryPlaylists.modifyPlaylistGenerator()`: 
  *  `request.item` **Changed**
  *  `response.mediacontainer.metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.library.autocomplete()`: 
  *  `request.mediaQuery` **Changed**
  *  `response.mediacontainer.metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.library.getCollections()`: 
  *  `request.mediaQuery` **Changed**
  *  `response.mediacontainer.metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.library.getCommon()`: 
  *  `request.mediaQuery` **Changed**
  *  `response.mediacontainer.metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.libraryPlaylists.deletePlaylistItem()`:  `response.mediacontainer.metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.libraryPlaylists.clearPlaylistItems()`:  `response.mediacontainer.metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.playQueue.shuffle()`:  `response.mediacontainer.metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.libraryPlaylists.createPlaylist()`:  `response.mediacontainer.metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.playlist.getPlaylistItems()`:  `response.mediacontainer.metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.playlist.getPlaylist()`:  `response.mediacontainer.metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.collections.createCollection()`: 
  *  `request.type` **Changed** **Breaking** ⚠️
  *  `response.mediacontainer.metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.dvRs.tuneChannel()`:  `response.mediacontainer.metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.liveTv.getSessions()`:  `response.mediacontainer.metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.liveTv.getLiveTvSession()`:  `response.mediacontainer.metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.playlist.listPlaylists()`:  `response.mediacontainer.metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.subscriptions.getAllSubscriptions()`: 
  *  `request` **Changed**
  *  `response.mediacontainer.mediaSubscription.[].mediaGrabOperation.[].metadata` **Changed** **Breaking** ⚠️
* `plex-api.subscriptions.createSubscription()`:  `response.mediacontainer.mediaSubscription.[].mediaGrabOperation.[].metadata` **Changed** **Breaking** ⚠️
* `plex-api.subscriptions.getScheduledRecordings()`:  `response.mediacontainer.mediaGrabOperation.[].metadata` **Changed** **Breaking** ⚠️
* `plex-api.subscriptions.getTemplate()`:  `response.mediacontainer.subscriptionTemplate.[].mediaSubscription.[].mediaGrabOperation.[].metadata` **Changed** **Breaking** ⚠️
* `plex-api.subscriptions.getSubscription()`: 
  *  `request` **Changed**
  *  `response.mediacontainer.mediaSubscription.[].mediaGrabOperation.[].metadata` **Changed** **Breaking** ⚠️
* `plex-api.subscriptions.editSubscriptionPreferences()`:  `response.mediacontainer.mediaSubscription.[].mediaGrabOperation.[].metadata` **Changed** **Breaking** ⚠️
* `plex-api.subscriptions.reorderSubscription()`:  `response.mediacontainer.mediaSubscription.[].mediaGrabOperation.[].metadata` **Changed** **Breaking** ⚠️
* `plex-api.transcoder.makeDecision()`: 
  *  `request` **Changed**
  *  `response.mediacontainer.metadata.[]` **Changed** **Breaking** ⚠️
* `plex-api.library.refreshItemsMetadata()`: 
  *  `request.markUpdated` **Changed**
* `plex-api.authentication.postUsersSignInData()`: **Added**
* `plex-api.transcoder.startTranscodeSession()`:  `request` **Changed**
* `plex-api.devices.modifyDevice()`: 
  *  `request.enabled` **Changed**
* `plex-api.library.getMediaPart()`: 
  *  `request.download` **Changed**
* `plex-api.library.detectIntros()`: 
  *  `request.force` **Changed**
* `plex-api.library.refreshSection()`: 
  *  `request.force` **Changed**
* `plex-api.libraryPlaylists.uploadPlaylist()`: 
  *  `request.force` **Changed**
* `plex-api.library.deleteMediaItem()`: 
  *  `request.proxy` **Changed**
* `plex-api.authentication.getTokenDetails()`: **Added**
* `plex-api.library.getFirstCharacters()`: 
  *  `request.mediaQuery` **Changed**
* `plex-api.library.updateItems()`: 
  *  `request.field.locked` **Changed**
* `plex-api.library.deleteLibrarySection()`: 
  *  `request.async` **Changed**
* `plex-api.library.setStreamSelection()`: 
  *  `request.allParts` **Changed**
* `plex-api.playQueue.createPlayQueue()`:  `request` **Changed**
* `plex-api.library.getAugmentationStatus()`: 
  *  `request.wait` **Changed**
* `plex-api.library.detectVoiceActivity()`:  `request` **Changed**
* `plex-api.transcoder.transcodeImage()`:  `request` **Changed**
* `plex-api.transcoder.transcodeSubtitles()`:  `request` **Changed**
* `plex-api.library.addSubtitles()`:  `request` **Changed**
* `plex-api.library.getStream()`: 
  *  `request.autoAdjustSubtitle` **Changed**
* `plex-api.library.startBifGeneration()`: 
  *  `request.force` **Changed**
* `plex-api.library.detectCredits()`:  `request` **Changed**
* `plex-api.ultraBlur.getImage()`: 
  *  `request.noise` **Changed**
* `plex-api.library.generateThumbs()`: 
  *  `request.force` **Changed**
* `plex-api.updater.applyUpdates()`:  `request` **Changed**
* `plex-api.updater.checkUpdates()`: 
  *  `request.download` **Changed**
* `plex-api.library.deleteMetadataItem()`: 
  *  `request.proxy` **Changed**
* `plex-api.library.optimizeDatabase()`: 
  *  `request.async` **Changed**
* `plex-api.hubs.updateHubVisibility()`:  `request` **Changed**
* `plex-api.hubs.createCustomHub()`:  `request` **Changed**
* `plex-api.library.getSectionImage()`: 
  *  `request.mediaQuery` **Changed**
* `plex-api.downloadQueue.addDownloadQueueItems()`:  `request` **Changed**
* `plex-api.timeline.report()`:  `request` **Changed**
* `plex-api.general.getSourceConnectionInformation()`: 
  *  `request.refresh` **Changed**
* `plex-api.plex.getServerResources()`: **Added**
* `plex-api.users.getUsers()`: **Added**
2025-12-01 00:15:57 +00:00
..
2025-12-01 00:15:57 +00:00

Library

(library)

Overview

Library endpoints which are outside of the Media Provider API. Typically this is manipulation of the library (adding/removing sections, modifying preferences, etc).

Available Operations

getLibraryItems

Request all metadata items according to a query.

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts, MediaType } from "@lukehagar/plexjs/sdk/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.library.getLibraryItems({
    mediaQuery: {
      type: MediaType.Episode,
      sourceType: 2,
      sort: "duration:desc,index",
    },
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryGetLibraryItems } from "@lukehagar/plexjs/funcs/libraryGetLibraryItems.js";
import { Accepts, MediaType } from "@lukehagar/plexjs/sdk/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 libraryGetLibraryItems(plexAPI, {
    mediaQuery: {
      type: MediaType.Episode,
      sourceType: 2,
      sort: "duration:desc,index",
    },
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryGetLibraryItems failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

deleteCaches

Delete the hub caches so they are recomputed on next request

Example Usage

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

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

async function run() {
  const result = await plexAPI.library.deleteCaches();

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryDeleteCaches } from "@lukehagar/plexjs/funcs/libraryDeleteCaches.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 libraryDeleteCaches(plexAPI);
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryDeleteCaches 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.DeleteCachesResponse>

Errors

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

cleanBundles

Clean out any now unused bundles. Bundles can become unused when media is deleted

Example Usage

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

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

async function run() {
  const result = await plexAPI.library.cleanBundles();

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryCleanBundles } from "@lukehagar/plexjs/funcs/libraryCleanBundles.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 libraryCleanBundles(plexAPI);
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryCleanBundles 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.CleanBundlesResponse>

Errors

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

ingestTransientItem

This endpoint takes a file path specified in the url parameter, matches it using the scanner's match mechanism, downloads rich metadata, and then ingests the item as a transient item (without a library section). In the case where the file represents an episode, the entire tree (show, season, and episode) is added as transient items. At this time, movies and episodes are the only supported types, which are gleaned automatically from the file path. Note that any of the parameters passed to the metadata details endpoint (e.g. includeExtras=1) work here.

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts, BoolInt } from "@lukehagar/plexjs/sdk/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.library.ingestTransientItem({
    url: "file:///storage%2Femulated%2F0%2FArcher-S01E01.mkv",
    virtualFilePath: "/Avatar.mkv",
    computeHashes: BoolInt.True,
    ingestNonMatches: BoolInt.True,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryIngestTransientItem } from "@lukehagar/plexjs/funcs/libraryIngestTransientItem.js";
import { Accepts, BoolInt } from "@lukehagar/plexjs/sdk/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 libraryIngestTransientItem(plexAPI, {
    url: "file:///storage%2Femulated%2F0%2FArcher-S01E01.mkv",
    virtualFilePath: "/Avatar.mkv",
    computeHashes: BoolInt.True,
    ingestNonMatches: BoolInt.True,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryIngestTransientItem failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

getLibraryMatches

The matches endpoint is used to match content external to the library with content inside the library. This is done by passing a series of semantic "hints" about the content (its type, name, or release year). Each type (e.g. movie) has a canonical set of minimal required hints. This ability to match content is useful in a variety of scenarios. For example, in the DVR, the EPG uses the endpoint to match recording rules against airing content. And in the cloud, the UMP uses the endpoint to match up a piece of media with rich metadata. The endpoint response can including multiple matches, if there is ambiguity, each one containing a score from 0 to 100. For somewhat historical reasons, anything over 85 is considered a positive match (we prefer false negatives over false positives in general for matching). The guid hint is somewhat special, in that it generally represents a unique identity for a piece of media (e.g. the IMDB ttXXX) identifier, in contrast with other hints which can be much more ambiguous (e.g. a title of Jane Eyre, which could refer to the 1943 or the 2011 version). Episodes require either a season/episode pair, or an air date (or both). Either the path must be sent, or the show title

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts, BoolInt, MediaType } from "@lukehagar/plexjs/sdk/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.library.getLibraryMatches({
    type: MediaType.TvShow,
    includeFullMetadata: BoolInt.True,
    includeAncestorMetadata: BoolInt.True,
    includeAlternateMetadataSources: BoolInt.True,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryGetLibraryMatches } from "@lukehagar/plexjs/funcs/libraryGetLibraryMatches.js";
import { Accepts, BoolInt, MediaType } from "@lukehagar/plexjs/sdk/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 libraryGetLibraryMatches(plexAPI, {
    type: MediaType.TvShow,
    includeFullMetadata: BoolInt.True,
    includeAncestorMetadata: BoolInt.True,
    includeAlternateMetadataSources: BoolInt.True,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryGetLibraryMatches failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

optimizeDatabase

Initiate optimize on the database.

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts, BoolInt } from "@lukehagar/plexjs/sdk/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.library.optimizeDatabase({
    async: BoolInt.True,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryOptimizeDatabase } from "@lukehagar/plexjs/funcs/libraryOptimizeDatabase.js";
import { Accepts, BoolInt } from "@lukehagar/plexjs/sdk/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 libraryOptimizeDatabase(plexAPI, {
    async: BoolInt.True,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryOptimizeDatabase failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

getRandomArtwork

Get random artwork across sections. This is commonly used for a screensaver.

This retrieves 100 random artwork paths in the specified sections and returns them. Restrictions are put in place to not return artwork for items the user is not allowed to access. Artwork will be for Movies, Shows, and Artists only.

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/sdk/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.library.getRandomArtwork({
    sections: [
      5,
      6,
    ],
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryGetRandomArtwork } from "@lukehagar/plexjs/funcs/libraryGetRandomArtwork.js";
import { Accepts } from "@lukehagar/plexjs/sdk/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 libraryGetRandomArtwork(plexAPI, {
    sections: [
      5,
      6,
    ],
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryGetRandomArtwork failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

getSections

A library section (commonly referred to as just a library) is a collection of media. Libraries are typed, and depending on their type provide either a flat or a hierarchical view of the media. For example, a music library has an artist > albums > tracks structure, whereas a movie library is flat. Libraries have features beyond just being a collection of media; for starters, they include information about supported types, filters and sorts. This allows a client to provide a rich interface around the media (e.g. allow sorting movies by release year).

Example Usage

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

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

async function run() {
  const result = await plexAPI.library.getSections();

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryGetSections } from "@lukehagar/plexjs/funcs/libraryGetSections.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 libraryGetSections(plexAPI);
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryGetSections 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.GetSectionsResponse>

Errors

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

addSection

Add a new library section to the server

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts, BoolInt } from "@lukehagar/plexjs/sdk/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.library.addSection({
    name: "<value>",
    type: 39544,
    agent: "<value>",
    language: "<value>",
    locations: [
      "O:\fatboy\\Media\\Ripped\\Music",
      "O:\fatboy\\Media\\My Music",
    ],
    prefs: {},
    relative: BoolInt.True,
    importFromiTunes: BoolInt.True,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryAddSection } from "@lukehagar/plexjs/funcs/libraryAddSection.js";
import { Accepts, BoolInt } from "@lukehagar/plexjs/sdk/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 libraryAddSection(plexAPI, {
    name: "<value>",
    type: 39544,
    agent: "<value>",
    language: "<value>",
    locations: [
      "O:\fatboy\\Media\\Ripped\\Music",
      "O:\fatboy\\Media\\My Music",
    ],
    prefs: {},
    relative: BoolInt.True,
    importFromiTunes: BoolInt.True,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryAddSection failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

stopAllRefreshes

Stop all refreshes across all sections

Example Usage

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

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

async function run() {
  const result = await plexAPI.library.stopAllRefreshes();

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryStopAllRefreshes } from "@lukehagar/plexjs/funcs/libraryStopAllRefreshes.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 libraryStopAllRefreshes(plexAPI);
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryStopAllRefreshes 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.StopAllRefreshesResponse>

Errors

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

getSectionsPrefs

Get a section's preferences for a metadata type

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/sdk/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.library.getSectionsPrefs({
    type: 460221,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryGetSectionsPrefs } from "@lukehagar/plexjs/funcs/libraryGetSectionsPrefs.js";
import { Accepts } from "@lukehagar/plexjs/sdk/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 libraryGetSectionsPrefs(plexAPI, {
    type: 460221,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryGetSectionsPrefs failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

refreshSectionsMetadata

Tell PMS to refresh all section metadata

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/sdk/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.library.refreshSectionsMetadata({});

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryRefreshSectionsMetadata } from "@lukehagar/plexjs/funcs/libraryRefreshSectionsMetadata.js";
import { Accepts } from "@lukehagar/plexjs/sdk/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 libraryRefreshSectionsMetadata(plexAPI, {});
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryRefreshSectionsMetadata failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

getTags

Get all library tags of a type

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts, MediaType } from "@lukehagar/plexjs/sdk/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.library.getTags({
    type: MediaType.TvShow,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryGetTags } from "@lukehagar/plexjs/funcs/libraryGetTags.js";
import { Accepts, MediaType } from "@lukehagar/plexjs/sdk/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 libraryGetTags(plexAPI, {
    type: MediaType.TvShow,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryGetTags failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

deleteMetadataItem

Delete a single metadata item from the library, deleting media as well

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts, BoolInt } from "@lukehagar/plexjs/sdk/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.library.deleteMetadataItem({
    ids: "<value>",
    proxy: BoolInt.True,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryDeleteMetadataItem } from "@lukehagar/plexjs/funcs/libraryDeleteMetadataItem.js";
import { Accepts, BoolInt } from "@lukehagar/plexjs/sdk/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 libraryDeleteMetadataItem(plexAPI, {
    ids: "<value>",
    proxy: BoolInt.True,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryDeleteMetadataItem failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

editMetadataItem

Edit metadata items setting fields

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/sdk/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.library.editMetadataItem({
    ids: [
      "<value 1>",
      "<value 2>",
    ],
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryEditMetadataItem } from "@lukehagar/plexjs/funcs/libraryEditMetadataItem.js";
import { Accepts } from "@lukehagar/plexjs/sdk/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 libraryEditMetadataItem(plexAPI, {
    ids: [
      "<value 1>",
      "<value 2>",
    ],
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryEditMetadataItem failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

detectAds

Start the detection of ads in a metadata item

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/sdk/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.library.detectAds({
    ids: "<value>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryDetectAds } from "@lukehagar/plexjs/funcs/libraryDetectAds.js";
import { Accepts } from "@lukehagar/plexjs/sdk/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 libraryDetectAds(plexAPI, {
    ids: "<value>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryDetectAds failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

getAllItemLeaves

Get the leaves for a metadata item such as the episodes in a show

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/sdk/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.library.getAllItemLeaves({
    ids: "<value>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryGetAllItemLeaves } from "@lukehagar/plexjs/funcs/libraryGetAllItemLeaves.js";
import { Accepts } from "@lukehagar/plexjs/sdk/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 libraryGetAllItemLeaves(plexAPI, {
    ids: "<value>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryGetAllItemLeaves failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

analyzeMetadata

Start the analysis of a metadata item

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/sdk/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.library.analyzeMetadata({
    ids: "<value>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryAnalyzeMetadata } from "@lukehagar/plexjs/funcs/libraryAnalyzeMetadata.js";
import { Accepts } from "@lukehagar/plexjs/sdk/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 libraryAnalyzeMetadata(plexAPI, {
    ids: "<value>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryAnalyzeMetadata failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

generateThumbs

Start the chapter thumb generation for an item

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts, BoolInt } from "@lukehagar/plexjs/sdk/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.library.generateThumbs({
    ids: "<value>",
    force: BoolInt.True,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryGenerateThumbs } from "@lukehagar/plexjs/funcs/libraryGenerateThumbs.js";
import { Accepts, BoolInt } from "@lukehagar/plexjs/sdk/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 libraryGenerateThumbs(plexAPI, {
    ids: "<value>",
    force: BoolInt.True,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryGenerateThumbs failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

detectCredits

Start credit detection on a metadata item

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts, BoolInt } from "@lukehagar/plexjs/sdk/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.library.detectCredits({
    ids: "<value>",
    force: BoolInt.True,
    manual: BoolInt.True,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryDetectCredits } from "@lukehagar/plexjs/funcs/libraryDetectCredits.js";
import { Accepts, BoolInt } from "@lukehagar/plexjs/sdk/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 libraryDetectCredits(plexAPI, {
    ids: "<value>",
    force: BoolInt.True,
    manual: BoolInt.True,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryDetectCredits failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

getExtras

Get the extras for a metadata item

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/sdk/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.library.getExtras({
    ids: "<value>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryGetExtras } from "@lukehagar/plexjs/funcs/libraryGetExtras.js";
import { Accepts } from "@lukehagar/plexjs/sdk/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 libraryGetExtras(plexAPI, {
    ids: "<value>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryGetExtras failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

addExtras

Add an extra to a metadata item

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/sdk/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.library.addExtras({
    ids: "<value>",
    url: "https://super-mortise.biz/",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryAddExtras } from "@lukehagar/plexjs/funcs/libraryAddExtras.js";
import { Accepts } from "@lukehagar/plexjs/sdk/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 libraryAddExtras(plexAPI, {
    ids: "<value>",
    url: "https://super-mortise.biz/",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryAddExtras failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

getFile

Get a bundle file for a metadata or media item. This is either an image or a mp3 (for a show's theme)

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/sdk/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.library.getFile({
    ids: "<value>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryGetFile } from "@lukehagar/plexjs/funcs/libraryGetFile.js";
import { Accepts } from "@lukehagar/plexjs/sdk/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 libraryGetFile(plexAPI, {
    ids: "<value>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryGetFile failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

startBifGeneration

Start the indexing (BIF generation) of an item

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts, BoolInt } from "@lukehagar/plexjs/sdk/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.library.startBifGeneration({
    ids: "<value>",
    force: BoolInt.True,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryStartBifGeneration } from "@lukehagar/plexjs/funcs/libraryStartBifGeneration.js";
import { Accepts, BoolInt } from "@lukehagar/plexjs/sdk/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 libraryStartBifGeneration(plexAPI, {
    ids: "<value>",
    force: BoolInt.True,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryStartBifGeneration failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

detectIntros

Start the detection of intros in a metadata item

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts, BoolInt } from "@lukehagar/plexjs/sdk/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.library.detectIntros({
    ids: "<value>",
    force: BoolInt.True,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryDetectIntros } from "@lukehagar/plexjs/funcs/libraryDetectIntros.js";
import { Accepts, BoolInt } from "@lukehagar/plexjs/sdk/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 libraryDetectIntros(plexAPI, {
    ids: "<value>",
    force: BoolInt.True,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryDetectIntros failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

createMarker

Create a marker for this user on the metadata item

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/sdk/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.library.createMarker({
    ids: "<value>",
    type: 248391,
    startTimeOffset: 535191,
    attributes: {},
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryCreateMarker } from "@lukehagar/plexjs/funcs/libraryCreateMarker.js";
import { Accepts } from "@lukehagar/plexjs/sdk/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 libraryCreateMarker(plexAPI, {
    ids: "<value>",
    type: 248391,
    startTimeOffset: 535191,
    attributes: {},
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryCreateMarker failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

matchItem

Match a metadata item to a guid

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/sdk/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.library.matchItem({
    ids: "<value>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryMatchItem } from "@lukehagar/plexjs/funcs/libraryMatchItem.js";
import { Accepts } from "@lukehagar/plexjs/sdk/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 libraryMatchItem(plexAPI, {
    ids: "<value>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryMatchItem failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

listMatches

Get the list of metadata matches for a metadata item

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts, BoolInt } from "@lukehagar/plexjs/sdk/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.library.listMatches({
    ids: "<value>",
    manual: BoolInt.True,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryListMatches } from "@lukehagar/plexjs/funcs/libraryListMatches.js";
import { Accepts, BoolInt } from "@lukehagar/plexjs/sdk/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 libraryListMatches(plexAPI, {
    ids: "<value>",
    manual: BoolInt.True,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryListMatches failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

mergeItems

Merge a metadata item with other items

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/sdk/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.library.mergeItems({
    idsPathParameter: "<value>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryMergeItems } from "@lukehagar/plexjs/funcs/libraryMergeItems.js";
import { Accepts } from "@lukehagar/plexjs/sdk/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 libraryMergeItems(plexAPI, {
    idsPathParameter: "<value>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryMergeItems failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

listSonicallySimilar

Get the nearest tracks, sonically, to the provided track

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/sdk/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.library.listSonicallySimilar({
    ids: "<value>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryListSonicallySimilar } from "@lukehagar/plexjs/funcs/libraryListSonicallySimilar.js";
import { Accepts } from "@lukehagar/plexjs/sdk/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 libraryListSonicallySimilar(plexAPI, {
    ids: "<value>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryListSonicallySimilar failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

setItemPreferences

Set the preferences on a metadata item

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/sdk/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.library.setItemPreferences({
    ids: "<value>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { librarySetItemPreferences } from "@lukehagar/plexjs/funcs/librarySetItemPreferences.js";
import { Accepts } from "@lukehagar/plexjs/sdk/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 librarySetItemPreferences(plexAPI, {
    ids: "<value>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("librarySetItemPreferences failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

refreshItemsMetadata

Refresh a metadata item from the agent

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts, BoolInt } from "@lukehagar/plexjs/sdk/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.library.refreshItemsMetadata({
    ids: "<value>",
    markUpdated: BoolInt.True,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryRefreshItemsMetadata } from "@lukehagar/plexjs/funcs/libraryRefreshItemsMetadata.js";
import { Accepts, BoolInt } from "@lukehagar/plexjs/sdk/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 libraryRefreshItemsMetadata(plexAPI, {
    ids: "<value>",
    markUpdated: BoolInt.True,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryRefreshItemsMetadata failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

getRelatedItems

Get a hub of related items to a metadata item

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/sdk/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.library.getRelatedItems({
    ids: "<value>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryGetRelatedItems } from "@lukehagar/plexjs/funcs/libraryGetRelatedItems.js";
import { Accepts } from "@lukehagar/plexjs/sdk/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 libraryGetRelatedItems(plexAPI, {
    ids: "<value>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryGetRelatedItems failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

listSimilar

Get a list of similar items to a metadata item

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/sdk/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.library.listSimilar({
    ids: "<value>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryListSimilar } from "@lukehagar/plexjs/funcs/libraryListSimilar.js";
import { Accepts } from "@lukehagar/plexjs/sdk/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 libraryListSimilar(plexAPI, {
    ids: "<value>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryListSimilar failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

splitItem

Split a metadata item into multiple items

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/sdk/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.library.splitItem({
    ids: "<value>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { librarySplitItem } from "@lukehagar/plexjs/funcs/librarySplitItem.js";
import { Accepts } from "@lukehagar/plexjs/sdk/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 librarySplitItem(plexAPI, {
    ids: "<value>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("librarySplitItem failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

addSubtitles

Add a subtitle to a metadata item

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts, BoolInt } from "@lukehagar/plexjs/sdk/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.library.addSubtitles({
    ids: "<value>",
    forced: BoolInt.True,
    hearingImpaired: BoolInt.True,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryAddSubtitles } from "@lukehagar/plexjs/funcs/libraryAddSubtitles.js";
import { Accepts, BoolInt } from "@lukehagar/plexjs/sdk/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 libraryAddSubtitles(plexAPI, {
    ids: "<value>",
    forced: BoolInt.True,
    hearingImpaired: BoolInt.True,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryAddSubtitles failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

getItemTree

Get a tree of metadata items, such as the seasons/episodes of a show

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/sdk/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.library.getItemTree({
    ids: "<value>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryGetItemTree } from "@lukehagar/plexjs/funcs/libraryGetItemTree.js";
import { Accepts } from "@lukehagar/plexjs/sdk/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 libraryGetItemTree(plexAPI, {
    ids: "<value>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryGetItemTree failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

unmatch

Unmatch a metadata item to info fetched from the agent

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/sdk/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.library.unmatch({
    ids: "<value>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryUnmatch } from "@lukehagar/plexjs/funcs/libraryUnmatch.js";
import { Accepts } from "@lukehagar/plexjs/sdk/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 libraryUnmatch(plexAPI, {
    ids: "<value>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryUnmatch failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

listTopUsers

Get the list of users which have played this item starting with the most

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/sdk/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.library.listTopUsers({
    ids: "<value>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryListTopUsers } from "@lukehagar/plexjs/funcs/libraryListTopUsers.js";
import { Accepts } from "@lukehagar/plexjs/sdk/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 libraryListTopUsers(plexAPI, {
    ids: "<value>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryListTopUsers failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

detectVoiceActivity

Start the detection of voice in a metadata item

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts, BoolInt } from "@lukehagar/plexjs/sdk/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.library.detectVoiceActivity({
    ids: "<value>",
    force: BoolInt.True,
    manual: BoolInt.True,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryDetectVoiceActivity } from "@lukehagar/plexjs/funcs/libraryDetectVoiceActivity.js";
import { Accepts, BoolInt } from "@lukehagar/plexjs/sdk/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 libraryDetectVoiceActivity(plexAPI, {
    ids: "<value>",
    force: BoolInt.True,
    manual: BoolInt.True,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryDetectVoiceActivity failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

getAugmentationStatus

Get augmentation status and potentially wait for completion

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts, BoolInt } from "@lukehagar/plexjs/sdk/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.library.getAugmentationStatus({
    augmentationId: "<id>",
    wait: BoolInt.True,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryGetAugmentationStatus } from "@lukehagar/plexjs/funcs/libraryGetAugmentationStatus.js";
import { Accepts, BoolInt } from "@lukehagar/plexjs/sdk/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 libraryGetAugmentationStatus(plexAPI, {
    augmentationId: "<id>",
    wait: BoolInt.True,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryGetAugmentationStatus failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

setStreamSelection

Set which streams (audio/subtitle) are selected by this user

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts, BoolInt } from "@lukehagar/plexjs/sdk/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.library.setStreamSelection({
    partId: 360489,
    allParts: BoolInt.True,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { librarySetStreamSelection } from "@lukehagar/plexjs/funcs/librarySetStreamSelection.js";
import { Accepts, BoolInt } from "@lukehagar/plexjs/sdk/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 librarySetStreamSelection(plexAPI, {
    partId: 360489,
    allParts: BoolInt.True,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("librarySetStreamSelection failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

getPerson

Get details for a single actor.

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/sdk/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.library.getPerson({
    personId: "<id>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryGetPerson } from "@lukehagar/plexjs/funcs/libraryGetPerson.js";
import { Accepts } from "@lukehagar/plexjs/sdk/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 libraryGetPerson(plexAPI, {
    personId: "<id>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryGetPerson failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

listPersonMedia

Get all the media for a single actor.

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/sdk/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.library.listPersonMedia({
    personId: "<id>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryListPersonMedia } from "@lukehagar/plexjs/funcs/libraryListPersonMedia.js";
import { Accepts } from "@lukehagar/plexjs/sdk/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 libraryListPersonMedia(plexAPI, {
    personId: "<id>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryListPersonMedia failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

deleteLibrarySection

Delete a library section by id

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts, BoolInt } from "@lukehagar/plexjs/sdk/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.library.deleteLibrarySection({
    sectionId: "<id>",
    async: BoolInt.True,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryDeleteLibrarySection } from "@lukehagar/plexjs/funcs/libraryDeleteLibrarySection.js";
import { Accepts, BoolInt } from "@lukehagar/plexjs/sdk/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 libraryDeleteLibrarySection(plexAPI, {
    sectionId: "<id>",
    async: BoolInt.True,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryDeleteLibrarySection failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

getLibraryDetails

Returns details for the library. This can be thought of as an interstitial endpoint because it contains information about the library, rather than content itself. It often contains a list of Directory metadata objects: These used to be used by clients to build a menuing system.

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts, BoolInt } from "@lukehagar/plexjs/sdk/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.library.getLibraryDetails({
    sectionId: "<id>",
    includeDetails: BoolInt.True,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryGetLibraryDetails } from "@lukehagar/plexjs/funcs/libraryGetLibraryDetails.js";
import { Accepts, BoolInt } from "@lukehagar/plexjs/sdk/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 libraryGetLibraryDetails(plexAPI, {
    sectionId: "<id>",
    includeDetails: BoolInt.True,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryGetLibraryDetails failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

editSection

Edit a library section by id setting parameters

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/sdk/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.library.editSection({
    sectionId: "<id>",
    agent: "<value>",
    locations: [
      "O:\fatboy\\Media\\Ripped\\Music",
      "O:\fatboy\\Media\\My Music",
    ],
    prefs: {},
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryEditSection } from "@lukehagar/plexjs/funcs/libraryEditSection.js";
import { Accepts } from "@lukehagar/plexjs/sdk/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 libraryEditSection(plexAPI, {
    sectionId: "<id>",
    agent: "<value>",
    locations: [
      "O:\fatboy\\Media\\Ripped\\Music",
      "O:\fatboy\\Media\\My Music",
    ],
    prefs: {},
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryEditSection failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

updateItems

This endpoint takes an large possible set of values. Here are some examples.

  • Parameters, extra documentation

    • artist.title.value
      • When used with track, both artist.title.value and album.title.value need to be specified
    • title.value usage
      • Summary
        • Tracks always rename and never merge
        • Albums and Artists
          • if single item and item without title does not exist, it is renamed.
          • if single item and item with title does exist they are merged.
          • if multiple they are always merged.
      • Tracks
        • Works as expected will update the track's title
        • Single track: /library/sections/{id}/all?type=10&id=42&title.value=NewName
        • Multiple tracks: /library/sections/{id}/all?type=10&id=42,43,44&title.value=NewName
        • All tracks: /library/sections/{id}/all?type=10&title.value=NewName
      • Albums
        • Functionality changes depending on the existence of an album with the same title
        • Album exists
          • Single album: /library/sections/{id}/all?type=9&id=42&title.value=Album 2
            • Album with id 42 is merged into album titled "Album 2"
          • Multiple/All albums: /library/sections/{id}/all?type=9&title.value=Moo Album
            • All albums are merged into the existing album titled "Moo Album"
        • Album does not exist
          • Single album: /library/sections/{id}/all?type=9&id=42&title.value=NewAlbumTitle
            • Album with id 42 has title modified to "NewAlbumTitle"
          • Multiple/All albums: /library/sections/{id}/all?type=9&title.value=NewAlbumTitle
            • All albums are merged into a new album with title="NewAlbumTitle"
      • Artists
        • Functionaly changes depending on the existence of an artist with the same title.
        • Artist exists
          • Single artist: /library/sections/{id}/all?type=8&id=42&title.value=Artist 2
            • Artist with id 42 is merged into existing artist titled "Artist 2"
          • Multiple/All artists: /library/sections/{id}/all?type=8&title.value=Artist 3
            • All artists are merged into the existing artist titled "Artist 3"
        • Artist does not exist
          • Single artist: /library/sections/{id}/all?type=8&id=42&title.value=NewArtistTitle
            • Artist with id 42 has title modified to "NewArtistTitle"
          • Multiple/All artists: /library/sections/{id}/all?type=8&title.value=NewArtistTitle
            • All artists are merged into a new artist with title="NewArtistTitle"
  • Notes

    • Technically square brackets are not allowed in an URI except the Internet Protocol Literal Address
    • RFC3513: A host identified by an Internet Protocol literal address, version 6 [RFC3513] or later, is distinguished by enclosing the IP literal within square brackets ("[" and "]"). This is the only place where square bracket characters are allowed in the URI syntax.
    • Escaped square brackets are allowed, but don't render well

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts, BoolInt } from "@lukehagar/plexjs/sdk/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.library.updateItems({
    sectionId: "<id>",
    fieldLocked: BoolInt.True,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryUpdateItems } from "@lukehagar/plexjs/funcs/libraryUpdateItems.js";
import { Accepts, BoolInt } from "@lukehagar/plexjs/sdk/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 libraryUpdateItems(plexAPI, {
    sectionId: "<id>",
    fieldLocked: BoolInt.True,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryUpdateItems failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

startAnalysis

Start analysis of all items in a section. If BIF generation is enabled, this will also be started on this section

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/sdk/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.library.startAnalysis({
    sectionId: 158829,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryStartAnalysis } from "@lukehagar/plexjs/funcs/libraryStartAnalysis.js";
import { Accepts } from "@lukehagar/plexjs/sdk/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 libraryStartAnalysis(plexAPI, {
    sectionId: 158829,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryStartAnalysis failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

autocomplete

The field to autocomplete on is specified by the {field}.query parameter. For example genre.query or title.query. Returns a set of items from the filtered items whose {field} starts with {field}.query. In the results, a {field}.queryRange will be present to express the range of the match

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts, MediaType } from "@lukehagar/plexjs/sdk/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.library.autocomplete({
    sectionId: 942007,
    mediaQuery: {
      type: MediaType.Episode,
      sourceType: 2,
      sort: "duration:desc,index",
    },
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryAutocomplete } from "@lukehagar/plexjs/funcs/libraryAutocomplete.js";
import { Accepts, MediaType } from "@lukehagar/plexjs/sdk/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 libraryAutocomplete(plexAPI, {
    sectionId: 942007,
    mediaQuery: {
      type: MediaType.Episode,
      sourceType: 2,
      sort: "duration:desc,index",
    },
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryAutocomplete failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

getCollections

Get all collections in a section

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts, MediaType } from "@lukehagar/plexjs/sdk/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.library.getCollections({
    sectionId: 348838,
    mediaQuery: {
      type: MediaType.Episode,
      sourceType: 2,
      sort: "duration:desc,index",
    },
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryGetCollections } from "@lukehagar/plexjs/funcs/libraryGetCollections.js";
import { Accepts, MediaType } from "@lukehagar/plexjs/sdk/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 libraryGetCollections(plexAPI, {
    sectionId: 348838,
    mediaQuery: {
      type: MediaType.Episode,
      sourceType: 2,
      sort: "duration:desc,index",
    },
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryGetCollections failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

getCommon

Represents a "Common" item. It contains only the common attributes of the items selected by the provided filter Fields which are not common will be expressed in the mixedFields field

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts, MediaType } from "@lukehagar/plexjs/sdk/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.library.getCommon({
    sectionId: 298154,
    mediaQuery: {
      type: MediaType.Episode,
      sourceType: 2,
      sort: "duration:desc,index",
    },
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryGetCommon } from "@lukehagar/plexjs/funcs/libraryGetCommon.js";
import { Accepts, MediaType } from "@lukehagar/plexjs/sdk/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 libraryGetCommon(plexAPI, {
    sectionId: 298154,
    mediaQuery: {
      type: MediaType.Episode,
      sourceType: 2,
      sort: "duration:desc,index",
    },
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryGetCommon failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

emptyTrash

Empty trash in the section, permanently deleting media/metadata for missing media

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/sdk/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.library.emptyTrash({
    sectionId: 30052,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryEmptyTrash } from "@lukehagar/plexjs/funcs/libraryEmptyTrash.js";
import { Accepts } from "@lukehagar/plexjs/sdk/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 libraryEmptyTrash(plexAPI, {
    sectionId: 30052,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryEmptyTrash failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

getSectionFilters

Get common filters on a section

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/sdk/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.library.getSectionFilters({
    sectionId: 380557,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryGetSectionFilters } from "@lukehagar/plexjs/funcs/libraryGetSectionFilters.js";
import { Accepts } from "@lukehagar/plexjs/sdk/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 libraryGetSectionFilters(plexAPI, {
    sectionId: 380557,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryGetSectionFilters failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

getFirstCharacters

Get list of first characters in this section

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts, MediaType } from "@lukehagar/plexjs/sdk/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.library.getFirstCharacters({
    sectionId: 3947,
    mediaQuery: {
      type: MediaType.Episode,
      sourceType: 2,
      sort: "duration:desc,index",
    },
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryGetFirstCharacters } from "@lukehagar/plexjs/funcs/libraryGetFirstCharacters.js";
import { Accepts, MediaType } from "@lukehagar/plexjs/sdk/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 libraryGetFirstCharacters(plexAPI, {
    sectionId: 3947,
    mediaQuery: {
      type: MediaType.Episode,
      sourceType: 2,
      sort: "duration:desc,index",
    },
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryGetFirstCharacters failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

deleteIndexes

Delete all the indexes in a section

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/sdk/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.library.deleteIndexes({
    sectionId: 588437,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryDeleteIndexes } from "@lukehagar/plexjs/funcs/libraryDeleteIndexes.js";
import { Accepts } from "@lukehagar/plexjs/sdk/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 libraryDeleteIndexes(plexAPI, {
    sectionId: 588437,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryDeleteIndexes failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

deleteIntros

Delete all the intro markers in a section

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/sdk/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.library.deleteIntros({
    sectionId: 498656,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryDeleteIntros } from "@lukehagar/plexjs/funcs/libraryDeleteIntros.js";
import { Accepts } from "@lukehagar/plexjs/sdk/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 libraryDeleteIntros(plexAPI, {
    sectionId: 498656,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryDeleteIntros failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

getSectionPreferences

Get the prefs for a section by id and potentially overriding the agent

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/sdk/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.library.getSectionPreferences({
    sectionId: 754869,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryGetSectionPreferences } from "@lukehagar/plexjs/funcs/libraryGetSectionPreferences.js";
import { Accepts } from "@lukehagar/plexjs/sdk/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 libraryGetSectionPreferences(plexAPI, {
    sectionId: 754869,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryGetSectionPreferences failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

setSectionPreferences

Set the prefs for a section by id

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/sdk/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.library.setSectionPreferences({
    sectionId: 349936,
    prefs: {},
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { librarySetSectionPreferences } from "@lukehagar/plexjs/funcs/librarySetSectionPreferences.js";
import { Accepts } from "@lukehagar/plexjs/sdk/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 librarySetSectionPreferences(plexAPI, {
    sectionId: 349936,
    prefs: {},
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("librarySetSectionPreferences failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

cancelRefresh

Cancel the refresh of a section

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/sdk/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.library.cancelRefresh({
    sectionId: 326852,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryCancelRefresh } from "@lukehagar/plexjs/funcs/libraryCancelRefresh.js";
import { Accepts } from "@lukehagar/plexjs/sdk/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 libraryCancelRefresh(plexAPI, {
    sectionId: 326852,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryCancelRefresh failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

refreshSection

Start a refresh of this section

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts, BoolInt } from "@lukehagar/plexjs/sdk/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.library.refreshSection({
    sectionId: 450300,
    force: BoolInt.True,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryRefreshSection } from "@lukehagar/plexjs/funcs/libraryRefreshSection.js";
import { Accepts, BoolInt } from "@lukehagar/plexjs/sdk/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 libraryRefreshSection(plexAPI, {
    sectionId: 450300,
    force: BoolInt.True,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryRefreshSection failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

getAvailableSorts

Get the sort mechanisms available in a section

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/sdk/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.library.getAvailableSorts({
    sectionId: 212498,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryGetAvailableSorts } from "@lukehagar/plexjs/funcs/libraryGetAvailableSorts.js";
import { Accepts } from "@lukehagar/plexjs/sdk/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 libraryGetAvailableSorts(plexAPI, {
    sectionId: 212498,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryGetAvailableSorts failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

getStreamLevels

The the loudness of a stream in db, one entry per 100ms

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/sdk/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.library.getStreamLevels({
    streamId: 447611,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryGetStreamLevels } from "@lukehagar/plexjs/funcs/libraryGetStreamLevels.js";
import { Accepts } from "@lukehagar/plexjs/sdk/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 libraryGetStreamLevels(plexAPI, {
    streamId: 447611,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryGetStreamLevels failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

getStreamLoudness

The the loudness of a stream in db, one number per line, one entry per 100ms

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/sdk/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.library.getStreamLoudness({
    streamId: 277271,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryGetStreamLoudness } from "@lukehagar/plexjs/funcs/libraryGetStreamLoudness.js";
import { Accepts } from "@lukehagar/plexjs/sdk/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 libraryGetStreamLoudness(plexAPI, {
    streamId: 277271,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryGetStreamLoudness failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

getChapterImage

Get a single chapter image for a piece of media

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/sdk/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.library.getChapterImage({
    mediaId: 892563,
    chapter: 48348,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryGetChapterImage } from "@lukehagar/plexjs/funcs/libraryGetChapterImage.js";
import { Accepts } from "@lukehagar/plexjs/sdk/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 libraryGetChapterImage(plexAPI, {
    mediaId: 892563,
    chapter: 48348,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryGetChapterImage failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

setItemArtwork

Set the artwork, thumb, element for a metadata item Generally only the admin can perform this action. The exception is if the metadata is a playlist created by the user

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { SetItemArtworkElement } from "@lukehagar/plexjs/sdk/models/operations";
import { Accepts } from "@lukehagar/plexjs/sdk/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.library.setItemArtwork({
    ids: "<value>",
    element: SetItemArtworkElement.Banner,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { librarySetItemArtwork } from "@lukehagar/plexjs/funcs/librarySetItemArtwork.js";
import { SetItemArtworkElement } from "@lukehagar/plexjs/sdk/models/operations";
import { Accepts } from "@lukehagar/plexjs/sdk/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 librarySetItemArtwork(plexAPI, {
    ids: "<value>",
    element: SetItemArtworkElement.Banner,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("librarySetItemArtwork failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

updateItemArtwork

Set the artwork, thumb, element for a metadata item Generally only the admin can perform this action. The exception is if the metadata is a playlist created by the user

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { UpdateItemArtworkElement } from "@lukehagar/plexjs/sdk/models/operations";
import { Accepts } from "@lukehagar/plexjs/sdk/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.library.updateItemArtwork({
    ids: "<value>",
    element: UpdateItemArtworkElement.ClearLogo,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryUpdateItemArtwork } from "@lukehagar/plexjs/funcs/libraryUpdateItemArtwork.js";
import { UpdateItemArtworkElement } from "@lukehagar/plexjs/sdk/models/operations";
import { Accepts } from "@lukehagar/plexjs/sdk/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 libraryUpdateItemArtwork(plexAPI, {
    ids: "<value>",
    element: UpdateItemArtworkElement.ClearLogo,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryUpdateItemArtwork failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

deleteMarker

Delete a marker for this user on the metadata item

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/sdk/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.library.deleteMarker({
    ids: "<value>",
    marker: "<value>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryDeleteMarker } from "@lukehagar/plexjs/funcs/libraryDeleteMarker.js";
import { Accepts } from "@lukehagar/plexjs/sdk/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 libraryDeleteMarker(plexAPI, {
    ids: "<value>",
    marker: "<value>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryDeleteMarker failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

editMarker

Edit a marker for this user on the metadata item

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/sdk/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.library.editMarker({
    ids: "<value>",
    marker: "<value>",
    type: 884347,
    startTimeOffset: 517251,
    attributes: {},
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryEditMarker } from "@lukehagar/plexjs/funcs/libraryEditMarker.js";
import { Accepts } from "@lukehagar/plexjs/sdk/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 libraryEditMarker(plexAPI, {
    ids: "<value>",
    marker: "<value>",
    type: 884347,
    startTimeOffset: 517251,
    attributes: {},
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryEditMarker failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

deleteMediaItem

Delete a single media from a metadata item in the library

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts, BoolInt } from "@lukehagar/plexjs/sdk/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.library.deleteMediaItem({
    ids: "<value>",
    mediaItem: "<value>",
    proxy: BoolInt.True,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryDeleteMediaItem } from "@lukehagar/plexjs/funcs/libraryDeleteMediaItem.js";
import { Accepts, BoolInt } from "@lukehagar/plexjs/sdk/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 libraryDeleteMediaItem(plexAPI, {
    ids: "<value>",
    mediaItem: "<value>",
    proxy: BoolInt.True,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryDeleteMediaItem failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

getPartIndex

Get BIF index for a part by index type

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { GetPartIndexIndex } from "@lukehagar/plexjs/sdk/models/operations";
import { Accepts } from "@lukehagar/plexjs/sdk/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.library.getPartIndex({
    partId: 724750,
    index: GetPartIndexIndex.Sd,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryGetPartIndex } from "@lukehagar/plexjs/funcs/libraryGetPartIndex.js";
import { GetPartIndexIndex } from "@lukehagar/plexjs/sdk/models/operations";
import { Accepts } from "@lukehagar/plexjs/sdk/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 libraryGetPartIndex(plexAPI, {
    partId: 724750,
    index: GetPartIndexIndex.Sd,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryGetPartIndex failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

deleteCollection

Delete a library collection from the PMS

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/sdk/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.library.deleteCollection({
    sectionId: 283619,
    collectionId: 680895,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryDeleteCollection } from "@lukehagar/plexjs/funcs/libraryDeleteCollection.js";
import { Accepts } from "@lukehagar/plexjs/sdk/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 libraryDeleteCollection(plexAPI, {
    sectionId: 283619,
    collectionId: 680895,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryDeleteCollection failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

getSectionImage

Get a composite image of images in this section

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts, MediaType } from "@lukehagar/plexjs/sdk/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.library.getSectionImage({
    sectionId: 925611,
    updatedAt: 117413,
    mediaQuery: {
      type: MediaType.Episode,
      sourceType: 2,
      sort: "duration:desc,index",
    },
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryGetSectionImage } from "@lukehagar/plexjs/funcs/libraryGetSectionImage.js";
import { Accepts, MediaType } from "@lukehagar/plexjs/sdk/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 libraryGetSectionImage(plexAPI, {
    sectionId: 925611,
    updatedAt: 117413,
    mediaQuery: {
      type: MediaType.Episode,
      sourceType: 2,
      sort: "duration:desc,index",
    },
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryGetSectionImage failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

deleteStream

Delete a stream. Only applies to downloaded subtitle streams or a sidecar subtitle when media deletion is enabled.

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/sdk/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.library.deleteStream({
    streamId: 841510,
    ext: "<value>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryDeleteStream } from "@lukehagar/plexjs/funcs/libraryDeleteStream.js";
import { Accepts } from "@lukehagar/plexjs/sdk/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 libraryDeleteStream(plexAPI, {
    streamId: 841510,
    ext: "<value>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryDeleteStream failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

getStream

Get a stream (such as a sidecar subtitle stream)

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts, BoolInt } from "@lukehagar/plexjs/sdk/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.library.getStream({
    streamId: 314506,
    ext: "<value>",
    autoAdjustSubtitle: BoolInt.True,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryGetStream } from "@lukehagar/plexjs/funcs/libraryGetStream.js";
import { Accepts, BoolInt } from "@lukehagar/plexjs/sdk/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 libraryGetStream(plexAPI, {
    streamId: 314506,
    ext: "<value>",
    autoAdjustSubtitle: BoolInt.True,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryGetStream failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

setStreamOffset

Set a stream offset in ms. This may not be respected by all clients

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/sdk/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.library.setStreamOffset({
    streamId: 606295,
    ext: "<value>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { librarySetStreamOffset } from "@lukehagar/plexjs/funcs/librarySetStreamOffset.js";
import { Accepts } from "@lukehagar/plexjs/sdk/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 librarySetStreamOffset(plexAPI, {
    streamId: 606295,
    ext: "<value>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("librarySetStreamOffset failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

getItemArtwork

Get the artwork, thumb, element for a metadata item

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { GetItemArtworkElement } from "@lukehagar/plexjs/sdk/models/operations";
import { Accepts } from "@lukehagar/plexjs/sdk/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.library.getItemArtwork({
    ids: "<value>",
    element: GetItemArtworkElement.Poster,
    timestamp: 999555,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryGetItemArtwork } from "@lukehagar/plexjs/funcs/libraryGetItemArtwork.js";
import { GetItemArtworkElement } from "@lukehagar/plexjs/sdk/models/operations";
import { Accepts } from "@lukehagar/plexjs/sdk/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 libraryGetItemArtwork(plexAPI, {
    ids: "<value>",
    element: GetItemArtworkElement.Poster,
    timestamp: 999555,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryGetItemArtwork failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

getMediaPart

Get a media part for streaming or download.

  • streaming: This is the default scenario. Bandwidth usage on this endpoint will be guaranteed (on the server's end) to be at least the bandwidth reservation given in the decision. If no decision exists, an ad-hoc decision will be created if sufficient bandwidth exists. Clients should not rely on ad-hoc decisions being made as this may be removed in the future.
  • download: Indicated if the query parameter indicates this is a download. Bandwidth will be prioritized behind playbacks and will get a fair share of what remains.

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts, BoolInt } from "@lukehagar/plexjs/sdk/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.library.getMediaPart({
    partId: 877105,
    changestamp: 970622,
    filename: "example.file",
    download: BoolInt.True,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryGetMediaPart } from "@lukehagar/plexjs/funcs/libraryGetMediaPart.js";
import { Accepts, BoolInt } from "@lukehagar/plexjs/sdk/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 libraryGetMediaPart(plexAPI, {
    partId: 877105,
    changestamp: 970622,
    filename: "example.file",
    download: BoolInt.True,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryGetMediaPart failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

getImageFromBif

Extract an image from the BIF for a part at a particular offset

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { GetImageFromBifIndex } from "@lukehagar/plexjs/sdk/models/operations";
import { Accepts } from "@lukehagar/plexjs/sdk/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.library.getImageFromBif({
    partId: 304273,
    index: GetImageFromBifIndex.Sd,
    offset: 939569,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { libraryGetImageFromBif } from "@lukehagar/plexjs/funcs/libraryGetImageFromBif.js";
import { GetImageFromBifIndex } from "@lukehagar/plexjs/sdk/models/operations";
import { Accepts } from "@lukehagar/plexjs/sdk/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 libraryGetImageFromBif(plexAPI, {
    partId: 304273,
    index: GetImageFromBifIndex.Sd,
    offset: 939569,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("libraryGetImageFromBif failed:", res.error);
  }
}

run();

Parameters

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

Errors

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