PHPackages                             lukehagar/plex-api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. lukehagar/plex-api

ActiveLibrary[API Development](/categories/api)

lukehagar/plex-api
==================

v0.14.13(8mo ago)62642[1 issues](https://github.com/LukeHagar/plexphp/issues)MITPHPPHP &gt;=8.2CI failing

Since Sep 16Pushed 7mo ago2 watchersCompare

[ Source](https://github.com/LukeHagar/plexphp)[ Packagist](https://packagist.org/packages/lukehagar/plex-api)[ RSS](/packages/lukehagar-plex-api/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (10)Versions (38)Used By (0)

lukehagar/plex-api
==================

[](#lukehagarplex-api)

 [![](https://camo.githubusercontent.com/096b86187dea2c62026c9750456a53a3e7c20fdd95fa1b55f5cc9a67ebc2078d/68747470733a2f2f637573746f6d2d69636f6e2d6261646765732e64656d6f6c61622e636f6d2f62616467652f2d4275696c742532304279253230537065616b656173792d3231323031353f7374796c653d666f722d7468652d6261646765266c6f676f436f6c6f723d464245333331266c6f676f3d737065616b65617379266c6162656c436f6c6f723d353435343534)](https://speakeasyapi.dev/) [ ![](https://camo.githubusercontent.com/08cef40a9105b6526ca22088bc514fbfdbc9aac1ddbf8d4e6c750e3a88a44dca/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d626c75652e737667) ](https://opensource.org/licenses/MIT)

Summary
-------

[](#summary)

Plex-API: An Open API Spec for interacting with Plex.tv and Plex Media Server

Plex Media Server OpenAPI Specification
=======================================

[](#plex-media-server-openapi-specification)

An Open Source OpenAPI Specification for Plex Media Server

Automation and SDKs provided by [Speakeasy](https://speakeasyapi.dev/)

Documentation
-------------

[](#documentation)

[API Documentation](https://plexapi.dev)

SDKs
----

[](#sdks)

The following SDKs are generated from the OpenAPI Specification. They are automatically generated and may not be fully tested. If you find any issues, please open an issue on the [main specification Repository](https://github.com/LukeHagar/plex-api-spec).

LanguageRepositoryReleasesOtherPython[GitHub](https://github.com/LukeHagar/plexpy)[PyPI](https://pypi.org/project/plex-api-client/)-JavaScript/TypeScript[GitHub](https://github.com/LukeHagar/plexjs)[NPM](https://www.npmjs.com/package/@lukehagar/plexjs) \\ [JSR](https://jsr.io/@lukehagar/plexjs)-Go[GitHub](https://github.com/LukeHagar/plexgo)[Releases](https://github.com/LukeHagar/plexgo/releases)[GoDoc](https://pkg.go.dev/github.com/LukeHagar/plexgo)Ruby[GitHub](https://github.com/LukeHagar/plexruby)[Releases](https://github.com/LukeHagar/plexruby/releases)-Swift[GitHub](https://github.com/LukeHagar/plexswift)[Releases](https://github.com/LukeHagar/plexswift/releases)-PHP[GitHub](https://github.com/LukeHagar/plexphp)[Releases](https://github.com/LukeHagar/plexphp/releases)-Java[GitHub](https://github.com/LukeHagar/plexjava)[Releases](https://github.com/LukeHagar/plexjava/releases)-C#[GitHub](https://github.com/LukeHagar/plexcsharp)[Releases](https://github.com/LukeHagar/plexcsharp/releases)-Table of Contents
-----------------

[](#table-of-contents)

- [lukehagar/plex-api](#lukehagarplex-api)
- [Plex Media Server OpenAPI Specification](#plex-media-server-openapi-specification)
    - [Documentation](#documentation)
    - [SDKs](#sdks)
    - [SDK Installation](#sdk-installation)
    - [SDK Example Usage](#sdk-example-usage)
    - [Authentication](#authentication)
    - [Available Resources and Operations](#available-resources-and-operations)
    - [Error Handling](#error-handling)
    - [Server Selection](#server-selection)
- [Development](#development)
    - [Maturity](#maturity)
    - [Contributions](#contributions)

SDK Installation
----------------

[](#sdk-installation)

The SDK relies on [Composer](https://getcomposer.org/) to manage its dependencies.

To install the SDK and add it as a dependency to an existing `composer.json` file:

```
composer require "lukehagar/plex-api"
```

SDK Example Usage
-----------------

[](#sdk-example-usage)

### Example

[](#example)

```
declare(strict_types=1);

require 'vendor/autoload.php';

use LukeHagar\Plex_API;

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

$response = $sdk->server->getServerCapabilities(

);

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

Authentication
--------------

[](#authentication)

### Per-Client Security Schemes

[](#per-client-security-schemes)

This SDK supports the following security scheme globally:

NameTypeScheme`accessToken`apiKeyAPI keyTo authenticate with the API the `accessToken` parameter must be set when initializing the SDK. For example:

```
declare(strict_types=1);

require 'vendor/autoload.php';

use LukeHagar\Plex_API;

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

$response = $sdk->server->getServerCapabilities(

);

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

Available Resources and Operations
----------------------------------

[](#available-resources-and-operations)

Available methods### [activities](docs/sdks/activities/README.md)

[](#activities)

- [getServerActivities](docs/sdks/activities/README.md#getserveractivities) - Get Server Activities
- [cancelServerActivities](docs/sdks/activities/README.md#cancelserveractivities) - Cancel Server Activities

### [authentication](docs/sdks/authentication/README.md)

[](#authentication-1)

- [getTransientToken](docs/sdks/authentication/README.md#gettransienttoken) - Get a Transient Token
- [getSourceConnectionInformation](docs/sdks/authentication/README.md#getsourceconnectioninformation) - Get Source Connection Information
- [getTokenDetails](docs/sdks/authentication/README.md#gettokendetails) - Get Token Details
- [postUsersSignInData](docs/sdks/authentication/README.md#postuserssignindata) - Get User Sign In Data

### [butler](docs/sdks/butler/README.md)

[](#butler)

- [getButlerTasks](docs/sdks/butler/README.md#getbutlertasks) - Get Butler tasks
- [startAllTasks](docs/sdks/butler/README.md#startalltasks) - Start all Butler tasks
- [stopAllTasks](docs/sdks/butler/README.md#stopalltasks) - Stop all Butler tasks
- [startTask](docs/sdks/butler/README.md#starttask) - Start a single Butler task
- [stopTask](docs/sdks/butler/README.md#stoptask) - Stop a single Butler task

### [hubs](docs/sdks/hubs/README.md)

[](#hubs)

- [getGlobalHubs](docs/sdks/hubs/README.md#getglobalhubs) - Get Global Hubs
- [getRecentlyAdded](docs/sdks/hubs/README.md#getrecentlyadded) - Get Recently Added
- [getLibraryHubs](docs/sdks/hubs/README.md#getlibraryhubs) - Get library specific hubs

### [library](docs/sdks/library/README.md)

[](#library)

- [getFileHash](docs/sdks/library/README.md#getfilehash) - Get Hash Value
- [getRecentlyAddedLibrary](docs/sdks/library/README.md#getrecentlyaddedlibrary) - Get Recently Added
- [getAllLibraries](docs/sdks/library/README.md#getalllibraries) - Get All Libraries
- [getLibraryDetails](docs/sdks/library/README.md#getlibrarydetails) - Get Library Details
- [deleteLibrary](docs/sdks/library/README.md#deletelibrary) - Delete Library Section
- [getLibraryItems](docs/sdks/library/README.md#getlibraryitems) - Get Library Items
- [getLibrarySectionsAll](docs/sdks/library/README.md#getlibrarysectionsall) - Get Library section media by tag ALL
- [getRefreshLibraryMetadata](docs/sdks/library/README.md#getrefreshlibrarymetadata) - Refresh Metadata Of The Library
- [getSearchLibrary](docs/sdks/library/README.md#getsearchlibrary) - Search Library
- [getGenresLibrary](docs/sdks/library/README.md#getgenreslibrary) - Get Genres of library media
- [getCountriesLibrary](docs/sdks/library/README.md#getcountrieslibrary) - Get Countries of library media
- [getActorsLibrary](docs/sdks/library/README.md#getactorslibrary) - Get Actors of library media
- [getSearchAllLibraries](docs/sdks/library/README.md#getsearchalllibraries) - Search All Libraries
- [getMediaMetaData](docs/sdks/library/README.md#getmediametadata) - Get Media Metadata
- [getMediaArts](docs/sdks/library/README.md#getmediaarts) - Get Media Background Artwork
- [postMediaArts](docs/sdks/library/README.md#postmediaarts) - Upload Media Background Artwork
- [getMediaPosters](docs/sdks/library/README.md#getmediaposters) - Get Media Posters
- [postMediaPoster](docs/sdks/library/README.md#postmediaposter) - Upload Media Poster
- [getMetadataChildren](docs/sdks/library/README.md#getmetadatachildren) - Get Items Children
- [getTopWatchedContent](docs/sdks/library/README.md#gettopwatchedcontent) - Get Top Watched Content

### [log](docs/sdks/log/README.md)

[](#log)

- [logLine](docs/sdks/log/README.md#logline) - Logging a single line message.
- [logMultiLine](docs/sdks/log/README.md#logmultiline) - Logging a multi-line message
- [enablePaperTrail](docs/sdks/log/README.md#enablepapertrail) - Enabling Papertrail

### [media](docs/sdks/media/README.md)

[](#media)

- [markPlayed](docs/sdks/media/README.md#markplayed) - Mark Media Played
- [markUnplayed](docs/sdks/media/README.md#markunplayed) - Mark Media Unplayed
- [updatePlayProgress](docs/sdks/media/README.md#updateplayprogress) - Update Media Play Progress
- [getBannerImage](docs/sdks/media/README.md#getbannerimage) - Get Banner Image
- [getThumbImage](docs/sdks/media/README.md#getthumbimage) - Get Thumb Image

### [playlists](docs/sdks/playlists/README.md)

[](#playlists)

- [createPlaylist](docs/sdks/playlists/README.md#createplaylist) - Create a Playlist
- [getPlaylists](docs/sdks/playlists/README.md#getplaylists) - Get All Playlists
- [getPlaylist](docs/sdks/playlists/README.md#getplaylist) - Retrieve Playlist
- [deletePlaylist](docs/sdks/playlists/README.md#deleteplaylist) - Deletes a Playlist
- [updatePlaylist](docs/sdks/playlists/README.md#updateplaylist) - Update a Playlist
- [getPlaylistContents](docs/sdks/playlists/README.md#getplaylistcontents) - Retrieve Playlist Contents
- [clearPlaylistContents](docs/sdks/playlists/README.md#clearplaylistcontents) - Delete Playlist Contents
- [addPlaylistContents](docs/sdks/playlists/README.md#addplaylistcontents) - Adding to a Playlist
- [uploadPlaylist](docs/sdks/playlists/README.md#uploadplaylist) - Upload Playlist

### [plex](docs/sdks/plex/README.md)

[](#plex)

- [getCompanionsData](docs/sdks/plex/README.md#getcompanionsdata) - Get Companions Data
- [getUserFriends](docs/sdks/plex/README.md#getuserfriends) - Get list of friends of the user logged in
- [getGeoData](docs/sdks/plex/README.md#getgeodata) - Get Geo Data
- [getHomeData](docs/sdks/plex/README.md#gethomedata) - Get Plex Home Data
- [getServerResources](docs/sdks/plex/README.md#getserverresources) - Get Server Resources
- [getPin](docs/sdks/plex/README.md#getpin) - Get a Pin
- [getTokenByPinId](docs/sdks/plex/README.md#gettokenbypinid) - Get Access Token by PinId

### [search](docs/sdks/search/README.md)

[](#search)

- [performSearch](docs/sdks/search/README.md#performsearch) - Perform a search
- [performVoiceSearch](docs/sdks/search/README.md#performvoicesearch) - Perform a voice search
- [getSearchResults](docs/sdks/search/README.md#getsearchresults) - Get Search Results

### [server](docs/sdks/server/README.md)

[](#server)

- [getServerCapabilities](docs/sdks/server/README.md#getservercapabilities) - Get Server Capabilities
- [getServerPreferences](docs/sdks/server/README.md#getserverpreferences) - Get Server Preferences
- [getAvailableClients](docs/sdks/server/README.md#getavailableclients) - Get Available Clients
- [getDevices](docs/sdks/server/README.md#getdevices) - Get Devices
- [getServerIdentity](docs/sdks/server/README.md#getserveridentity) - Get Server Identity
- [getMyPlexAccount](docs/sdks/server/README.md#getmyplexaccount) - Get MyPlex Account
- [getResizedPhoto](docs/sdks/server/README.md#getresizedphoto) - Get a Resized Photo
- [getMediaProviders](docs/sdks/server/README.md#getmediaproviders) - Get Media Providers
- [getServerList](docs/sdks/server/README.md#getserverlist) - Get Server List

### [sessions](docs/sdks/sessions/README.md)

[](#sessions)

- [getSessions](docs/sdks/sessions/README.md#getsessions) - Get Active Sessions
- [getSessionHistory](docs/sdks/sessions/README.md#getsessionhistory) - Get Session History
- [getTranscodeSessions](docs/sdks/sessions/README.md#gettranscodesessions) - Get Transcode Sessions
- [stopTranscodeSession](docs/sdks/sessions/README.md#stoptranscodesession) - Stop a Transcode Session

### [statistics](docs/sdks/statistics/README.md)

[](#statistics)

- [getStatistics](docs/sdks/statistics/README.md#getstatistics) - Get Media Statistics
- [getResourcesStatistics](docs/sdks/statistics/README.md#getresourcesstatistics) - Get Resources Statistics
- [getBandwidthStatistics](docs/sdks/statistics/README.md#getbandwidthstatistics) - Get Bandwidth Statistics

### [updater](docs/sdks/updater/README.md)

[](#updater)

- [getUpdateStatus](docs/sdks/updater/README.md#getupdatestatus) - Querying status of updates
- [checkForUpdates](docs/sdks/updater/README.md#checkforupdates) - Checking for updates
- [applyUpdates](docs/sdks/updater/README.md#applyupdates) - Apply Updates

### [users](docs/sdks/users/README.md)

[](#users)

- [getUsers](docs/sdks/users/README.md#getusers) - Get list of all connected users

### [video](docs/sdks/video/README.md)

[](#video)

- [getTimeline](docs/sdks/video/README.md#gettimeline) - Get the timeline for a media item
- [startUniversalTranscode](docs/sdks/video/README.md#startuniversaltranscode) - Start Universal Transcode

### [watchlist](docs/sdks/watchlist/README.md)

[](#watchlist)

- [getWatchList](docs/sdks/watchlist/README.md#getwatchlist) - Get User Watchlist

Error Handling
--------------

[](#error-handling)

Handling errors in this SDK should largely match your expectations. All operations return a response object or throw an exception.

By default an API error will raise a `Errors\SDKException` exception, which has the following properties:

PropertyTypeDescription`$message`*string*The error message`$statusCode`*int*The HTTP status code`$rawResponse`*?\\Psr\\Http\\Message\\ResponseInterface*The raw HTTP response`$body`*string*The response contentWhen custom error responses are specified for an operation, the SDK may also throw their associated exception. You can refer to respective *Errors* tables in SDK docs for more details on possible exception types for each operation. For example, the `getServerCapabilities` method throws the following exceptions:

Error TypeStatus CodeContent TypeErrors\\GetServerCapabilitiesBadRequest400application/jsonErrors\\GetServerCapabilitiesUnauthorized401application/jsonErrors\\SDKException4XX, 5XX\*/\*### Example

[](#example-1)

```
declare(strict_types=1);

require 'vendor/autoload.php';

use LukeHagar\Plex_API;
use LukeHagar\Plex_API\Models\Errors;

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

try {
    $response = $sdk->server->getServerCapabilities(

    );

    if ($response->object !== null) {
        // handle response
    }
} catch (Errors\GetServerCapabilitiesBadRequestThrowable $e) {
    // handle $e->$container data
    throw $e;
} catch (Errors\GetServerCapabilitiesUnauthorizedThrowable $e) {
    // handle $e->$container data
    throw $e;
} catch (Errors\SDKException $e) {
    // handle default exception
    throw $e;
}
```

Server Selection
----------------

[](#server-selection)

### Server Variables

[](#server-variables)

The default server `{protocol}://{ip}:{port}` contains variables and is set to `https://10.10.10.47:32400` by default. To override default values, the following builder methods are available when initializing the SDK client instance:

VariableBuilderMethodSupported ValuesDefaultDescription`protocol``setProtocol(Plex_API\ServerProtocol protocol)`- `"http"`
- `"https"``"https"`The protocol to use for the server connection`ip``setIp(string ip)`string`"10.10.10.47"`The IP address or hostname of your Plex Server`port``setPort(string port)`string`"32400"`The port of your Plex Server#### Example

[](#example-2)

```
declare(strict_types=1);

require 'vendor/autoload.php';

use LukeHagar\Plex_API;

$sdk = Plex_API\PlexAPI::builder()
    ->setProtocol('https')
    ->setIp('4982:bc2a:b4f8:efb5:2394:5bc3:ab4f:0e6d')
    ->setPort('44765')
    ->setSecurity(
        ''
    )
    ->build();

$response = $sdk->server->getServerCapabilities(

);

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

### Override Server URL Per-Client

[](#override-server-url-per-client)

The default server can be overridden globally using the `setServerUrl(string $serverUrl)` builder method when initializing the SDK client instance. For example:

```
declare(strict_types=1);

require 'vendor/autoload.php';

use LukeHagar\Plex_API;

$sdk = Plex_API\PlexAPI::builder()
    ->setServerURL('https://10.10.10.47:32400')
    ->setSecurity(
        ''
    )
    ->build();

$response = $sdk->server->getServerCapabilities(

);

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

### Override Server URL Per-Operation

[](#override-server-url-per-operation)

The server URL can also be overridden on a per-operation basis, provided a server list was specified for the operation. For example:

```
declare(strict_types=1);

require 'vendor/autoload.php';

use LukeHagar\Plex_API;

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

$response = $sdk->plex->getCompanionsData(
    'https://plex.tv/api/v2'
);

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

Development
===========

[](#development)

Maturity
--------

[](#maturity)

This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.

Contributions
-------------

[](#contributions)

While we value open-source contributions to this SDK, this library is generated programmatically. Feel free to open a PR or a Github issue as a proof of concept and we'll do our best to include it in a future release!

### SDK Created by [Speakeasy](https://docs.speakeasyapi.dev/docs/using-speakeasy/client-sdks)

[](#sdk-created-by-speakeasy)

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance59

Moderate activity, may be stable

Popularity20

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 91.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~10 days

Recently: every ~26 days

Total

35

Last Release

245d ago

PHP version history (3 changes)v0.8.0PHP ^8.1

v0.11.0PHP ^8.2

v0.14.11PHP &gt;=8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/3a1181476a2b39abb300e4c9795d93e88b970d24aa5dbb75eb8135654bca8156?d=identicon)[LukeHagar](/maintainers/LukeHagar)

---

Top Contributors

[![speakeasybot](https://avatars.githubusercontent.com/u/108416695?v=4)](https://github.com/speakeasybot "speakeasybot (130 commits)")[![LukasParke](https://avatars.githubusercontent.com/u/5702154?v=4)](https://github.com/LukasParke "LukasParke (12 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/lukehagar-plex-api/health.svg)

```
[![Health](https://phpackages.com/badges/lukehagar-plex-api/health.svg)](https://phpackages.com/packages/lukehagar-plex-api)
```

###  Alternatives

[clerkinc/backend-php

2755.0k](/packages/clerkinc-backend-php)[polar-sh/sdk

4014.5k4](/packages/polar-sh-sdk)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[dnsimple/dnsimple

The DNSimple API client for PHP.

11190.9k1](/packages/dnsimple-dnsimple)[hardcastle/xrpl_php

PHP SDK / Client for the XRP Ledger

129.7k5](/packages/hardcastle-xrpl-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
