Files
plexphp/docs/sdks/sessions/README.md

12 KiB
Raw Blame History

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;
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->object !== null) {
        // handle response
    }
} catch (Throwable $e) {
    // handle exception
}

Response

?Operations\GetSessionsResponse

Errors

Error Object Status Code Content Type
Errors\GetSessionsResponseBody 401 application/json
LukeHagar\Plex_API\Models\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\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->object !== 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 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

?Operations\GetSessionHistoryResponse

Errors

Error Object Status Code Content Type
Errors\GetSessionHistoryResponseBody 401 application/json
LukeHagar\Plex_API\Models\Errors.SDKException 4xx-5xx /

getTranscodeSessions

Get Transcode Sessions

Example Usage

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->object !== null) {
        // handle response
    }
} catch (Throwable $e) {
    // handle exception
}

Response

?Operations\GetTranscodeSessionsResponse

Errors

Error Object Status Code Content Type
Errors\GetTranscodeSessionsResponseBody 401 application/json
LukeHagar\Plex_API\Models\Errors.SDKException 4xx-5xx /

stopTranscodeSession

Stop a Transcode Session

Example Usage

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->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

?Operations\StopTranscodeSessionResponse

Errors

Error Object Status Code Content Type
Errors\StopTranscodeSessionResponseBody 401 application/json
LukeHagar\Plex_API\Models\Errors.SDKException 4xx-5xx /