mirror of
https://github.com/LukeHagar/plexjs.git
synced 2025-12-07 04:20:49 +00:00
Plex
(plex)
Overview
API Calls that perform operations directly against https://Plex.tv
Available Operations
- getHomeData - Get Plex Home Data
- getPin - Get a Pin
- getToken - Get Access Token
getHomeData
Retrieves the home data for the authenticated user, including details like home ID, name, guest access information, and subscription status.
Example Usage
import { PlexAPI } from "@lukehagar/plexjs";
const plexAPI = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "Postman",
});
async function run() {
const result = await plexAPI.plex.getHomeData();
// Handle the result
console.log(result)
}
run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
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. |
Response
Promise<models.GetHomeDataResponse>
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| models.GetHomeDataPlexResponseBody | 401 | application/json |
| models.SDKError | 4xx-5xx | / |
getPin
Retrieve a Pin from Plex.tv for authentication flows
Example Usage
import { PlexAPI } from "@lukehagar/plexjs";
const plexAPI = new PlexAPI({
xPlexClientIdentifier: "Postman",
});
async function run() {
const result = await plexAPI.plex.getPin("Postman", false, "Postman");
// Handle the result
console.log(result)
}
run();
Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
xPlexProduct |
string | ✔️ | Product name of the application shown in the list of devices |
[object Object] |
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 |
|
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) |
[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.serverURL |
string | ➖ | An optional server URL to use. | http://localhost:8080 |
Response
Promise<models.GetPinResponse>
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| models.GetPinPlexResponseBody | 400 | application/json |
| models.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";
const plexAPI = new PlexAPI({
xPlexClientIdentifier: "Postman",
});
async function run() {
const result = await plexAPI.plex.getToken("<value>", "Postman");
// Handle the result
console.log(result)
}
run();
Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
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) |
[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.serverURL |
string | ➖ | An optional server URL to use. | http://localhost:8080 |
Response
Promise<models.GetTokenResponse>
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| models.GetTokenPlexResponseBody | 400 | application/json |
| models.SDKError | 4xx-5xx | / |