Skip to main content
GET
/
status
/
sessions
/
history
/
all
PlexPHP
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
}
{
  "MediaContainer": {
    "identifier": "<string>",
    "offset": 123,
    "size": 123,
    "totalSize": 123,
    "Metadata": [
      {
        "accountID": 123,
        "deviceID": 123,
        "historyKey": "<string>",
        "key": "<string>",
        "librarySectionID": "<string>",
        "originallyAvailableAt": "<string>",
        "ratingKey": "<string>",
        "thumb": "<string>",
        "title": "<string>",
        "type": "<string>",
        "viewedAt": 123
      }
    ]
  }
}

Authorizations

X-Plex-Token
string
header
required

Headers

accepts
enum<string>
default:application/xml
Available options:
application/json,
application/xml
X-Plex-Client-Identifier
string
required
Example:
X-Plex-Product
string
Example:
X-Plex-Version
string
Example:
X-Plex-Platform
string
Example:
X-Plex-Platform-Version
string
Example:
X-Plex-Device
string
Example:
X-Plex-Model
string
Example:
X-Plex-Device-Vendor
string
Example:
X-Plex-Device-Name
string
Example:
X-Plex-Marketplace
string
Example:

Query Parameters

accountID
integer
viewedAt
integer
librarySectionID
integer
metadataItemID
integer
sort
string[]

Response

200 - application/json
MediaContainer
object