Files
plexcsharp/docs/sdks/plex

Plex

(Plex)

Overview

API Calls that perform operations directly against https://Plex.tv

Available Operations

GetCompanionsData

Get Companions Data

Example Usage

using PlexAPI;
using PlexAPI.Models.Components;

var sdk = new PlexAPISDK(
    accessToken: "<YOUR_API_KEY_HERE>",
    xPlexClientIdentifier: "Postman"
);

var res = await sdk.Plex.GetCompanionsDataAsync();

// handle response

Parameters

Parameter Type Required Description
serverURL string An optional server URL to use.

Response

GetCompanionsDataResponse

Errors

Error Object Status Code Content Type
PlexAPI.Models.Errors.GetCompanionsDataResponseBody 401 application/json
PlexAPI.Models.Errors.SDKException 4xx-5xx /

GetUserFriends

Get friends of provided auth token.

Example Usage

using PlexAPI;
using PlexAPI.Models.Components;

var sdk = new PlexAPISDK(
    accessToken: "<YOUR_API_KEY_HERE>",
    xPlexClientIdentifier: "Postman"
);

var res = await sdk.Plex.GetUserFriendsAsync();

// handle response

Parameters

Parameter Type Required Description
serverURL string An optional server URL to use.

Response

GetUserFriendsResponse

Errors

Error Object Status Code Content Type
PlexAPI.Models.Errors.GetUserFriendsResponseBody 401 application/json
PlexAPI.Models.Errors.SDKException 4xx-5xx /

GetGeoData

Returns the geolocation and locale data of the caller

Example Usage

using PlexAPI;
using PlexAPI.Models.Components;

var sdk = new PlexAPISDK(xPlexClientIdentifier: "Postman");

var res = await sdk.Plex.GetGeoDataAsync();

// handle response

Parameters

Parameter Type Required Description
serverURL string An optional server URL to use.

Response

GetGeoDataResponse

Errors

Error Object Status Code Content Type
PlexAPI.Models.Errors.GetGeoDataResponseBody 401 application/json
PlexAPI.Models.Errors.SDKException 4xx-5xx /

GetHomeData

Retrieves the home data for the authenticated user, including details like home ID, name, guest access information, and subscription status.

Example Usage

using PlexAPI;
using PlexAPI.Models.Components;

var sdk = new PlexAPISDK(
    accessToken: "<YOUR_API_KEY_HERE>",
    xPlexClientIdentifier: "Postman"
);

var res = await sdk.Plex.GetHomeDataAsync();

// handle response

Response

GetHomeDataResponse

Errors

Error Object Status Code Content Type
PlexAPI.Models.Errors.GetHomeDataResponseBody 401 application/json
PlexAPI.Models.Errors.SDKException 4xx-5xx /

GetResources

Get Resources

Example Usage

using PlexAPI;
using PlexAPI.Models.Requests;
using PlexAPI.Models.Components;

var sdk = new PlexAPISDK(xPlexClientIdentifier: "Postman");

var res = await sdk.Plex.GetResourcesAsync(
    xPlexClientIdentifier: "Postman",
    includeHttps: PlexAPI.Models.Requests.IncludeHttps.Zero,
    includeRelay: PlexAPI.Models.Requests.IncludeRelay.Zero,
    includeIPv6: PlexAPI.Models.Requests.IncludeIPv6.One
);

// handle response

Parameters

Parameter Type Required Description Example
XPlexClientIdentifier string The unique identifier for the client application
This is used to track the client application and its usage
(UUID, serial number, or other number unique per device)
Postman
IncludeHttps IncludeHttps Include Https entries in the results
IncludeRelay IncludeRelay Include Relay addresses in the results
IncludeIPv6 IncludeIPv6 Include IPv6 entries in the results
serverURL string An optional server URL to use. http://localhost:8080

Response

GetResourcesResponse

Errors

Error Object Status Code Content Type
PlexAPI.Models.Errors.GetResourcesResponseBody 401 application/json
PlexAPI.Models.Errors.SDKException 4xx-5xx /

GetPin

Retrieve a Pin from Plex.tv for authentication flows

Example Usage

using PlexAPI;
using PlexAPI.Models.Requests;
using PlexAPI.Models.Components;

var sdk = new PlexAPISDK(xPlexClientIdentifier: "Postman");

var res = await sdk.Plex.GetPinAsync(
    xPlexProduct: "Postman",
    strong: false,
    xPlexClientIdentifier: "Postman"
);

// handle response

Parameters

Parameter Type Required Description Example
XPlexProduct string ✔️ Product name of the application shown in the list of devices
Postman
Strong bool Determines the kind of code returned by the API call
Strong codes are used for Pin authentication flows
Non-Strong codes are used for Plex.tv/link
XPlexClientIdentifier string The unique identifier for the client application
This is used to track the client application and its usage
(UUID, serial number, or other number unique per device)
Postman
serverURL string An optional server URL to use. http://localhost:8080

Response

GetPinResponse

Errors

Error Object Status Code Content Type
PlexAPI.Models.Errors.GetPinResponseBody 400 application/json
PlexAPI.Models.Errors.SDKException 4xx-5xx /

GetTokenByPinId

Retrieve an Access Token from Plex.tv after the Pin has been authenticated

Example Usage

using PlexAPI;
using PlexAPI.Models.Requests;
using PlexAPI.Models.Components;

var sdk = new PlexAPISDK(xPlexClientIdentifier: "Postman");

var res = await sdk.Plex.GetTokenByPinIdAsync(
    pinID: 408895,
    xPlexClientIdentifier: "Postman"
);

// handle response

Parameters

Parameter Type Required Description Example
PinID long ✔️ The PinID to retrieve an access token for
XPlexClientIdentifier string The unique identifier for the client application
This is used to track the client application and its usage
(UUID, serial number, or other number unique per device)
Postman
serverURL string An optional server URL to use. http://localhost:8080

Response

GetTokenByPinIdResponse

Errors

Error Object Status Code Content Type
PlexAPI.Models.Errors.GetTokenByPinIdResponseBody 404 application/json
PlexAPI.Models.Errors.SDKException 4xx-5xx /

GetUserDetails

Get the User data from the provided X-Plex-Token

Example Usage

using PlexAPI;
using PlexAPI.Models.Components;

var sdk = new PlexAPISDK(
    accessToken: "<YOUR_API_KEY_HERE>",
    xPlexClientIdentifier: "Postman"
);

var res = await sdk.Plex.GetUserDetailsAsync();

// handle response

Parameters

Parameter Type Required Description
serverURL string An optional server URL to use.

Response

GetUserDetailsResponse

Errors

Error Object Status Code Content Type
PlexAPI.Models.Errors.GetUserDetailsResponseBody 401 application/json
PlexAPI.Models.Errors.SDKException 4xx-5xx /