mirror of
https://github.com/LukeHagar/plexjs.git
synced 2025-12-06 04:20:46 +00:00
12 KiB
12 KiB
Plex
(plex)
Overview
API Calls that perform operations directly against https://Plex.tv
Available Operations
getPin
Retrieve a Pin from Plex.tv for authentication flows
Example Usage
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI();
const xPlexClientIdentifier = "<value>";
const strong = false;
const result = await sdk.plex.getPin(xPlexClientIdentifier, strong);
// Handle the result
console.log(result)
}
run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
xPlexClientIdentifier |
string | ✔️ | The unique identifier for the client application This is used to track the client application and its usage (UUID, serial number, or other number unique per device) |
strong |
boolean | ➖ | Determines the kind of code returned by the API call Strong codes are used for Pin authentication flows Non-Strong codes are used for Plex.tv/link |
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.serverURL |
string | ➖ | An optional server URL to use. |
Response
Promise<operations.GetPinResponse>
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| errors.GetPinResponseBody | 400 | application/json |
| errors.SDKError | 4xx-5xx | / |
getToken
Retrieve an Access Token from Plex.tv after the Pin has already been authenticated
Example Usage
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI();
const pinID = "<value>";
const xPlexClientIdentifier = "<value>";
const result = await sdk.plex.getToken(pinID, xPlexClientIdentifier);
// Handle the result
console.log(result)
}
run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
pinID |
string | ✔️ | The PinID to retrieve an access token for |
xPlexClientIdentifier |
string | ✔️ | The unique identifier for the client application This is used to track the client application and its usage (UUID, serial number, or other number unique per device) |
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.serverURL |
string | ➖ | An optional server URL to use. |
Response
Promise<operations.GetTokenResponse>
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| errors.GetTokenResponseBody | 400 | application/json |
| errors.SDKError | 4xx-5xx | / |