mirror of
https://github.com/LukeHagar/plexcsharp.git
synced 2025-12-06 12:37:46 +00:00
Plex
(Plex)
Overview
API Calls that perform operations directly against https://Plex.tv
Available Operations
- GetCompanionsData - Get Companions Data
- GetUserFriends - Get list of friends of the user logged in
- GetGeoData - Get Geo Data
- GetHomeData - Get Plex Home Data
- GetServerResources - Get Server Resources
- GetPin - Get a Pin
- GetTokenByPinId - Get Access Token by PinId
GetCompanionsData
Get Companions Data
Example Usage
using LukeHagar.PlexAPI.SDK;
using LukeHagar.PlexAPI.SDK.Models.Components;
var sdk = new PlexAPI(
accessToken: "<YOUR_API_KEY_HERE>",
clientID: "gcgzw5rz2xovp84b4vha3a40",
clientName: "Plex Web",
clientVersion: "4.133.0",
clientPlatform: "Chrome",
deviceName: "Linux"
);
var res = await sdk.Plex.GetCompanionsDataAsync();
// handle response
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
serverURL |
string | ➖ | An optional server URL to use. |
Response
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| LukeHagar.PlexAPI.SDK.Models.Errors.GetCompanionsDataBadRequest | 400 | application/json |
| LukeHagar.PlexAPI.SDK.Models.Errors.GetCompanionsDataUnauthorized | 401 | application/json |
| LukeHagar.PlexAPI.SDK.Models.Errors.SDKException | 4xx-5xx | / |
GetUserFriends
Get friends of provided auth token.
Example Usage
using LukeHagar.PlexAPI.SDK;
using LukeHagar.PlexAPI.SDK.Models.Components;
var sdk = new PlexAPI(
accessToken: "<YOUR_API_KEY_HERE>",
clientID: "gcgzw5rz2xovp84b4vha3a40",
clientName: "Plex Web",
clientVersion: "4.133.0",
clientPlatform: "Chrome",
deviceName: "Linux"
);
var res = await sdk.Plex.GetUserFriendsAsync();
// handle response
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
serverURL |
string | ➖ | An optional server URL to use. |
Response
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| LukeHagar.PlexAPI.SDK.Models.Errors.GetUserFriendsBadRequest | 400 | application/json |
| LukeHagar.PlexAPI.SDK.Models.Errors.GetUserFriendsUnauthorized | 401 | application/json |
| LukeHagar.PlexAPI.SDK.Models.Errors.SDKException | 4xx-5xx | / |
GetGeoData
Returns the geolocation and locale data of the caller
Example Usage
using LukeHagar.PlexAPI.SDK;
using LukeHagar.PlexAPI.SDK.Models.Components;
var sdk = new PlexAPI(
clientID: "gcgzw5rz2xovp84b4vha3a40",
clientName: "Plex Web",
clientVersion: "4.133.0",
clientPlatform: "Chrome",
deviceName: "Linux"
);
var res = await sdk.Plex.GetGeoDataAsync();
// handle response
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
serverURL |
string | ➖ | An optional server URL to use. |
Response
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| LukeHagar.PlexAPI.SDK.Models.Errors.GetGeoDataBadRequest | 400 | application/json |
| LukeHagar.PlexAPI.SDK.Models.Errors.GetGeoDataUnauthorized | 401 | application/json |
| LukeHagar.PlexAPI.SDK.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 LukeHagar.PlexAPI.SDK;
using LukeHagar.PlexAPI.SDK.Models.Components;
var sdk = new PlexAPI(
accessToken: "<YOUR_API_KEY_HERE>",
clientID: "gcgzw5rz2xovp84b4vha3a40",
clientName: "Plex Web",
clientVersion: "4.133.0",
clientPlatform: "Chrome",
deviceName: "Linux"
);
var res = await sdk.Plex.GetHomeDataAsync();
// handle response
Response
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| LukeHagar.PlexAPI.SDK.Models.Errors.GetHomeDataBadRequest | 400 | application/json |
| LukeHagar.PlexAPI.SDK.Models.Errors.GetHomeDataUnauthorized | 401 | application/json |
| LukeHagar.PlexAPI.SDK.Models.Errors.SDKException | 4xx-5xx | / |
GetServerResources
Get Plex server access tokens and server connections
Example Usage
using LukeHagar.PlexAPI.SDK;
using LukeHagar.PlexAPI.SDK.Models.Requests;
using LukeHagar.PlexAPI.SDK.Models.Components;
var sdk = new PlexAPI(
accessToken: "<YOUR_API_KEY_HERE>",
clientID: "gcgzw5rz2xovp84b4vha3a40",
clientName: "Plex Web",
clientVersion: "4.133.0",
clientPlatform: "Chrome",
deviceName: "Linux"
);
var res = await sdk.Plex.GetServerResourcesAsync(
clientID: "gcgzw5rz2xovp84b4vha3a40",
includeHttps: LukeHagar.PlexAPI.SDK.Models.Requests.IncludeHttps.One,
includeRelay: LukeHagar.PlexAPI.SDK.Models.Requests.IncludeRelay.One,
includeIPv6: LukeHagar.PlexAPI.SDK.Models.Requests.IncludeIPv6.One
);
// handle response
Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ClientID |
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) |
gcgzw5rz2xovp84b4vha3a40 |
IncludeHttps |
IncludeHttps | ➖ | Include Https entries in the results | 1 |
IncludeRelay |
IncludeRelay | ➖ | Include Relay addresses in the results E.g: https://10-0-0-25.bbf8e10c7fa20447cacee74cd9914cde.plex.direct:32400 |
1 |
IncludeIPv6 |
IncludeIPv6 | ➖ | Include IPv6 entries in the results | 1 |
serverURL |
string | ➖ | An optional server URL to use. | http://localhost:8080 |
Response
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| LukeHagar.PlexAPI.SDK.Models.Errors.GetServerResourcesBadRequest | 400 | application/json |
| LukeHagar.PlexAPI.SDK.Models.Errors.GetServerResourcesUnauthorized | 401 | application/json |
| LukeHagar.PlexAPI.SDK.Models.Errors.SDKException | 4xx-5xx | / |
GetPin
Retrieve a Pin ID from Plex.tv to use for authentication flows
Example Usage
using LukeHagar.PlexAPI.SDK;
using LukeHagar.PlexAPI.SDK.Models.Requests;
using LukeHagar.PlexAPI.SDK.Models.Components;
var sdk = new PlexAPI(
clientID: "gcgzw5rz2xovp84b4vha3a40",
clientName: "Plex Web",
clientVersion: "4.133.0",
clientPlatform: "Chrome",
deviceName: "Linux"
);
GetPinRequest req = new GetPinRequest() {};
var res = await sdk.Plex.GetPinAsync(req);
// handle response
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request |
GetPinRequest | ✔️ | The request object to use for the request. |
serverURL |
string | ➖ | An optional server URL to use. |
Response
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| LukeHagar.PlexAPI.SDK.Models.Errors.GetPinBadRequest | 400 | application/json |
| LukeHagar.PlexAPI.SDK.Models.Errors.SDKException | 4xx-5xx | / |
GetTokenByPinId
Retrieve an Access Token from Plex.tv after the Pin has been authenticated
Example Usage
using LukeHagar.PlexAPI.SDK;
using LukeHagar.PlexAPI.SDK.Models.Requests;
using LukeHagar.PlexAPI.SDK.Models.Components;
var sdk = new PlexAPI(
clientID: "gcgzw5rz2xovp84b4vha3a40",
clientName: "Plex Web",
clientVersion: "4.133.0",
clientPlatform: "Chrome",
deviceName: "Linux"
);
var res = await sdk.Plex.GetTokenByPinIdAsync(
pinID: 408895,
clientID: "gcgzw5rz2xovp84b4vha3a40"
);
// handle response
Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
PinID |
long | ✔️ | The PinID to retrieve an access token for | |
ClientID |
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) |
gcgzw5rz2xovp84b4vha3a40 |
serverURL |
string | ➖ | An optional server URL to use. | http://localhost:8080 |
Response
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| LukeHagar.PlexAPI.SDK.Models.Errors.GetTokenByPinIdBadRequest | 400 | application/json |
| LukeHagar.PlexAPI.SDK.Models.Errors.GetTokenByPinIdResponseBody | 404 | application/json |
| LukeHagar.PlexAPI.SDK.Models.Errors.SDKException | 4xx-5xx | / |