(watchlist)
API Calls that perform operations with Plex Media Server Watchlists
- getWatchList - Get User Watchlist
Get User Watchlist
import { PlexAPI } from "@lukehagar/plexjs";
import { Filter } from "@lukehagar/plexjs/sdk/models/operations";
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await plexAPI.watchlist.getWatchList({
filter: Filter.Available,
xPlexToken: "CV5xoxjTpFKUzBTShsaf",
});
// Handle the result
console.log(result);
}
run();
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>",
});
async function run() {
const res = await watchlistGetWatchList(plexAPI, {
filter: Filter.Available,
xPlexToken: "CV5xoxjTpFKUzBTShsaf",
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
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. |
Promise<operations.GetWatchListResponse>
Error Type | Status Code | Content Type |
---|---|---|
errors.GetWatchListBadRequest | 400 | application/json |
errors.GetWatchListUnauthorized | 401 | application/json |
errors.SDKError | 4XX, 5XX | */* |