mirror of
https://github.com/LukeHagar/plexcsharp.git
synced 2025-12-07 20:47:44 +00:00
Plex
(Plex)
Overview
API Calls that perform operations directly against https://Plex.tv
Available Operations
- GetHomeData - Get Plex Home Data
- GetPin - Get a Pin
- GetToken - Get Access Token
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
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| PlexAPI.Models.Errors.GetHomeDataResponseBody | 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.Components;
using PlexAPI.Models.Requests;
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
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| PlexAPI.Models.Errors.GetPinResponseBody | 400 | application/json |
| PlexAPI.Models.Errors.SDKException | 4xx-5xx | / |
GetToken
Retrieve an Access Token from Plex.tv after the Pin has already been authenticated
Example Usage
using PlexAPI;
using PlexAPI.Models.Components;
using PlexAPI.Models.Requests;
var sdk = new PlexAPISDK(xPlexClientIdentifier: "Postman");
var res = await sdk.Plex.GetTokenAsync(
pinID: "<value>",
xPlexClientIdentifier: "Postman");
// handle response
Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
PinID |
string | ✔️ | 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
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| PlexAPI.Models.Errors.GetTokenResponseBody | 400 | application/json |
| PlexAPI.Models.Errors.SDKException | 4xx-5xx | / |