Package: plex-api-client
plexpySDK Installationpipinstallplex-api-clientSDK Example UsageExampleimportplex_apis=plex_api.PlexAPI(access_token="<YOUR_API_KEY_HERE>",)res=s.server.get_server_capabilities()ifres.objectisnotNone:# handle responsepassAvailable Resources and Operationsserverget_server_capabilities- Server Capabilitiesget_server_preferences- Get Server Preferencesget_available_clients- Get Available Clientsget_devices- Get Devicesget_server_identity- Get Server Identityget_my_plex_account- Get MyPlex Accountget_resized_photo- Get a Resized Photoget_server_list- Get Server Listmediamark_played- Mark Media Playedmark_unplayed- Mark Media Unplayedupdate_play_progress- Update Media Play Progressvideoget_timeline- Get the timeline for a media itemstart_universal_transcode- Start Universal Transcodeactivitiesget_server_activities- Get Server Activitiescancel_server_activities- Cancel Server Activitiesbutlerget_butler_tasks- Get Butler tasksstart_all_tasks- Start all Butler tasksstop_all_tasks- Stop all Butler tasksstart_task- Start a single Butler taskstop_task- Stop a single Butler taskhubsget_global_hubs- Get Global Hubsget_library_hubs- Get library specific hubssearchperform_search- Perform a searchperform_voice_search- Perform a voice searchget_search_results- Get Search Resultslibraryget_file_hash- Get Hash Valueget_recently_added- Get Recently Addedget_libraries- Get All Librariesget_library- Get Library Detailsdelete_library- Delete Library Sectionget_library_items- Get Library Itemsrefresh_library- Refresh Librarysearch_library- Search Libraryget_metadata- Get Items Metadataget_metadata_children- Get Items Childrenget_on_deck- Get On Deckloglog_line- Logging a single line message.log_multi_line- Logging a multi-line messageenable_paper_trail- Enabling Papertrailplexget_pin- Get a Pinget_token- Get Access Tokenplaylistscreate_playlist- Create a Playlistget_playlists- Get All Playlistsget_playlist- Retrieve Playlistdelete_playlist- Deletes a Playlistupdate_playlist- Update a Playlistget_playlist_contents- Retrieve Playlist Contentsclear_playlist_contents- Delete Playlist Contentsadd_playlist_contents- Adding to a Playlistupload_playlist- Upload Playlistauthenticationget_transient_token- Get a Transient Token.get_source_connection_information- Get Source Connection Informationstatisticsget_statistics- Get Media Statisticssessionsget_sessions- Get Active Sessionsget_session_history- Get Session Historyget_transcode_sessions- Get Transcode Sessionsstop_transcode_session- Stop a Transcode Sessionupdaterget_update_status- Querying status of updatescheck_for_updates- Checking for updatesapply_updates- Apply UpdatesError HandlingHandling errors in this SDK should largely match your expectations.  All operations return a response object or raise an error.  If Error objects are specified in your OpenAPI Spec, the SDK will raise the appropriate Error type.Error ObjectStatus CodeContent Typeerrors.GetServerCapabilitiesResponseBody401application/jsonerrors.SDKError4x-5xx/Exampleimportplex_apifromplex_api.modelsimporterrorss=plex_api.PlexAPI(access_token="<YOUR_API_KEY_HERE>",)res=Nonetry:res=s.server.get_server_capabilities()excepterrors.GetServerCapabilitiesResponseBodyase:# handle exceptionraise(e)excepterrors.SDKErrorase:# handle exceptionraise(e)ifres.objectisnotNone:# handle responsepassServer SelectionSelect Server by IndexYou can override the default server globally by passing a server index to theserver_idx: intoptional 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:#ServerVariables0{protocol}://{ip}:{port}protocol(default ishttp),ip(default is10.10.10.47),port(default is32400)Exampleimportplex_apis=plex_api.PlexAPI(server_idx=0,access_token="<YOUR_API_KEY_HERE>",)res=s.server.get_server_capabilities()ifres.objectisnotNone:# handle responsepassVariablesSome 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: models.ServerProtocolip: strport: strOverride Server URL Per-ClientThe default server can also be overridden globally by passing a URL to theserver_url: stroptional parameter when initializing the SDK client instance. For example:importplex_apis=plex_api.PlexAPI(server_url="{protocol}://{ip}:{port}",access_token="<YOUR_API_KEY_HERE>",)res=s.server.get_server_capabilities()ifres.objectisnotNone:# handle responsepassOverride Server URL Per-OperationThe server URL can also be overridden on a per-operation basis, provided a server list was specified for the operation. For example:importplex_apis=plex_api.PlexAPI()res=s.plex.get_pin(server_url="https://plex.tv/api/v2",x_plex_client_identifier='<value>',strong=False)ifres.objectisnotNone:# handle responsepassCustom HTTP ClientThe Python SDK makes API calls using therequestsHTTP library.  In order to provide a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration, you can initialize the SDK client with a customrequests.Sessionobject.For example, you could specify a header for every request that this sdk makes as follows:importplex_apiimportrequestshttp_client=requests.Session()http_client.headers.update({'x-custom-header':'someValue'})s=plex_api.PlexAPI(client:http_client)AuthenticationPer-Client Security SchemesThis SDK supports the following security scheme globally:NameTypeSchemeaccess_tokenapiKeyAPI keyTo authenticate with the API theaccess_tokenparameter must be set when initializing the SDK client instance. For example:importplex_apis=plex_api.PlexAPI(access_token="<YOUR_API_KEY_HERE>",)res=s.server.get_server_capabilities()ifres.objectisnotNone:# handle responsepassDevelopmentMaturityThis 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.ContributionsWhile 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 bySpeakeasy