mirror of
https://github.com/LukeHagar/plexcsharp.git
synced 2025-12-07 20:47:44 +00:00
292 lines
20 KiB
Markdown
292 lines
20 KiB
Markdown
# Plex
|
|
(*Plex*)
|
|
|
|
## Overview
|
|
|
|
API Calls that perform operations directly against https://Plex.tv
|
|
|
|
|
|
### Available Operations
|
|
|
|
* [GetCompanionsData](#getcompanionsdata) - Get Companions Data
|
|
* [GetUserFriends](#getuserfriends) - Get list of friends of the user logged in
|
|
* [GetGeoData](#getgeodata) - Get Geo Data
|
|
* [GetHomeData](#gethomedata) - Get Plex Home Data
|
|
* [GetServerResources](#getserverresources) - Get Server Resources
|
|
* [GetPin](#getpin) - Get a Pin
|
|
* [GetTokenByPinId](#gettokenbypinid) - Get Access Token by PinId
|
|
|
|
## GetCompanionsData
|
|
|
|
Get Companions Data
|
|
|
|
### Example Usage
|
|
|
|
```csharp
|
|
using PlexAPI;
|
|
using PlexAPI.Models.Components;
|
|
|
|
var sdk = new PlexAPISDK(
|
|
accessToken: "<YOUR_API_KEY_HERE>",
|
|
xPlexClientIdentifier: "gcgzw5rz2xovp84b4vha3a40"
|
|
);
|
|
|
|
var res = await sdk.Plex.GetCompanionsDataAsync();
|
|
|
|
// handle response
|
|
```
|
|
|
|
### Parameters
|
|
|
|
| Parameter | Type | Required | Description |
|
|
| ------------------------------ | ------------------------------ | ------------------------------ | ------------------------------ |
|
|
| `serverURL` | *string* | :heavy_minus_sign: | An optional server URL to use. |
|
|
|
|
### Response
|
|
|
|
**[GetCompanionsDataResponse](../../Models/Requests/GetCompanionsDataResponse.md)**
|
|
|
|
### 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
|
|
|
|
```csharp
|
|
using PlexAPI;
|
|
using PlexAPI.Models.Components;
|
|
|
|
var sdk = new PlexAPISDK(
|
|
accessToken: "<YOUR_API_KEY_HERE>",
|
|
xPlexClientIdentifier: "gcgzw5rz2xovp84b4vha3a40"
|
|
);
|
|
|
|
var res = await sdk.Plex.GetUserFriendsAsync();
|
|
|
|
// handle response
|
|
```
|
|
|
|
### Parameters
|
|
|
|
| Parameter | Type | Required | Description |
|
|
| ------------------------------ | ------------------------------ | ------------------------------ | ------------------------------ |
|
|
| `serverURL` | *string* | :heavy_minus_sign: | An optional server URL to use. |
|
|
|
|
### Response
|
|
|
|
**[GetUserFriendsResponse](../../Models/Requests/GetUserFriendsResponse.md)**
|
|
|
|
### 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
|
|
|
|
```csharp
|
|
using PlexAPI;
|
|
using PlexAPI.Models.Components;
|
|
|
|
var sdk = new PlexAPISDK(xPlexClientIdentifier: "gcgzw5rz2xovp84b4vha3a40");
|
|
|
|
var res = await sdk.Plex.GetGeoDataAsync();
|
|
|
|
// handle response
|
|
```
|
|
|
|
### Parameters
|
|
|
|
| Parameter | Type | Required | Description |
|
|
| ------------------------------ | ------------------------------ | ------------------------------ | ------------------------------ |
|
|
| `serverURL` | *string* | :heavy_minus_sign: | An optional server URL to use. |
|
|
|
|
### Response
|
|
|
|
**[GetGeoDataResponse](../../Models/Requests/GetGeoDataResponse.md)**
|
|
|
|
### 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
|
|
|
|
```csharp
|
|
using PlexAPI;
|
|
using PlexAPI.Models.Components;
|
|
|
|
var sdk = new PlexAPISDK(
|
|
accessToken: "<YOUR_API_KEY_HERE>",
|
|
xPlexClientIdentifier: "gcgzw5rz2xovp84b4vha3a40"
|
|
);
|
|
|
|
var res = await sdk.Plex.GetHomeDataAsync();
|
|
|
|
// handle response
|
|
```
|
|
|
|
### Response
|
|
|
|
**[GetHomeDataResponse](../../Models/Requests/GetHomeDataResponse.md)**
|
|
|
|
### Errors
|
|
|
|
| Error Object | Status Code | Content Type |
|
|
| --------------------------------------------- | --------------------------------------------- | --------------------------------------------- |
|
|
| PlexAPI.Models.Errors.GetHomeDataResponseBody | 401 | application/json |
|
|
| PlexAPI.Models.Errors.SDKException | 4xx-5xx | */* |
|
|
|
|
|
|
## GetServerResources
|
|
|
|
Get Plex server access tokens and server connections
|
|
|
|
### Example Usage
|
|
|
|
```csharp
|
|
using PlexAPI;
|
|
using PlexAPI.Models.Requests;
|
|
using PlexAPI.Models.Components;
|
|
|
|
var sdk = new PlexAPISDK(
|
|
accessToken: "<YOUR_API_KEY_HERE>",
|
|
xPlexClientIdentifier: "gcgzw5rz2xovp84b4vha3a40"
|
|
);
|
|
|
|
GetServerResourcesRequest req = new GetServerResourcesRequest() {
|
|
XPlexToken = "CV5xoxjTpFKUzBTShsaf",
|
|
IncludeHttps = PlexAPI.Models.Requests.IncludeHttps.One,
|
|
IncludeRelay = PlexAPI.Models.Requests.IncludeRelay.One,
|
|
IncludeIPv6 = PlexAPI.Models.Requests.IncludeIPv6.One,
|
|
};
|
|
|
|
var res = await sdk.Plex.GetServerResourcesAsync(req);
|
|
|
|
// handle response
|
|
```
|
|
|
|
### Parameters
|
|
|
|
| Parameter | Type | Required | Description |
|
|
| ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- |
|
|
| `request` | [GetServerResourcesRequest](../../Models/Requests/GetServerResourcesRequest.md) | :heavy_check_mark: | The request object to use for the request. |
|
|
| `serverURL` | *string* | :heavy_minus_sign: | An optional server URL to use. |
|
|
|
|
### Response
|
|
|
|
**[GetServerResourcesResponse](../../Models/Requests/GetServerResourcesResponse.md)**
|
|
|
|
### Errors
|
|
|
|
| Error Object | Status Code | Content Type |
|
|
| ---------------------------------------------------- | ---------------------------------------------------- | ---------------------------------------------------- |
|
|
| PlexAPI.Models.Errors.GetServerResourcesResponseBody | 401 | application/json |
|
|
| PlexAPI.Models.Errors.SDKException | 4xx-5xx | */* |
|
|
|
|
|
|
## GetPin
|
|
|
|
Retrieve a Pin from Plex.tv for authentication flows
|
|
|
|
### Example Usage
|
|
|
|
```csharp
|
|
using PlexAPI;
|
|
using PlexAPI.Models.Requests;
|
|
using PlexAPI.Models.Components;
|
|
|
|
var sdk = new PlexAPISDK(xPlexClientIdentifier: "gcgzw5rz2xovp84b4vha3a40");
|
|
|
|
var res = await sdk.Plex.GetPinAsync(
|
|
strong: false,
|
|
xPlexClientIdentifier: "gcgzw5rz2xovp84b4vha3a40",
|
|
xPlexProduct: "Plex Web"
|
|
);
|
|
|
|
// handle response
|
|
```
|
|
|
|
### Parameters
|
|
|
|
| Parameter | Type | Required | Description | Example |
|
|
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
| `Strong` | *bool* | :heavy_minus_sign: | Determines the kind of code returned by the API call<br/>Strong codes are used for Pin authentication flows<br/>Non-Strong codes are used for `Plex.tv/link`<br/> | |
|
|
| `XPlexClientIdentifier` | *string* | :heavy_minus_sign: | The unique identifier for the client application<br/>This is used to track the client application and its usage<br/>(UUID, serial number, or other number unique per device)<br/> | gcgzw5rz2xovp84b4vha3a40 |
|
|
| `XPlexProduct` | *string* | :heavy_minus_sign: | N/A | Plex Web |
|
|
| `serverURL` | *string* | :heavy_minus_sign: | An optional server URL to use. | http://localhost:8080 |
|
|
|
|
### Response
|
|
|
|
**[GetPinResponse](../../Models/Requests/GetPinResponse.md)**
|
|
|
|
### 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
|
|
|
|
```csharp
|
|
using PlexAPI;
|
|
using PlexAPI.Models.Requests;
|
|
using PlexAPI.Models.Components;
|
|
|
|
var sdk = new PlexAPISDK(xPlexClientIdentifier: "gcgzw5rz2xovp84b4vha3a40");
|
|
|
|
var res = await sdk.Plex.GetTokenByPinIdAsync(
|
|
pinID: 408895,
|
|
xPlexClientIdentifier: "gcgzw5rz2xovp84b4vha3a40"
|
|
);
|
|
|
|
// handle response
|
|
```
|
|
|
|
### Parameters
|
|
|
|
| Parameter | Type | Required | Description | Example |
|
|
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
| `PinID` | *long* | :heavy_check_mark: | The PinID to retrieve an access token for | |
|
|
| `XPlexClientIdentifier` | *string* | :heavy_minus_sign: | The unique identifier for the client application<br/>This is used to track the client application and its usage<br/>(UUID, serial number, or other number unique per device)<br/> | gcgzw5rz2xovp84b4vha3a40 |
|
|
| `serverURL` | *string* | :heavy_minus_sign: | An optional server URL to use. | http://localhost:8080 |
|
|
|
|
### Response
|
|
|
|
**[GetTokenByPinIdResponse](../../Models/Requests/GetTokenByPinIdResponse.md)**
|
|
|
|
### Errors
|
|
|
|
| Error Object | Status Code | Content Type |
|
|
| ----------------------------------------------------- | ----------------------------------------------------- | ----------------------------------------------------- |
|
|
| PlexAPI.Models.Errors.GetTokenByPinIdResponseBody | 400 | application/json |
|
|
| PlexAPI.Models.Errors.GetTokenByPinIdPlexResponseBody | 404 | application/json |
|
|
| PlexAPI.Models.Errors.SDKException | 4xx-5xx | */* |
|