mirror of
https://github.com/LukeHagar/plexjs.git
synced 2025-12-06 04:20:46 +00:00
14 KiB
14 KiB
Hubs
(hubs)
Overview
Hubs are a structured two-dimensional container for media, generally represented by multiple horizontal rows.
Available Operations
- getGlobalHubs - Get Global Hubs
- getLibraryHubs - Get library specific hubs
getGlobalHubs
Get Global Hubs filtered by the parameters provided.
Example Usage
import { PlexAPI } from "@lukehagar/plexjs";
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "gcgzw5rz2xovp84b4vha3a40",
});
async function run() {
const result = await plexAPI.hubs.getGlobalHubs();
// Handle the result
console.log(result)
}
run();
Standalone function
The standalone function version of this method:
import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { hubsGetGlobalHubs } from "@lukehagar/plexjs/funcs/hubsGetGlobalHubs.js";
// 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 hubsGetGlobalHubs(plexAPI);
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result)
}
run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
count |
number | ➖ | The number of items to return with each hub. |
onlyTransient |
models.OnlyTransient | ➖ | Only return hubs which are "transient", meaning those which are prone to changing after media playback or addition (e.g. On Deck, or Recently Added). |
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<models.GetGlobalHubsResponse>
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| models.GetGlobalHubsHubsResponseBody | 401 | application/json |
| models.SDKError | 4xx-5xx | / |
getLibraryHubs
This endpoint will return a list of library specific hubs
Example Usage
import { PlexAPI } from "@lukehagar/plexjs";
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "gcgzw5rz2xovp84b4vha3a40",
});
async function run() {
const result = await plexAPI.hubs.getLibraryHubs(6728.76);
// Handle the result
console.log(result)
}
run();
Standalone function
The standalone function version of this method:
import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { hubsGetLibraryHubs } from "@lukehagar/plexjs/funcs/hubsGetLibraryHubs.js";
// 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 hubsGetLibraryHubs(plexAPI, 639.24);
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result)
}
run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
sectionId |
number | ✔️ | the Id of the library to query |
count |
number | ➖ | The number of items to return with each hub. |
onlyTransient |
models.QueryParamOnlyTransient | ➖ | Only return hubs which are "transient", meaning those which are prone to changing after media playback or addition (e.g. On Deck, or Recently Added). |
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<models.GetLibraryHubsResponse>
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| models.GetLibraryHubsHubsResponseBody | 401 | application/json |
| models.SDKError | 4xx-5xx | / |