(media)
API Calls interacting with Plex Media Server Media
- getBannerImage - Get Banner Image
- getThumbImage - Get Thumb Image
- markPlayed - Mark Media Played
- markUnplayed - Mark Media Unplayed
- updatePlayProgress - Update Media Play Progress
Gets the banner image of the media item
declare(strict_types=1);
require 'vendor/autoload.php';
use LukeHagar\Plex_API;
use LukeHagar\Plex_API\Models\Operations;
$security = '<YOUR_API_KEY_HERE>';
$sdk = Plex_API\PlexAPI::builder()->setSecurity($security)->build();
$request = new Operations\GetBannerImageRequest(
ratingKey: 9518,
width: 396,
height: 396,
minSize: 1,
upscale: 1,
xPlexToken: 'CV5xoxjTpFKUzBTShsaf',
);
$response = $sdk->media->getBannerImage(
request: $request
);
if ($response->bytes !== null) {
// handle response
}
Parameter | Type | Required | Description |
---|---|---|---|
$request |
Operations\GetBannerImageRequest | ✔️ | The request object to use for the request. |
?Operations\GetBannerImageResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\GetBannerImageBadRequest | 400 | application/json |
Errors\GetBannerImageUnauthorized | 401 | application/json |
Errors\SDKException | 4XX, 5XX | */* |
Gets the thumbnail image of the media item
declare(strict_types=1);
require 'vendor/autoload.php';
use LukeHagar\Plex_API;
use LukeHagar\Plex_API\Models\Operations;
$security = '<YOUR_API_KEY_HERE>';
$sdk = Plex_API\PlexAPI::builder()->setSecurity($security)->build();
$request = new Operations\GetThumbImageRequest(
ratingKey: 9518,
width: 396,
height: 396,
minSize: 1,
upscale: 1,
xPlexToken: 'CV5xoxjTpFKUzBTShsaf',
);
$response = $sdk->media->getThumbImage(
request: $request
);
if ($response->bytes !== null) {
// handle response
}
Parameter | Type | Required | Description |
---|---|---|---|
$request |
Operations\GetThumbImageRequest | ✔️ | The request object to use for the request. |
?Operations\GetThumbImageResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\GetThumbImageBadRequest | 400 | application/json |
Errors\GetThumbImageUnauthorized | 401 | application/json |
Errors\SDKException | 4XX, 5XX | */* |
This will mark the provided media key as Played.
declare(strict_types=1);
require 'vendor/autoload.php';
use LukeHagar\Plex_API;
$security = '<YOUR_API_KEY_HERE>';
$sdk = Plex_API\PlexAPI::builder()->setSecurity($security)->build();
$response = $sdk->media->markPlayed(
key: 59398
);
if ($response->statusCode === 200) {
// handle response
}
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
key |
float | ✔️ | The media key to mark as played | 59398 |
?Operations\MarkPlayedResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\MarkPlayedBadRequest | 400 | application/json |
Errors\MarkPlayedUnauthorized | 401 | application/json |
Errors\SDKException | 4XX, 5XX | */* |
This will mark the provided media key as Unplayed.
declare(strict_types=1);
require 'vendor/autoload.php';
use LukeHagar\Plex_API;
$security = '<YOUR_API_KEY_HERE>';
$sdk = Plex_API\PlexAPI::builder()->setSecurity($security)->build();
$response = $sdk->media->markUnplayed(
key: 59398
);
if ($response->statusCode === 200) {
// handle response
}
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
key |
float | ✔️ | The media key to mark as Unplayed | 59398 |
?Operations\MarkUnplayedResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\MarkUnplayedBadRequest | 400 | application/json |
Errors\MarkUnplayedUnauthorized | 401 | application/json |
Errors\SDKException | 4XX, 5XX | */* |
This API command can be used to update the play progress of a media item.
declare(strict_types=1);
require 'vendor/autoload.php';
use LukeHagar\Plex_API;
$security = '<YOUR_API_KEY_HERE>';
$sdk = Plex_API\PlexAPI::builder()->setSecurity($security)->build();
$response = $sdk->media->updatePlayProgress(
key: '<key>',
time: 90000,
state: 'played'
);
if ($response->statusCode === 200) {
// handle response
}
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
key |
string | ✔️ | the media key | |
time |
float | ✔️ | The time, in milliseconds, used to set the media playback progress. | 90000 |
state |
string | ✔️ | The playback state of the media item. | played |
?Operations\UpdatePlayProgressResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\UpdatePlayProgressBadRequest | 400 | application/json |
Errors\UpdatePlayProgressUnauthorized | 401 | application/json |
Errors\SDKException | 4XX, 5XX | */* |