mirror of
https://github.com/LukeHagar/plexjs.git
synced 2025-12-06 04:20:46 +00:00
17 KiB
17 KiB
Sessions
(sessions)
Overview
API Calls that perform search operations with Plex Media Server Sessions
Available Operations
- getSessions - Get Active Sessions
- getSessionHistory - Get Session History
- getTranscodeSessions - Get Transcode Sessions
- stopTranscodeSession - Stop a Transcode Session
getSessions
This will retrieve the "Now Playing" Information of the PMS.
Example Usage
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
const result = await sdk.sessions.getSessions();
// 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<operations.GetSessionsResponse>
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| errors.GetSessionsResponseBody | 401 | application/json |
| errors.SDKError | 4xx-5xx | / |
getSessionHistory
This will Retrieve a listing of all history views.
Example Usage
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
const result = await sdk.sessions.getSessionHistory();
// 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<operations.GetSessionHistoryResponse>
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| errors.GetSessionHistoryResponseBody | 401 | application/json |
| errors.SDKError | 4xx-5xx | / |
getTranscodeSessions
Get Transcode Sessions
Example Usage
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
const result = await sdk.sessions.getTranscodeSessions();
// 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<operations.GetTranscodeSessionsResponse>
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| errors.GetTranscodeSessionsResponseBody | 401 | application/json |
| errors.SDKError | 4xx-5xx | / |
stopTranscodeSession
Stop a Transcode Session
Example Usage
import { PlexAPI } from "@lukehagar/plexjs";
async function run() {
const sdk = new PlexAPI({
accessToken: "<YOUR_API_KEY_HERE>",
});
const sessionKey = "zz7llzqlx8w9vnrsbnwhbmep";
const result = await sdk.sessions.stopTranscodeSession(sessionKey);
// Handle the result
console.log(result)
}
run();
Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
sessionKey |
string | ✔️ | the Key of the transcode session to stop | [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. |
Response
Promise<operations.StopTranscodeSessionResponse>
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| errors.StopTranscodeSessionResponseBody | 401 | application/json |
| errors.SDKError | 4xx-5xx | / |