# lukehagar/plex-api
## SDK Installation ### Composer To install the SDK first add the below to your `composer.json` file: ```json { "repositories": [ { "type": "github", "url": "https://github.com/LukeHagar/plexphp.git" } ], "require": { "lukehagar/plex-api": "*" } } ``` Then run the following command: ```bash composer update ``` ## SDK Example Usage ### Example ```php declare(strict_types=1); require 'vendor/autoload.php'; use LukeHagar\Plex_API; use LukeHagar\Plex_API\Models\Components; $security = new Components\Security(); $security->accessToken = ''; $sdk = Plex_API\PlexAPI::builder() ->setXPlexClientIdentifier('Postman') ->setSecurity($security)->build(); try { $response = $sdk->server->getServerCapabilities(); if ($response->object !== null) { // handle response } } catch (Throwable $e) { // handle exception } ``` ## Available Resources and Operations ### [Server](docs/sdks/server/README.md) * [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 * [getServerList](docs/sdks/server/README.md#getserverlist) - Get Server List ### [Media](docs/sdks/media/README.md) * [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 ### [Video](docs/sdks/video/README.md) * [getTimeline](docs/sdks/video/README.md#gettimeline) - Get the timeline for a media item * [startUniversalTranscode](docs/sdks/video/README.md#startuniversaltranscode) - Start Universal Transcode ### [Activities](docs/sdks/activities/README.md) * [getServerActivities](docs/sdks/activities/README.md#getserveractivities) - Get Server Activities * [cancelServerActivities](docs/sdks/activities/README.md#cancelserveractivities) - Cancel Server Activities ### [Butler](docs/sdks/butler/README.md) * [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 ### [Plex](docs/sdks/plex/README.md) * [getHomeData](docs/sdks/plex/README.md#gethomedata) - Get Plex Home Data * [getPin](docs/sdks/plex/README.md#getpin) - Get a Pin * [getToken](docs/sdks/plex/README.md#gettoken) - Get Access Token ### [Hubs](docs/sdks/hubs/README.md) * [getGlobalHubs](docs/sdks/hubs/README.md#getglobalhubs) - Get Global Hubs * [getLibraryHubs](docs/sdks/hubs/README.md#getlibraryhubs) - Get library specific hubs ### [Search](docs/sdks/search/README.md) * [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 ### [Library](docs/sdks/library/README.md) * [getFileHash](docs/sdks/library/README.md#getfilehash) - Get Hash Value * [getRecentlyAdded](docs/sdks/library/README.md#getrecentlyadded) - Get Recently Added * [getLibraries](docs/sdks/library/README.md#getlibraries) - Get All Libraries * [getLibrary](docs/sdks/library/README.md#getlibrary) - Get Library Details * [deleteLibrary](docs/sdks/library/README.md#deletelibrary) - Delete Library Section * [getLibraryItems](docs/sdks/library/README.md#getlibraryitems) - Get Library Items * [refreshLibrary](docs/sdks/library/README.md#refreshlibrary) - Refresh Library * [searchLibrary](docs/sdks/library/README.md#searchlibrary) - Search Library * [getMetadata](docs/sdks/library/README.md#getmetadata) - Get Items Metadata * [getMetadataChildren](docs/sdks/library/README.md#getmetadatachildren) - Get Items Children * [getTopWatchedContent](docs/sdks/library/README.md#gettopwatchedcontent) - Get Top Watched Content * [getOnDeck](docs/sdks/library/README.md#getondeck) - Get On Deck ### [Log](docs/sdks/log/README.md) * [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 ### [Playlists](docs/sdks/playlists/README.md) * [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 ### [Authentication](docs/sdks/authentication/README.md) * [getTransientToken](docs/sdks/authentication/README.md#gettransienttoken) - Get a Transient Token. * [getSourceConnectionInformation](docs/sdks/authentication/README.md#getsourceconnectioninformation) - Get Source Connection Information ### [Statistics](docs/sdks/statistics/README.md) * [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 ### [Sessions](docs/sdks/sessions/README.md) * [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 ### [Updater](docs/sdks/updater/README.md) * [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 ### [Watchlist](docs/sdks/watchlist/README.md) * [getWatchlist](docs/sdks/watchlist/README.md#getwatchlist) - Get User Watchlist ## Server Selection ## Server Selection ### Select Server by Index You can override the default server globally by passing a server index to the `server_idx: int` optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the indexes associated with the available servers: | # | Server | Variables | | - | ------ | --------- | | 0 | `{protocol}://{ip}:{port}` | `protocol` (default is `http`), `ip` (default is `10.10.10.47`), `port` (default is `32400`) | #### Variables Some of the server options above contain variables. If you want to set the values of those variables, the following optional parameters are available when initializing the SDK client instance: * `protocol: ServerProtocol` * `ip: string` * `port: string` ### Override Server URL Per-Client The default server can also be overridden globally by passing a URL to the `server_url: str` optional parameter when initializing the SDK client instance. For example: ### 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: ```php declare(strict_types=1); require 'vendor/autoload.php'; use LukeHagar\Plex_API; $sdk = Plex_API\PlexAPI::builder() ->setXPlexClientIdentifier('Postman') ->build(); try { $response = $sdk->plex->getPin("https://plex.tv/api/v2", 'Postman', false, 'Postman'); if ($response->object !== null) { // handle response } } catch (Throwable $e) { // handle exception } ``` # Development ## 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 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)