Files
plexcsharp/NUGET.md

42 KiB

LukeHagar.PlexAPI.SDK

SDK Example Usage

Example

using LukeHagar.PlexAPI.SDK;
using LukeHagar.PlexAPI.SDK.Models.Components;

var sdk = new PlexAPI(accessToken: "<YOUR_API_KEY_HERE>");

var res = await sdk.Server.GetServerCapabilitiesAsync();

// handle response

Authentication

Per-Client Security Schemes

This SDK supports the following security scheme globally:

Name Type Scheme
AccessToken apiKey API key

To authenticate with the API the AccessToken parameter must be set when initializing the SDK client instance. For example:

using LukeHagar.PlexAPI.SDK;
using LukeHagar.PlexAPI.SDK.Models.Components;

var sdk = new PlexAPI(accessToken: "<YOUR_API_KEY_HERE>");

var res = await sdk.Server.GetServerCapabilitiesAsync();

// handle response

Error Handling

PlexAPIError is the base exception class for all HTTP error responses. It has the following properties:

Property Type Description
Message string Error message
StatusCode int HTTP status code
Headers HttpResponseHeaders HTTP headers
ContentType string? HTTP content type
RawResponse HttpResponseMessage HTTP response object
Body string HTTP response body

Some exceptions in this SDK include an additional Payload field, which will contain deserialized custom error data when present. Possible exceptions are listed in the Error Classes section.

Example

using LukeHagar.PlexAPI.SDK;
using LukeHagar.PlexAPI.SDK.Models.Components;
using LukeHagar.PlexAPI.SDK.Models.Errors;
using System.Collections.Generic;

var sdk = new PlexAPI(accessToken: "<YOUR_API_KEY_HERE>");

try
{
    var res = await sdk.Server.GetServerCapabilitiesAsync();

    // handle response
}
catch (PlexAPIError ex)  // all SDK exceptions inherit from PlexAPIError
{
    // ex.ToString() provides a detailed error message
    System.Console.WriteLine(ex);

    // Base exception fields
    HttpResponseMessage rawResponse = ex.RawResponse;
    HttpResponseHeaders headers = ex.Headers;
    int statusCode = ex.StatusCode;
    string? contentType = ex.ContentType;
    var responseBody = ex.Body;

    if (ex is GetServerCapabilitiesBadRequest) // different exceptions may be thrown depending on the method
    {
        // Check error data fields
        GetServerCapabilitiesBadRequestPayload payload = ex.Payload;
        List<Errors> Errors = payload.Errors;
        HttpResponseMessage RawResponse = payload.RawResponse;
    }

    // An underlying cause may be provided
    if (ex.InnerException != null)
    {
        Exception cause = ex.InnerException;
    }
}
catch (System.Net.Http.HttpRequestException ex)
{
    // Check ex.InnerException for Network connectivity errors
}

Error Classes

Primary exception:

Less common exceptions (158)
  • System.Net.Http.HttpRequestException: Network connectivity error. For more details about the underlying cause, inspect the ex.InnerException.

  • Inheriting from PlexAPIError:

    • GetServerCapabilitiesBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetServerPreferencesBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetAvailableClientsBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetDevicesBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetMyPlexAccountBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetResizedPhotoBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetMediaProvidersBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetServerListBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • MarkPlayedBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • MarkUnplayedBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • UpdatePlayProgressBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetBannerImageBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetThumbImageBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetTimelineBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • StartUniversalTranscodeBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetServerActivitiesBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • CancelServerActivitiesBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetButlerTasksBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • StartAllTasksBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • StopAllTasksBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • StartTaskBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • StopTaskBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetCompanionsDataBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetUserFriendsBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetGeoDataBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetHomeDataBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetServerResourcesBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetPinBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetTokenByPinIdBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetGlobalHubsBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetLibraryHubsBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • PerformSearchBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • PerformVoiceSearchBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetSearchResultsBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetFileHashBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetRecentlyAddedLibraryBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetAllLibrariesBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetLibraryDetailsBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • DeleteLibraryBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetLibraryItemsBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetLibrarySectionsAllBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetRefreshLibraryMetadataBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetSearchLibraryBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetGenresLibraryBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetCountriesLibraryBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetActorsLibraryBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetSearchAllLibrariesBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetMediaMetaDataBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetMetadataChildrenBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetTopWatchedContentBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetWatchListBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • LogLineBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • LogMultiLineBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • EnablePaperTrailBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • CreatePlaylistBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetPlaylistsBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetPlaylistBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • DeletePlaylistBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • UpdatePlaylistBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetPlaylistContentsBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • ClearPlaylistContentsBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • AddPlaylistContentsBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • UploadPlaylistBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetTransientTokenBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetSourceConnectionInformationBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetTokenDetailsBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • PostUsersSignInDataBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetStatisticsBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetResourcesStatisticsBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetBandwidthStatisticsBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetSessionsBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetSessionHistoryBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetTranscodeSessionsBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • StopTranscodeSessionBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetUpdateStatusBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • CheckForUpdatesBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • ApplyUpdatesBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetUsersBadRequest: Bad Request - A parameter was not specified, or was specified incorrectly. Status code 400. Applicable to 1 of 84 methods.*
    • GetServerCapabilitiesUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetServerPreferencesUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetAvailableClientsUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetDevicesUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetMyPlexAccountUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetResizedPhotoUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetMediaProvidersUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetServerListUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • MarkPlayedUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • MarkUnplayedUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • UpdatePlayProgressUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetBannerImageUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetThumbImageUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetTimelineUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • StartUniversalTranscodeUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetServerActivitiesUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • CancelServerActivitiesUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetButlerTasksUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • StartAllTasksUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • StopAllTasksUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • StartTaskUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • StopTaskUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetCompanionsDataUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetUserFriendsUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetGeoDataUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetHomeDataUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetServerResourcesUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetGlobalHubsUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetLibraryHubsUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • PerformSearchUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • PerformVoiceSearchUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetSearchResultsUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetFileHashUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetRecentlyAddedLibraryUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetAllLibrariesUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetLibraryDetailsUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • DeleteLibraryUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetLibraryItemsUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetLibrarySectionsAllUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetRefreshLibraryMetadataUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetSearchLibraryUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetGenresLibraryUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetCountriesLibraryUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetActorsLibraryUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetSearchAllLibrariesUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetMediaMetaDataUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetMetadataChildrenUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetTopWatchedContentUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetWatchListUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • LogLineUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • LogMultiLineUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • EnablePaperTrailUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • CreatePlaylistUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetPlaylistsUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetPlaylistUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • DeletePlaylistUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • UpdatePlaylistUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetPlaylistContentsUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • ClearPlaylistContentsUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • AddPlaylistContentsUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • UploadPlaylistUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetTransientTokenUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetSourceConnectionInformationUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetTokenDetailsUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • PostUsersSignInDataUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetStatisticsUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetResourcesStatisticsUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetBandwidthStatisticsUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetSessionsUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetSessionHistoryUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetTranscodeSessionsUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • StopTranscodeSessionUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetUpdateStatusUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • CheckForUpdatesUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • ApplyUpdatesUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetUsersUnauthorized: Unauthorized - Returned if the X-Plex-Token is missing from the header or query. Status code 401. Applicable to 1 of 84 methods.*
    • GetTokenByPinIdResponseBody: Not Found or Expired. Status code 404. Applicable to 1 of 84 methods.*
    • GetServerIdentityRequestTimeout: Request Timeout. Status code 408. Applicable to 1 of 84 methods.*
    • ResponseValidationError: Thrown when the response data could not be deserialized into the expected type.

* Refer to the relevant documentation to determine whether an exception applies to a specific operation.

Server Selection

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 parameters are available when initializing the SDK client instance:

Variable Parameter Supported Values Default Description
protocol protocol: LukeHagar.PlexAPI.SDK.Models.ServerProtocol - "http"
- "https"
"https" The protocol to use for the server connection
ip ip: string string "10.10.10.47" The IP address or hostname of your Plex Server
port port: string string "32400" The port of your Plex Server

Example

using LukeHagar.PlexAPI.SDK;
using LukeHagar.PlexAPI.SDK.Models.Components;

var sdk = new PlexAPI(
    protocol: "https",
    ip: "4982:bc2a:b4f8:efb5:2394:5bc3:ab4f:0e6d",
    port: "44765",
    accessToken: "<YOUR_API_KEY_HERE>"
);

var res = await sdk.Server.GetServerCapabilitiesAsync();

// handle response

Override Server URL Per-Client

The default server can be overridden globally by passing a URL to the serverUrl: string optional parameter when initializing the SDK client instance. For example:

using LukeHagar.PlexAPI.SDK;
using LukeHagar.PlexAPI.SDK.Models.Components;

var sdk = new PlexAPI(
    serverUrl: "https://10.10.10.47:32400",
    accessToken: "<YOUR_API_KEY_HERE>"
);

var res = await sdk.Server.GetServerCapabilitiesAsync();

// handle response

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:

using LukeHagar.PlexAPI.SDK;
using LukeHagar.PlexAPI.SDK.Models.Components;

var sdk = new PlexAPI(accessToken: "<YOUR_API_KEY_HERE>");

var res = await sdk.Plex.GetCompanionsDataAsync(serverUrl: "https://plex.tv/api/v2");

// handle response