mirror of
https://github.com/LukeHagar/plexjs.git
synced 2025-12-06 04:20:46 +00:00
ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.377.1
This commit is contained in:
@@ -8,9 +8,240 @@ 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
|
||||
* [getResources](#getresources) - Get Resources
|
||||
* [getPin](#getpin) - Get a Pin
|
||||
* [getToken](#gettoken) - Get Access Token
|
||||
* [getTokenByPinId](#gettokenbypinid) - Get Access Token by PinId
|
||||
* [getUserDetails](#getuserdetails) - Get UserData By Token
|
||||
|
||||
## getCompanionsData
|
||||
|
||||
Get Companions Data
|
||||
|
||||
### Example Usage
|
||||
|
||||
```typescript
|
||||
import { PlexAPI } from "@lukehagar/plexjs";
|
||||
|
||||
const plexAPI = new PlexAPI({
|
||||
accessToken: "<YOUR_API_KEY_HERE>",
|
||||
xPlexClientIdentifier: "Postman",
|
||||
});
|
||||
|
||||
async function run() {
|
||||
const result = await plexAPI.plex.getCompanionsData();
|
||||
|
||||
// Handle the result
|
||||
console.log(result)
|
||||
}
|
||||
|
||||
run();
|
||||
```
|
||||
|
||||
### Standalone function
|
||||
|
||||
The standalone function version of this method:
|
||||
|
||||
```typescript
|
||||
import { PlexAPICore } from "@lukehagar/plexjs/core.js";
|
||||
import { plexGetCompanionsData } from "@lukehagar/plexjs/funcs/plexGetCompanionsData.js";
|
||||
|
||||
// Use `PlexAPICore` for best tree-shaking performance.
|
||||
// You can create one instance of it to use across an application.
|
||||
const plexAPI = new PlexAPICore({
|
||||
accessToken: "<YOUR_API_KEY_HERE>",
|
||||
xPlexClientIdentifier: "Postman",
|
||||
});
|
||||
|
||||
async function run() {
|
||||
const res = await plexGetCompanionsData(plexAPI);
|
||||
|
||||
if (!res.ok) {
|
||||
throw res.error;
|
||||
}
|
||||
|
||||
const { value: result } = res;
|
||||
|
||||
// Handle the result
|
||||
console.log(result)
|
||||
}
|
||||
|
||||
run();
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
|
||||
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
|
||||
| `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
|
||||
| `options.serverURL` | *string* | :heavy_minus_sign: | An optional server URL to use. |
|
||||
|
||||
### Response
|
||||
|
||||
**Promise\<[models.GetCompanionsDataResponse](../../models/getcompanionsdataresponse.md)\>**
|
||||
|
||||
### Errors
|
||||
|
||||
| Error Object | Status Code | Content Type |
|
||||
| ------------------------------------ | ------------------------------------ | ------------------------------------ |
|
||||
| models.GetCompanionsDataResponseBody | 401 | application/json |
|
||||
| models.SDKError | 4xx-5xx | */* |
|
||||
|
||||
|
||||
## getUserFriends
|
||||
|
||||
Get friends of provided auth token.
|
||||
|
||||
### Example Usage
|
||||
|
||||
```typescript
|
||||
import { PlexAPI } from "@lukehagar/plexjs";
|
||||
|
||||
const plexAPI = new PlexAPI({
|
||||
accessToken: "<YOUR_API_KEY_HERE>",
|
||||
xPlexClientIdentifier: "Postman",
|
||||
});
|
||||
|
||||
async function run() {
|
||||
const result = await plexAPI.plex.getUserFriends();
|
||||
|
||||
// Handle the result
|
||||
console.log(result)
|
||||
}
|
||||
|
||||
run();
|
||||
```
|
||||
|
||||
### Standalone function
|
||||
|
||||
The standalone function version of this method:
|
||||
|
||||
```typescript
|
||||
import { PlexAPICore } from "@lukehagar/plexjs/core.js";
|
||||
import { plexGetUserFriends } from "@lukehagar/plexjs/funcs/plexGetUserFriends.js";
|
||||
|
||||
// Use `PlexAPICore` for best tree-shaking performance.
|
||||
// You can create one instance of it to use across an application.
|
||||
const plexAPI = new PlexAPICore({
|
||||
accessToken: "<YOUR_API_KEY_HERE>",
|
||||
xPlexClientIdentifier: "Postman",
|
||||
});
|
||||
|
||||
async function run() {
|
||||
const res = await plexGetUserFriends(plexAPI);
|
||||
|
||||
if (!res.ok) {
|
||||
throw res.error;
|
||||
}
|
||||
|
||||
const { value: result } = res;
|
||||
|
||||
// Handle the result
|
||||
console.log(result)
|
||||
}
|
||||
|
||||
run();
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
|
||||
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
|
||||
| `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
|
||||
| `options.serverURL` | *string* | :heavy_minus_sign: | An optional server URL to use. |
|
||||
|
||||
### Response
|
||||
|
||||
**Promise\<[models.GetUserFriendsResponse](../../models/getuserfriendsresponse.md)\>**
|
||||
|
||||
### Errors
|
||||
|
||||
| Error Object | Status Code | Content Type |
|
||||
| --------------------------------- | --------------------------------- | --------------------------------- |
|
||||
| models.GetUserFriendsResponseBody | 401 | application/json |
|
||||
| models.SDKError | 4xx-5xx | */* |
|
||||
|
||||
|
||||
## getGeoData
|
||||
|
||||
Returns the geolocation and locale data of the caller
|
||||
|
||||
### Example Usage
|
||||
|
||||
```typescript
|
||||
import { PlexAPI } from "@lukehagar/plexjs";
|
||||
|
||||
const plexAPI = new PlexAPI({
|
||||
xPlexClientIdentifier: "Postman",
|
||||
});
|
||||
|
||||
async function run() {
|
||||
const result = await plexAPI.plex.getGeoData();
|
||||
|
||||
// Handle the result
|
||||
console.log(result)
|
||||
}
|
||||
|
||||
run();
|
||||
```
|
||||
|
||||
### Standalone function
|
||||
|
||||
The standalone function version of this method:
|
||||
|
||||
```typescript
|
||||
import { PlexAPICore } from "@lukehagar/plexjs/core.js";
|
||||
import { plexGetGeoData } from "@lukehagar/plexjs/funcs/plexGetGeoData.js";
|
||||
|
||||
// Use `PlexAPICore` for best tree-shaking performance.
|
||||
// You can create one instance of it to use across an application.
|
||||
const plexAPI = new PlexAPICore({
|
||||
xPlexClientIdentifier: "Postman",
|
||||
});
|
||||
|
||||
async function run() {
|
||||
const res = await plexGetGeoData(plexAPI);
|
||||
|
||||
if (!res.ok) {
|
||||
throw res.error;
|
||||
}
|
||||
|
||||
const { value: result } = res;
|
||||
|
||||
// Handle the result
|
||||
console.log(result)
|
||||
}
|
||||
|
||||
run();
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
|
||||
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
|
||||
| `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
|
||||
| `options.serverURL` | *string* | :heavy_minus_sign: | An optional server URL to use. |
|
||||
|
||||
### Response
|
||||
|
||||
**Promise\<[models.GetGeoDataResponse](../../models/getgeodataresponse.md)\>**
|
||||
|
||||
### Errors
|
||||
|
||||
| Error Object | Status Code | Content Type |
|
||||
| ----------------------------- | ----------------------------- | ----------------------------- |
|
||||
| models.GetGeoDataResponseBody | 401 | application/json |
|
||||
| models.SDKError | 4xx-5xx | */* |
|
||||
|
||||
|
||||
## getHomeData
|
||||
|
||||
@@ -36,17 +267,49 @@ async function run() {
|
||||
run();
|
||||
```
|
||||
|
||||
### Standalone function
|
||||
|
||||
The standalone function version of this method:
|
||||
|
||||
```typescript
|
||||
import { PlexAPICore } from "@lukehagar/plexjs/core.js";
|
||||
import { plexGetHomeData } from "@lukehagar/plexjs/funcs/plexGetHomeData.js";
|
||||
|
||||
// Use `PlexAPICore` for best tree-shaking performance.
|
||||
// You can create one instance of it to use across an application.
|
||||
const plexAPI = new PlexAPICore({
|
||||
accessToken: "<YOUR_API_KEY_HERE>",
|
||||
xPlexClientIdentifier: "Postman",
|
||||
});
|
||||
|
||||
async function run() {
|
||||
const res = await plexGetHomeData(plexAPI);
|
||||
|
||||
if (!res.ok) {
|
||||
throw res.error;
|
||||
}
|
||||
|
||||
const { value: result } = res;
|
||||
|
||||
// Handle the result
|
||||
console.log(result)
|
||||
}
|
||||
|
||||
run();
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
|
||||
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
|
||||
|
||||
| `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
|
||||
|
||||
### Response
|
||||
|
||||
**Promise\<[models.GetHomeDataResponse](../../models/gethomedataresponse.md)\>**
|
||||
|
||||
### Errors
|
||||
|
||||
| Error Object | Status Code | Content Type |
|
||||
@@ -54,6 +317,85 @@ run();
|
||||
| models.GetHomeDataPlexResponseBody | 401 | application/json |
|
||||
| models.SDKError | 4xx-5xx | */* |
|
||||
|
||||
|
||||
## getResources
|
||||
|
||||
Get Resources
|
||||
|
||||
### Example Usage
|
||||
|
||||
```typescript
|
||||
import { PlexAPI } from "@lukehagar/plexjs";
|
||||
|
||||
const plexAPI = new PlexAPI({
|
||||
xPlexClientIdentifier: "Postman",
|
||||
});
|
||||
|
||||
async function run() {
|
||||
const result = await plexAPI.plex.getResources("Postman");
|
||||
|
||||
// Handle the result
|
||||
console.log(result)
|
||||
}
|
||||
|
||||
run();
|
||||
```
|
||||
|
||||
### Standalone function
|
||||
|
||||
The standalone function version of this method:
|
||||
|
||||
```typescript
|
||||
import { PlexAPICore } from "@lukehagar/plexjs/core.js";
|
||||
import { plexGetResources } from "@lukehagar/plexjs/funcs/plexGetResources.js";
|
||||
|
||||
// Use `PlexAPICore` for best tree-shaking performance.
|
||||
// You can create one instance of it to use across an application.
|
||||
const plexAPI = new PlexAPICore({
|
||||
xPlexClientIdentifier: "Postman",
|
||||
});
|
||||
|
||||
async function run() {
|
||||
const res = await plexGetResources(plexAPI, "Postman");
|
||||
|
||||
if (!res.ok) {
|
||||
throw res.error;
|
||||
}
|
||||
|
||||
const { value: result } = res;
|
||||
|
||||
// Handle the result
|
||||
console.log(result)
|
||||
}
|
||||
|
||||
run();
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Required | Description | Example |
|
||||
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| `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/> | [object Object] |
|
||||
| `includeHttps` | [models.IncludeHttps](../../models/includehttps.md) | :heavy_minus_sign: | Include Https entries in the results | |
|
||||
| `includeRelay` | [models.IncludeRelay](../../models/includerelay.md) | :heavy_minus_sign: | Include Relay addresses in the results | |
|
||||
| `includeIPv6` | [models.IncludeIPv6](../../models/includeipv6.md) | :heavy_minus_sign: | Include IPv6 entries in the results | |
|
||||
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. | |
|
||||
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | |
|
||||
| `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | |
|
||||
| `options.serverURL` | *string* | :heavy_minus_sign: | An optional server URL to use. | http://localhost:8080 |
|
||||
|
||||
### Response
|
||||
|
||||
**Promise\<[models.GetResourcesResponse](../../models/getresourcesresponse.md)\>**
|
||||
|
||||
### Errors
|
||||
|
||||
| Error Object | Status Code | Content Type |
|
||||
| ------------------------------- | ------------------------------- | ------------------------------- |
|
||||
| models.GetResourcesResponseBody | 401 | application/json |
|
||||
| models.SDKError | 4xx-5xx | */* |
|
||||
|
||||
|
||||
## getPin
|
||||
|
||||
Retrieve a Pin from Plex.tv for authentication flows
|
||||
@@ -68,7 +410,37 @@ const plexAPI = new PlexAPI({
|
||||
});
|
||||
|
||||
async function run() {
|
||||
const result = await plexAPI.plex.getPin("Postman", false, "Postman");
|
||||
const result = await plexAPI.plex.getPin("Postman", "Postman");
|
||||
|
||||
// Handle the result
|
||||
console.log(result)
|
||||
}
|
||||
|
||||
run();
|
||||
```
|
||||
|
||||
### Standalone function
|
||||
|
||||
The standalone function version of this method:
|
||||
|
||||
```typescript
|
||||
import { PlexAPICore } from "@lukehagar/plexjs/core.js";
|
||||
import { plexGetPin } from "@lukehagar/plexjs/funcs/plexGetPin.js";
|
||||
|
||||
// Use `PlexAPICore` for best tree-shaking performance.
|
||||
// You can create one instance of it to use across an application.
|
||||
const plexAPI = new PlexAPICore({
|
||||
xPlexClientIdentifier: "Postman",
|
||||
});
|
||||
|
||||
async function run() {
|
||||
const res = await plexGetPin(plexAPI, "Postman", "Postman");
|
||||
|
||||
if (!res.ok) {
|
||||
throw res.error;
|
||||
}
|
||||
|
||||
const { value: result } = res;
|
||||
|
||||
// Handle the result
|
||||
console.log(result)
|
||||
@@ -86,22 +458,24 @@ run();
|
||||
| `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/> | [object Object] |
|
||||
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. | |
|
||||
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | |
|
||||
| `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | |
|
||||
| `options.serverURL` | *string* | :heavy_minus_sign: | An optional server URL to use. | http://localhost:8080 |
|
||||
|
||||
|
||||
### Response
|
||||
|
||||
**Promise\<[models.GetPinResponse](../../models/getpinresponse.md)\>**
|
||||
|
||||
### Errors
|
||||
|
||||
| Error Object | Status Code | Content Type |
|
||||
| ----------------------------- | ----------------------------- | ----------------------------- |
|
||||
| models.GetPinPlexResponseBody | 400 | application/json |
|
||||
| models.SDKError | 4xx-5xx | */* |
|
||||
| Error Object | Status Code | Content Type |
|
||||
| ------------------------- | ------------------------- | ------------------------- |
|
||||
| models.GetPinResponseBody | 400 | application/json |
|
||||
| models.SDKError | 4xx-5xx | */* |
|
||||
|
||||
## getToken
|
||||
|
||||
Retrieve an Access Token from Plex.tv after the Pin has already been authenticated
|
||||
## getTokenByPinId
|
||||
|
||||
Retrieve an Access Token from Plex.tv after the Pin has been authenticated
|
||||
|
||||
### Example Usage
|
||||
|
||||
@@ -113,7 +487,37 @@ const plexAPI = new PlexAPI({
|
||||
});
|
||||
|
||||
async function run() {
|
||||
const result = await plexAPI.plex.getToken("<value>", "Postman");
|
||||
const result = await plexAPI.plex.getTokenByPinId(408895, "Postman");
|
||||
|
||||
// Handle the result
|
||||
console.log(result)
|
||||
}
|
||||
|
||||
run();
|
||||
```
|
||||
|
||||
### Standalone function
|
||||
|
||||
The standalone function version of this method:
|
||||
|
||||
```typescript
|
||||
import { PlexAPICore } from "@lukehagar/plexjs/core.js";
|
||||
import { plexGetTokenByPinId } from "@lukehagar/plexjs/funcs/plexGetTokenByPinId.js";
|
||||
|
||||
// Use `PlexAPICore` for best tree-shaking performance.
|
||||
// You can create one instance of it to use across an application.
|
||||
const plexAPI = new PlexAPICore({
|
||||
xPlexClientIdentifier: "Postman",
|
||||
});
|
||||
|
||||
async function run() {
|
||||
const res = await plexGetTokenByPinId(plexAPI, 537318, "Postman");
|
||||
|
||||
if (!res.ok) {
|
||||
throw res.error;
|
||||
}
|
||||
|
||||
const { value: result } = res;
|
||||
|
||||
// Handle the result
|
||||
console.log(result)
|
||||
@@ -126,19 +530,96 @@ run();
|
||||
|
||||
| Parameter | Type | Required | Description | Example |
|
||||
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| `pinID` | *string* | :heavy_check_mark: | The PinID to retrieve an access token for | |
|
||||
| `pinID` | *number* | :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/> | [object Object] |
|
||||
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. | |
|
||||
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | |
|
||||
| `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | |
|
||||
| `options.serverURL` | *string* | :heavy_minus_sign: | An optional server URL to use. | http://localhost:8080 |
|
||||
|
||||
|
||||
### Response
|
||||
|
||||
**Promise\<[models.GetTokenResponse](../../models/gettokenresponse.md)\>**
|
||||
**Promise\<[models.GetTokenByPinIdResponse](../../models/gettokenbypinidresponse.md)\>**
|
||||
|
||||
### Errors
|
||||
|
||||
| Error Object | Status Code | Content Type |
|
||||
| ------------------------------- | ------------------------------- | ------------------------------- |
|
||||
| models.GetTokenPlexResponseBody | 400 | application/json |
|
||||
| models.SDKError | 4xx-5xx | */* |
|
||||
| Error Object | Status Code | Content Type |
|
||||
| ---------------------------------- | ---------------------------------- | ---------------------------------- |
|
||||
| models.GetTokenByPinIdResponseBody | 404 | application/json |
|
||||
| models.SDKError | 4xx-5xx | */* |
|
||||
|
||||
|
||||
## getUserDetails
|
||||
|
||||
Get the User data from the provided X-Plex-Token
|
||||
|
||||
### Example Usage
|
||||
|
||||
```typescript
|
||||
import { PlexAPI } from "@lukehagar/plexjs";
|
||||
|
||||
const plexAPI = new PlexAPI({
|
||||
accessToken: "<YOUR_API_KEY_HERE>",
|
||||
xPlexClientIdentifier: "Postman",
|
||||
});
|
||||
|
||||
async function run() {
|
||||
const result = await plexAPI.plex.getUserDetails();
|
||||
|
||||
// Handle the result
|
||||
console.log(result)
|
||||
}
|
||||
|
||||
run();
|
||||
```
|
||||
|
||||
### Standalone function
|
||||
|
||||
The standalone function version of this method:
|
||||
|
||||
```typescript
|
||||
import { PlexAPICore } from "@lukehagar/plexjs/core.js";
|
||||
import { plexGetUserDetails } from "@lukehagar/plexjs/funcs/plexGetUserDetails.js";
|
||||
|
||||
// Use `PlexAPICore` for best tree-shaking performance.
|
||||
// You can create one instance of it to use across an application.
|
||||
const plexAPI = new PlexAPICore({
|
||||
accessToken: "<YOUR_API_KEY_HERE>",
|
||||
xPlexClientIdentifier: "Postman",
|
||||
});
|
||||
|
||||
async function run() {
|
||||
const res = await plexGetUserDetails(plexAPI);
|
||||
|
||||
if (!res.ok) {
|
||||
throw res.error;
|
||||
}
|
||||
|
||||
const { value: result } = res;
|
||||
|
||||
// Handle the result
|
||||
console.log(result)
|
||||
}
|
||||
|
||||
run();
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
|
||||
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
|
||||
| `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
|
||||
| `options.serverURL` | *string* | :heavy_minus_sign: | An optional server URL to use. |
|
||||
|
||||
### Response
|
||||
|
||||
**Promise\<[models.GetUserDetailsResponse](../../models/getuserdetailsresponse.md)\>**
|
||||
|
||||
### Errors
|
||||
|
||||
| Error Object | Status Code | Content Type |
|
||||
| --------------------------------- | --------------------------------- | --------------------------------- |
|
||||
| models.GetUserDetailsResponseBody | 401 | application/json |
|
||||
| models.SDKError | 4xx-5xx | */* |
|
||||
|
||||
Reference in New Issue
Block a user