mirror of
https://github.com/LukeHagar/plexjs.git
synced 2025-12-06 12:37:46 +00:00
721 lines
51 KiB
Markdown
721 lines
51 KiB
Markdown
# Server
|
|
(*server*)
|
|
|
|
## Overview
|
|
|
|
Operations against the Plex Media Server System.
|
|
|
|
|
|
### Available Operations
|
|
|
|
* [getServerCapabilities](#getservercapabilities) - Get Server Capabilities
|
|
* [getServerPreferences](#getserverpreferences) - Get Server Preferences
|
|
* [getAvailableClients](#getavailableclients) - Get Available Clients
|
|
* [getDevices](#getdevices) - Get Devices
|
|
* [getServerIdentity](#getserveridentity) - Get Server Identity
|
|
* [getMyPlexAccount](#getmyplexaccount) - Get MyPlex Account
|
|
* [getResizedPhoto](#getresizedphoto) - Get a Resized Photo
|
|
* [getMediaProviders](#getmediaproviders) - Get Media Providers
|
|
* [getServerList](#getserverlist) - Get Server List
|
|
|
|
## getServerCapabilities
|
|
|
|
Get Server Capabilities
|
|
|
|
### Example Usage
|
|
|
|
```typescript
|
|
import { PlexAPI } from "@lukehagar/plexjs";
|
|
|
|
const plexAPI = new PlexAPI({
|
|
accessToken: "<YOUR_API_KEY_HERE>",
|
|
xPlexClientIdentifier: "gcgzw5rz2xovp84b4vha3a40",
|
|
});
|
|
|
|
async function run() {
|
|
const result = await plexAPI.server.getServerCapabilities();
|
|
|
|
// Handle the result
|
|
console.log(result)
|
|
}
|
|
|
|
run();
|
|
```
|
|
|
|
### Standalone function
|
|
|
|
The standalone function version of this method:
|
|
|
|
```typescript
|
|
import { PlexAPICore } from "@lukehagar/plexjs/core.js";
|
|
import { serverGetServerCapabilities } from "@lukehagar/plexjs/funcs/serverGetServerCapabilities.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 serverGetServerCapabilities(plexAPI);
|
|
|
|
if (!res.ok) {
|
|
throw res.error;
|
|
}
|
|
|
|
const { value: result } = res;
|
|
|
|
// Handle the result
|
|
console.log(result)
|
|
}
|
|
|
|
run();
|
|
```
|
|
|
|
### Parameters
|
|
|
|
| Parameter | Type | Required | Description |
|
|
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
|
|
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | 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](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
|
|
|
|
### Response
|
|
|
|
**Promise\<[operations.GetServerCapabilitiesResponse](../../sdk/models/operations/getservercapabilitiesresponse.md)\>**
|
|
|
|
### Errors
|
|
|
|
| Error Object | Status Code | Content Type |
|
|
| ---------------------------------------- | ---------------------------------------- | ---------------------------------------- |
|
|
| errors.GetServerCapabilitiesBadRequest | 400 | application/json |
|
|
| errors.GetServerCapabilitiesUnauthorized | 401 | application/json |
|
|
| errors.SDKError | 4xx-5xx | */* |
|
|
|
|
|
|
## getServerPreferences
|
|
|
|
Get Server Preferences
|
|
|
|
### Example Usage
|
|
|
|
```typescript
|
|
import { PlexAPI } from "@lukehagar/plexjs";
|
|
|
|
const plexAPI = new PlexAPI({
|
|
accessToken: "<YOUR_API_KEY_HERE>",
|
|
xPlexClientIdentifier: "gcgzw5rz2xovp84b4vha3a40",
|
|
});
|
|
|
|
async function run() {
|
|
const result = await plexAPI.server.getServerPreferences();
|
|
|
|
// Handle the result
|
|
console.log(result)
|
|
}
|
|
|
|
run();
|
|
```
|
|
|
|
### Standalone function
|
|
|
|
The standalone function version of this method:
|
|
|
|
```typescript
|
|
import { PlexAPICore } from "@lukehagar/plexjs/core.js";
|
|
import { serverGetServerPreferences } from "@lukehagar/plexjs/funcs/serverGetServerPreferences.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 serverGetServerPreferences(plexAPI);
|
|
|
|
if (!res.ok) {
|
|
throw res.error;
|
|
}
|
|
|
|
const { value: result } = res;
|
|
|
|
// Handle the result
|
|
console.log(result)
|
|
}
|
|
|
|
run();
|
|
```
|
|
|
|
### Parameters
|
|
|
|
| Parameter | Type | Required | Description |
|
|
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
|
|
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | 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](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
|
|
|
|
### Response
|
|
|
|
**Promise\<[operations.GetServerPreferencesResponse](../../sdk/models/operations/getserverpreferencesresponse.md)\>**
|
|
|
|
### Errors
|
|
|
|
| Error Object | Status Code | Content Type |
|
|
| --------------------------------------- | --------------------------------------- | --------------------------------------- |
|
|
| errors.GetServerPreferencesBadRequest | 400 | application/json |
|
|
| errors.GetServerPreferencesUnauthorized | 401 | application/json |
|
|
| errors.SDKError | 4xx-5xx | */* |
|
|
|
|
|
|
## getAvailableClients
|
|
|
|
Get Available Clients
|
|
|
|
### Example Usage
|
|
|
|
```typescript
|
|
import { PlexAPI } from "@lukehagar/plexjs";
|
|
|
|
const plexAPI = new PlexAPI({
|
|
accessToken: "<YOUR_API_KEY_HERE>",
|
|
xPlexClientIdentifier: "gcgzw5rz2xovp84b4vha3a40",
|
|
});
|
|
|
|
async function run() {
|
|
const result = await plexAPI.server.getAvailableClients();
|
|
|
|
// Handle the result
|
|
console.log(result)
|
|
}
|
|
|
|
run();
|
|
```
|
|
|
|
### Standalone function
|
|
|
|
The standalone function version of this method:
|
|
|
|
```typescript
|
|
import { PlexAPICore } from "@lukehagar/plexjs/core.js";
|
|
import { serverGetAvailableClients } from "@lukehagar/plexjs/funcs/serverGetAvailableClients.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 serverGetAvailableClients(plexAPI);
|
|
|
|
if (!res.ok) {
|
|
throw res.error;
|
|
}
|
|
|
|
const { value: result } = res;
|
|
|
|
// Handle the result
|
|
console.log(result)
|
|
}
|
|
|
|
run();
|
|
```
|
|
|
|
### Parameters
|
|
|
|
| Parameter | Type | Required | Description |
|
|
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
|
|
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | 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](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
|
|
|
|
### Response
|
|
|
|
**Promise\<[operations.GetAvailableClientsResponse](../../sdk/models/operations/getavailableclientsresponse.md)\>**
|
|
|
|
### Errors
|
|
|
|
| Error Object | Status Code | Content Type |
|
|
| -------------------------------------- | -------------------------------------- | -------------------------------------- |
|
|
| errors.GetAvailableClientsBadRequest | 400 | application/json |
|
|
| errors.GetAvailableClientsUnauthorized | 401 | application/json |
|
|
| errors.SDKError | 4xx-5xx | */* |
|
|
|
|
|
|
## getDevices
|
|
|
|
Get Devices
|
|
|
|
### Example Usage
|
|
|
|
```typescript
|
|
import { PlexAPI } from "@lukehagar/plexjs";
|
|
|
|
const plexAPI = new PlexAPI({
|
|
accessToken: "<YOUR_API_KEY_HERE>",
|
|
xPlexClientIdentifier: "gcgzw5rz2xovp84b4vha3a40",
|
|
});
|
|
|
|
async function run() {
|
|
const result = await plexAPI.server.getDevices();
|
|
|
|
// Handle the result
|
|
console.log(result)
|
|
}
|
|
|
|
run();
|
|
```
|
|
|
|
### Standalone function
|
|
|
|
The standalone function version of this method:
|
|
|
|
```typescript
|
|
import { PlexAPICore } from "@lukehagar/plexjs/core.js";
|
|
import { serverGetDevices } from "@lukehagar/plexjs/funcs/serverGetDevices.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 serverGetDevices(plexAPI);
|
|
|
|
if (!res.ok) {
|
|
throw res.error;
|
|
}
|
|
|
|
const { value: result } = res;
|
|
|
|
// Handle the result
|
|
console.log(result)
|
|
}
|
|
|
|
run();
|
|
```
|
|
|
|
### Parameters
|
|
|
|
| Parameter | Type | Required | Description |
|
|
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
|
|
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | 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](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
|
|
|
|
### Response
|
|
|
|
**Promise\<[operations.GetDevicesResponse](../../sdk/models/operations/getdevicesresponse.md)\>**
|
|
|
|
### Errors
|
|
|
|
| Error Object | Status Code | Content Type |
|
|
| ----------------------------- | ----------------------------- | ----------------------------- |
|
|
| errors.GetDevicesBadRequest | 400 | application/json |
|
|
| errors.GetDevicesUnauthorized | 401 | application/json |
|
|
| errors.SDKError | 4xx-5xx | */* |
|
|
|
|
|
|
## getServerIdentity
|
|
|
|
This request is useful to determine if the server is online or offline
|
|
|
|
### Example Usage
|
|
|
|
```typescript
|
|
import { PlexAPI } from "@lukehagar/plexjs";
|
|
|
|
const plexAPI = new PlexAPI({
|
|
xPlexClientIdentifier: "gcgzw5rz2xovp84b4vha3a40",
|
|
});
|
|
|
|
async function run() {
|
|
const result = await plexAPI.server.getServerIdentity();
|
|
|
|
// Handle the result
|
|
console.log(result)
|
|
}
|
|
|
|
run();
|
|
```
|
|
|
|
### Standalone function
|
|
|
|
The standalone function version of this method:
|
|
|
|
```typescript
|
|
import { PlexAPICore } from "@lukehagar/plexjs/core.js";
|
|
import { serverGetServerIdentity } from "@lukehagar/plexjs/funcs/serverGetServerIdentity.js";
|
|
|
|
// Use `PlexAPICore` for best tree-shaking performance.
|
|
// You can create one instance of it to use across an application.
|
|
const plexAPI = new PlexAPICore({
|
|
xPlexClientIdentifier: "gcgzw5rz2xovp84b4vha3a40",
|
|
});
|
|
|
|
async function run() {
|
|
const res = await serverGetServerIdentity(plexAPI);
|
|
|
|
if (!res.ok) {
|
|
throw res.error;
|
|
}
|
|
|
|
const { value: result } = res;
|
|
|
|
// Handle the result
|
|
console.log(result)
|
|
}
|
|
|
|
run();
|
|
```
|
|
|
|
### Parameters
|
|
|
|
| Parameter | Type | Required | Description |
|
|
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
|
|
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | 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](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
|
|
|
|
### Response
|
|
|
|
**Promise\<[operations.GetServerIdentityResponse](../../sdk/models/operations/getserveridentityresponse.md)\>**
|
|
|
|
### Errors
|
|
|
|
| Error Object | Status Code | Content Type |
|
|
| -------------------------------------- | -------------------------------------- | -------------------------------------- |
|
|
| errors.GetServerIdentityRequestTimeout | 408 | application/json |
|
|
| errors.SDKError | 4xx-5xx | */* |
|
|
|
|
|
|
## getMyPlexAccount
|
|
|
|
Returns MyPlex Account Information
|
|
|
|
### Example Usage
|
|
|
|
```typescript
|
|
import { PlexAPI } from "@lukehagar/plexjs";
|
|
|
|
const plexAPI = new PlexAPI({
|
|
accessToken: "<YOUR_API_KEY_HERE>",
|
|
xPlexClientIdentifier: "gcgzw5rz2xovp84b4vha3a40",
|
|
});
|
|
|
|
async function run() {
|
|
const result = await plexAPI.server.getMyPlexAccount();
|
|
|
|
// Handle the result
|
|
console.log(result)
|
|
}
|
|
|
|
run();
|
|
```
|
|
|
|
### Standalone function
|
|
|
|
The standalone function version of this method:
|
|
|
|
```typescript
|
|
import { PlexAPICore } from "@lukehagar/plexjs/core.js";
|
|
import { serverGetMyPlexAccount } from "@lukehagar/plexjs/funcs/serverGetMyPlexAccount.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 serverGetMyPlexAccount(plexAPI);
|
|
|
|
if (!res.ok) {
|
|
throw res.error;
|
|
}
|
|
|
|
const { value: result } = res;
|
|
|
|
// Handle the result
|
|
console.log(result)
|
|
}
|
|
|
|
run();
|
|
```
|
|
|
|
### Parameters
|
|
|
|
| Parameter | Type | Required | Description |
|
|
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
|
|
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | 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](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
|
|
|
|
### Response
|
|
|
|
**Promise\<[operations.GetMyPlexAccountResponse](../../sdk/models/operations/getmyplexaccountresponse.md)\>**
|
|
|
|
### Errors
|
|
|
|
| Error Object | Status Code | Content Type |
|
|
| ----------------------------------- | ----------------------------------- | ----------------------------------- |
|
|
| errors.GetMyPlexAccountBadRequest | 400 | application/json |
|
|
| errors.GetMyPlexAccountUnauthorized | 401 | application/json |
|
|
| errors.SDKError | 4xx-5xx | */* |
|
|
|
|
|
|
## getResizedPhoto
|
|
|
|
Plex's Photo transcoder is used throughout the service to serve images at specified sizes.
|
|
|
|
|
|
### Example Usage
|
|
|
|
```typescript
|
|
import { PlexAPI } from "@lukehagar/plexjs";
|
|
import { MinSize, Upscale } from "@lukehagar/plexjs/sdk/models/operations";
|
|
|
|
const plexAPI = new PlexAPI({
|
|
accessToken: "<YOUR_API_KEY_HERE>",
|
|
xPlexClientIdentifier: "gcgzw5rz2xovp84b4vha3a40",
|
|
});
|
|
|
|
async function run() {
|
|
const result = await plexAPI.server.getResizedPhoto({
|
|
width: 110,
|
|
height: 165,
|
|
opacity: 100,
|
|
blur: 20,
|
|
minSize: MinSize.One,
|
|
upscale: Upscale.One,
|
|
url: "/library/metadata/49564/thumb/1654258204",
|
|
});
|
|
|
|
// Handle the result
|
|
console.log(result)
|
|
}
|
|
|
|
run();
|
|
```
|
|
|
|
### Standalone function
|
|
|
|
The standalone function version of this method:
|
|
|
|
```typescript
|
|
import { PlexAPICore } from "@lukehagar/plexjs/core.js";
|
|
import { serverGetResizedPhoto } from "@lukehagar/plexjs/funcs/serverGetResizedPhoto.js";
|
|
import { MinSize, Upscale } 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 serverGetResizedPhoto(plexAPI, {
|
|
width: 110,
|
|
height: 165,
|
|
opacity: 100,
|
|
blur: 20,
|
|
minSize: MinSize.One,
|
|
upscale: Upscale.Zero,
|
|
url: "/library/metadata/49564/thumb/1654258204",
|
|
});
|
|
|
|
if (!res.ok) {
|
|
throw res.error;
|
|
}
|
|
|
|
const { value: result } = res;
|
|
|
|
// Handle the result
|
|
console.log(result)
|
|
}
|
|
|
|
run();
|
|
```
|
|
|
|
### Parameters
|
|
|
|
| Parameter | Type | Required | Description |
|
|
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
| `request` | [operations.GetResizedPhotoRequest](../../sdk/models/operations/getresizedphotorequest.md) | :heavy_check_mark: | The request object to use for the request. |
|
|
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
|
|
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | 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](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
|
|
|
|
### Response
|
|
|
|
**Promise\<[operations.GetResizedPhotoResponse](../../sdk/models/operations/getresizedphotoresponse.md)\>**
|
|
|
|
### Errors
|
|
|
|
| Error Object | Status Code | Content Type |
|
|
| ---------------------------------- | ---------------------------------- | ---------------------------------- |
|
|
| errors.GetResizedPhotoBadRequest | 400 | application/json |
|
|
| errors.GetResizedPhotoUnauthorized | 401 | application/json |
|
|
| errors.SDKError | 4xx-5xx | */* |
|
|
|
|
|
|
## getMediaProviders
|
|
|
|
Retrieves media providers and their features from the Plex server.
|
|
|
|
### Example Usage
|
|
|
|
```typescript
|
|
import { PlexAPI } from "@lukehagar/plexjs";
|
|
|
|
const plexAPI = new PlexAPI({
|
|
accessToken: "<YOUR_API_KEY_HERE>",
|
|
xPlexClientIdentifier: "gcgzw5rz2xovp84b4vha3a40",
|
|
});
|
|
|
|
async function run() {
|
|
const result = await plexAPI.server.getMediaProviders("CV5xoxjTpFKUzBTShsaf");
|
|
|
|
// Handle the result
|
|
console.log(result)
|
|
}
|
|
|
|
run();
|
|
```
|
|
|
|
### Standalone function
|
|
|
|
The standalone function version of this method:
|
|
|
|
```typescript
|
|
import { PlexAPICore } from "@lukehagar/plexjs/core.js";
|
|
import { serverGetMediaProviders } from "@lukehagar/plexjs/funcs/serverGetMediaProviders.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 serverGetMediaProviders(plexAPI, "CV5xoxjTpFKUzBTShsaf");
|
|
|
|
if (!res.ok) {
|
|
throw res.error;
|
|
}
|
|
|
|
const { value: result } = res;
|
|
|
|
// Handle the result
|
|
console.log(result)
|
|
}
|
|
|
|
run();
|
|
```
|
|
|
|
### Parameters
|
|
|
|
| Parameter | Type | Required | Description | Example |
|
|
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
| `xPlexToken` | *string* | :heavy_check_mark: | Plex Authentication Token | [object Object] |
|
|
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. | |
|
|
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | 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](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | |
|
|
|
|
### Response
|
|
|
|
**Promise\<[operations.GetMediaProvidersResponse](../../sdk/models/operations/getmediaprovidersresponse.md)\>**
|
|
|
|
### Errors
|
|
|
|
| Error Object | Status Code | Content Type |
|
|
| ------------------------------------ | ------------------------------------ | ------------------------------------ |
|
|
| errors.GetMediaProvidersBadRequest | 400 | application/json |
|
|
| errors.GetMediaProvidersUnauthorized | 401 | application/json |
|
|
| errors.SDKError | 4xx-5xx | */* |
|
|
|
|
|
|
## getServerList
|
|
|
|
Get Server List
|
|
|
|
### Example Usage
|
|
|
|
```typescript
|
|
import { PlexAPI } from "@lukehagar/plexjs";
|
|
|
|
const plexAPI = new PlexAPI({
|
|
accessToken: "<YOUR_API_KEY_HERE>",
|
|
xPlexClientIdentifier: "gcgzw5rz2xovp84b4vha3a40",
|
|
});
|
|
|
|
async function run() {
|
|
const result = await plexAPI.server.getServerList();
|
|
|
|
// Handle the result
|
|
console.log(result)
|
|
}
|
|
|
|
run();
|
|
```
|
|
|
|
### Standalone function
|
|
|
|
The standalone function version of this method:
|
|
|
|
```typescript
|
|
import { PlexAPICore } from "@lukehagar/plexjs/core.js";
|
|
import { serverGetServerList } from "@lukehagar/plexjs/funcs/serverGetServerList.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 serverGetServerList(plexAPI);
|
|
|
|
if (!res.ok) {
|
|
throw res.error;
|
|
}
|
|
|
|
const { value: result } = res;
|
|
|
|
// Handle the result
|
|
console.log(result)
|
|
}
|
|
|
|
run();
|
|
```
|
|
|
|
### Parameters
|
|
|
|
| Parameter | Type | Required | Description |
|
|
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
|
|
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | 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](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
|
|
|
|
### Response
|
|
|
|
**Promise\<[operations.GetServerListResponse](../../sdk/models/operations/getserverlistresponse.md)\>**
|
|
|
|
### Errors
|
|
|
|
| Error Object | Status Code | Content Type |
|
|
| -------------------------------- | -------------------------------- | -------------------------------- |
|
|
| errors.GetServerListBadRequest | 400 | application/json |
|
|
| errors.GetServerListUnauthorized | 401 | application/json |
|
|
| errors.SDKError | 4xx-5xx | */* |
|