Files
plexphp/docs/sdks/sessions

Sessions

(sessions)

Overview

API Calls that perform search operations with Plex Media Server Sessions

Available Operations

getSessions

This will retrieve the "Now Playing" Information of the PMS.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use LukeHagar\Plex_API;

$sdk = Plex_API\PlexAPI::builder()
    ->setSecurity(
        '<YOUR_API_KEY_HERE>'
    )
    ->build();



$response = $sdk->sessions->getSessions(

);

if ($response->object !== null) {
    // handle response
}

Response

?Operations\GetSessionsResponse

Errors

Error Type Status Code Content Type
Errors\GetSessionsBadRequest 400 application/json
Errors\GetSessionsUnauthorized 401 application/json
Errors\SDKException 4XX, 5XX */*

getSessionHistory

This will Retrieve a listing of all history views.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use LukeHagar\Plex_API;
use LukeHagar\Plex_API\Models\Operations;

$sdk = Plex_API\PlexAPI::builder()
    ->setSecurity(
        '<YOUR_API_KEY_HERE>'
    )
    ->build();

$filter = new Operations\QueryParamFilter();

$response = $sdk->sessions->getSessionHistory(
    sort: 'viewedAt:desc',
    accountId: 1,
    filter: $filter,
    librarySectionID: 12

);

if ($response->object !== null) {
    // handle response
}

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 ?Operations\QueryParamFilter 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

?Operations\GetSessionHistoryResponse

Errors

Error Type Status Code Content Type
Errors\GetSessionHistoryBadRequest 400 application/json
Errors\GetSessionHistoryUnauthorized 401 application/json
Errors\SDKException 4XX, 5XX */*

getTranscodeSessions

Get Transcode Sessions

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use LukeHagar\Plex_API;

$sdk = Plex_API\PlexAPI::builder()
    ->setSecurity(
        '<YOUR_API_KEY_HERE>'
    )
    ->build();



$response = $sdk->sessions->getTranscodeSessions(

);

if ($response->object !== null) {
    // handle response
}

Response

?Operations\GetTranscodeSessionsResponse

Errors

Error Type Status Code Content Type
Errors\GetTranscodeSessionsBadRequest 400 application/json
Errors\GetTranscodeSessionsUnauthorized 401 application/json
Errors\SDKException 4XX, 5XX */*

stopTranscodeSession

Stop a Transcode Session

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use LukeHagar\Plex_API;

$sdk = Plex_API\PlexAPI::builder()
    ->setSecurity(
        '<YOUR_API_KEY_HERE>'
    )
    ->build();



$response = $sdk->sessions->stopTranscodeSession(
    sessionKey: 'zz7llzqlx8w9vnrsbnwhbmep'
);

if ($response->statusCode === 200) {
    // handle response
}

Parameters

Parameter Type Required Description Example
sessionKey string ✔️ the Key of the transcode session to stop zz7llzqlx8w9vnrsbnwhbmep

Response

?Operations\StopTranscodeSessionResponse

Errors

Error Type Status Code Content Type
Errors\StopTranscodeSessionBadRequest 400 application/json
Errors\StopTranscodeSessionUnauthorized 401 application/json
Errors\SDKException 4XX, 5XX */*