mirror of
https://github.com/LukeHagar/plexphp.git
synced 2025-12-06 04:20:51 +00:00
9.9 KiB
9.9 KiB
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
<?php
declare(strict_types=1);
require 'vendor/autoload.php';
use \LukeHagar\Plex_API;
use \LukeHagar\Plex_API\Models\Components;
$security = new Components\Security();
$security->accessToken = '<YOUR_API_KEY_HERE>';
$sdk = Plex_API\PlexAPI::builder()
->setXPlexClientIdentifier('Postman')
->setSecurity($security)->build();
try {
$response = $sdk->sessions->getSessions();
if ($response->twoHundredApplicationJsonObject !== null) {
// handle response
}
} catch (Throwable $e) {
// handle exception
}
Response
?\LukeHagar\Plex_API\Models\Operations\GetSessionsResponse
getSessionHistory
This will Retrieve a listing of all history views.
Example Usage
<?php
declare(strict_types=1);
require 'vendor/autoload.php';
use \LukeHagar\Plex_API;
use \LukeHagar\Plex_API\Models\Components;
use \LukeHagar\Plex_API\Models\Operations;
$security = new Components\Security();
$security->accessToken = '<YOUR_API_KEY_HERE>';
$sdk = Plex_API\PlexAPI::builder()
->setXPlexClientIdentifier('Postman')
->setSecurity($security)->build();
try {
$filter = new Operations\Filter();
$response = $sdk->sessions->getSessionHistory('<value>', 1, $filter, 12);
if ($response->twoHundredApplicationJsonObject !== null) {
// handle response
}
} catch (Throwable $e) {
// handle exception
}
Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
sort |
string | ➖ | Sorts the results by the specified field followed by the direction (asc, desc) |
|
accountId |
int | ➖ | Filter results by those that are related to a specific users id |
1 |
filter |
\LukeHagar\Plex_API\Models\Operations\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 |
int | ➖ | Filters the results based on the id of a valid library section |
12 |
Response
?\LukeHagar\Plex_API\Models\Operations\GetSessionHistoryResponse
getTranscodeSessions
Get Transcode Sessions
Example Usage
<?php
declare(strict_types=1);
require 'vendor/autoload.php';
use \LukeHagar\Plex_API;
use \LukeHagar\Plex_API\Models\Components;
$security = new Components\Security();
$security->accessToken = '<YOUR_API_KEY_HERE>';
$sdk = Plex_API\PlexAPI::builder()
->setXPlexClientIdentifier('Postman')
->setSecurity($security)->build();
try {
$response = $sdk->sessions->getTranscodeSessions();
if ($response->twoHundredApplicationJsonObject !== null) {
// handle response
}
} catch (Throwable $e) {
// handle exception
}
Response
?\LukeHagar\Plex_API\Models\Operations\GetTranscodeSessionsResponse
stopTranscodeSession
Stop a Transcode Session
Example Usage
<?php
declare(strict_types=1);
require 'vendor/autoload.php';
use \LukeHagar\Plex_API;
use \LukeHagar\Plex_API\Models\Components;
use \LukeHagar\Plex_API\Models\Operations;
$security = new Components\Security();
$security->accessToken = '<YOUR_API_KEY_HERE>';
$sdk = Plex_API\PlexAPI::builder()
->setXPlexClientIdentifier('Postman')
->setSecurity($security)->build();
try {
$response = $sdk->sessions->stopTranscodeSession('zz7llzqlx8w9vnrsbnwhbmep');
if ($response->statusCode === 200) {
// handle response
}
} catch (Throwable $e) {
// handle exception
}
Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
sessionKey |
string | ✔️ | the Key of the transcode session to stop | zz7llzqlx8w9vnrsbnwhbmep |
Response
?\LukeHagar\Plex_API\Models\Operations\StopTranscodeSessionResponse