mirror of
https://github.com/LukeHagar/plexjs.git
synced 2025-12-06 04:20:46 +00:00
7.1 KiB
7.1 KiB
Watchlist
(watchlist)
Overview
API Calls that perform operations with Plex Media Server Watchlists
Available Operations
- getWatchList - Get User Watchlist
getWatchList
Get User Watchlist
Example Usage
import { PlexAPI } from "@lukehagar/plexjs";
import { Filter } from "@lukehagar/plexjs/sdk/models/operations";
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "gcgzw5rz2xovp84b4vha3a40",
});
async function run() {
const result = await plexAPI.watchlist.getWatchList({
filter: Filter.Available,
xPlexContainerStart: 0,
xPlexContainerSize: 50,
xPlexToken: "CV5xoxjTpFKUzBTShsaf",
});
// Handle the result
console.log(result)
}
run();
Standalone function
The standalone function version of this method:
import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { watchlistGetWatchList } from "@lukehagar/plexjs/funcs/watchlistGetWatchList.js";
import { Filter } from "@lukehagar/plexjs/sdk/models/operations";
// Use `PlexAPICore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const plexAPI = new PlexAPICore({
accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "gcgzw5rz2xovp84b4vha3a40",
});
async function run() {
const res = await watchlistGetWatchList(plexAPI, {
filter: Filter.Available,
xPlexContainerStart: 0,
xPlexContainerSize: 50,
xPlexToken: "CV5xoxjTpFKUzBTShsaf",
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result)
}
run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.GetWatchListRequest | ✔️ | 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. |
options.serverURL |
string | ➖ | An optional server URL to use. |
Response
Promise<operations.GetWatchListResponse>
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| errors.GetWatchListBadRequest | 400 | application/json |
| errors.GetWatchListUnauthorized | 401 | application/json |
| errors.SDKError | 4xx-5xx | / |