Files
plexjs/docs/sdks/users/README.md

104 lines
7.4 KiB
Markdown

# Users
(*users*)
## Overview
### Available Operations
* [getUsers](#getusers) - Get list of all connected users
## getUsers
Get list of all users that are friends and have library access with the provided Plex authentication token
### Example Usage
<!-- UsageSnippet language="typescript" operationID="get-users" method="get" path="/users" -->
```typescript
import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/models/shared";
const plexAPI = new PlexAPI({
accepts: Accepts.ApplicationXml,
clientIdentifier: "3381b62b-9ab7-4e37-827b-203e9809eb58",
product: "Plex for Roku",
version: "2.4.1",
platform: "Roku",
platformVersion: "4.3 build 1057",
device: "Roku 3",
model: "4200X",
deviceVendor: "Roku",
deviceName: "Chrome",
marketplace: "googlePlay",
token: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await plexAPI.users.getUsers({});
console.log(result);
}
run();
```
### Standalone function
The standalone function version of this method:
```typescript
import { PlexAPICore } from "@lukehagar/plexjs/core.js";
import { usersGetUsers } from "@lukehagar/plexjs/funcs/usersGetUsers.js";
import { Accepts } from "@lukehagar/plexjs/models/shared";
// Use `PlexAPICore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const plexAPI = new PlexAPICore({
accepts: Accepts.ApplicationXml,
clientIdentifier: "3381b62b-9ab7-4e37-827b-203e9809eb58",
product: "Plex for Roku",
version: "2.4.1",
platform: "Roku",
platformVersion: "4.3 build 1057",
device: "Roku 3",
model: "4200X",
deviceVendor: "Roku",
deviceName: "Chrome",
marketplace: "googlePlay",
token: "<YOUR_API_KEY_HERE>",
});
async function run() {
const res = await usersGetUsers(plexAPI, {});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("usersGetUsers failed:", res.error);
}
}
run();
```
### Parameters
| Parameter | Type | Required | Description |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `request` | [operations.GetUsersRequest](../../models/operations/getusersrequest.md) | :heavy_check_mark: | The request object to use for the request. |
| `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\<[operations.GetUsersResponse](../../models/operations/getusersresponse.md)\>**
### Errors
| Error Type | Status Code | Content Type |
| -------------------------------- | -------------------------------- | -------------------------------- |
| errors.GetUsersBadRequestError | 400 | application/json |
| errors.GetUsersUnauthorizedError | 401 | application/json |
| errors.SDKError | 4XX, 5XX | \*/\* |