mirror of
https://github.com/LukeHagar/plexcsharp.git
synced 2025-12-06 12:37:46 +00:00
11 KiB
11 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
using PlexAPI;
using PlexAPI.Models.Components;
var sdk = new PlexAPISDK(
accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "Postman");
var res = await sdk.Sessions.GetSessionsAsync();
// handle response
Response
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| PlexAPI.Models.Errors.GetSessionsResponseBody | 401 | application/json |
| PlexAPI.Models.Errors.SDKException | 4xx-5xx | / |
GetSessionHistory
This will Retrieve a listing of all history views.
Example Usage
using PlexAPI;
using PlexAPI.Models.Requests;
using PlexAPI.Models.Components;
var sdk = new PlexAPISDK(
accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "Postman");
var res = await sdk.Sessions.GetSessionHistoryAsync(
sort: "<value>",
accountId: 1,
filter: new Filter() {},
librarySectionID: 12);
// handle response
Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
Sort |
string | ➖ | Sorts the results by the specified field followed by the direction (asc, desc) |
|
AccountId |
long | ➖ | Filter results by those that are related to a specific users id |
1 |
Filter |
Filter | ➖ | Filters content by field and direction/equality (Unknown if viewedAt is the only supported column) |
{ "viewed-at-greater-than": { "value": "viewedAt\u003e" }, "viewed-at-greater-than-or-equal-to": { "value": "viewedAt\u003e=\u003e" }, "viewed-at-less-than": { "value": "viewedAt\u003c" } } |
LibrarySectionID |
long | ➖ | Filters the results based on the id of a valid library section |
12 |
Response
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| PlexAPI.Models.Errors.GetSessionHistoryResponseBody | 401 | application/json |
| PlexAPI.Models.Errors.SDKException | 4xx-5xx | / |
GetTranscodeSessions
Get Transcode Sessions
Example Usage
using PlexAPI;
using PlexAPI.Models.Components;
var sdk = new PlexAPISDK(
accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "Postman");
var res = await sdk.Sessions.GetTranscodeSessionsAsync();
// handle response
Response
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| PlexAPI.Models.Errors.GetTranscodeSessionsResponseBody | 401 | application/json |
| PlexAPI.Models.Errors.SDKException | 4xx-5xx | / |
StopTranscodeSession
Stop a Transcode Session
Example Usage
using PlexAPI;
using PlexAPI.Models.Requests;
using PlexAPI.Models.Components;
var sdk = new PlexAPISDK(
accessToken: "<YOUR_API_KEY_HERE>",
xPlexClientIdentifier: "Postman");
var res = await sdk.Sessions.StopTranscodeSessionAsync(sessionKey: "zz7llzqlx8w9vnrsbnwhbmep");
// handle response
Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
SessionKey |
string | ✔️ | the Key of the transcode session to stop | zz7llzqlx8w9vnrsbnwhbmep |
Response
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| PlexAPI.Models.Errors.StopTranscodeSessionResponseBody | 401 | application/json |
| PlexAPI.Models.Errors.SDKException | 4xx-5xx | / |