(statistics)
API Calls that perform operations with Plex Media Server Statistics
- getStatistics - Get Media Statistics
- getResourcesStatistics - Get Resources Statistics
- getBandwidthStatistics - Get Bandwidth Statistics
This will return the media statistics for the server
import { PlexAPI } from "@lukehagar/plexjs";
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await plexAPI.statistics.getStatistics(4);
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { statisticsGetStatistics } from "@lukehagar/plexjs/funcs/statisticsGetStatistics.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>",
});
async function run() {
const res = await statisticsGetStatistics(plexAPI, 4);
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
timespan |
number | ➖ | The timespan to retrieve statistics for the exact meaning of this parameter is not known |
[object Object] |
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. |
Promise<operations.GetStatisticsResponse>
Error Type | Status Code | Content Type |
---|---|---|
errors.GetStatisticsBadRequest | 400 | application/json |
errors.GetStatisticsUnauthorized | 401 | application/json |
errors.SDKError | 4XX, 5XX | */* |
This will return the resources for the server
import { PlexAPI } from "@lukehagar/plexjs";
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await plexAPI.statistics.getResourcesStatistics(4);
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { statisticsGetResourcesStatistics } from "@lukehagar/plexjs/funcs/statisticsGetResourcesStatistics.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>",
});
async function run() {
const res = await statisticsGetResourcesStatistics(plexAPI, 4);
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
timespan |
number | ➖ | The timespan to retrieve statistics for the exact meaning of this parameter is not known |
[object Object] |
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. |
Promise<operations.GetResourcesStatisticsResponse>
Error Type | Status Code | Content Type |
---|---|---|
errors.GetResourcesStatisticsBadRequest | 400 | application/json |
errors.GetResourcesStatisticsUnauthorized | 401 | application/json |
errors.SDKError | 4XX, 5XX | */* |
This will return the bandwidth statistics for the server
import { PlexAPI } from "@lukehagar/plexjs";
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await plexAPI.statistics.getBandwidthStatistics(4);
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { statisticsGetBandwidthStatistics } from "@lukehagar/plexjs/funcs/statisticsGetBandwidthStatistics.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>",
});
async function run() {
const res = await statisticsGetBandwidthStatistics(plexAPI, 4);
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
timespan |
number | ➖ | The timespan to retrieve statistics for the exact meaning of this parameter is not known |
[object Object] |
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. |
Promise<operations.GetBandwidthStatisticsResponse>
Error Type | Status Code | Content Type |
---|---|---|
errors.GetBandwidthStatisticsBadRequest | 400 | application/json |
errors.GetBandwidthStatisticsUnauthorized | 401 | application/json |
errors.SDKError | 4XX, 5XX | */* |