mirror of
https://github.com/LukeHagar/plexjava.git
synced 2025-12-06 12:37:47 +00:00
224 lines
16 KiB
Markdown
224 lines
16 KiB
Markdown
# Plex
|
|
(*plex()*)
|
|
|
|
## Overview
|
|
|
|
API Calls that perform operations directly against https://Plex.tv
|
|
|
|
|
|
### Available Operations
|
|
|
|
* [getHomeData](#gethomedata) - Get Plex Home Data
|
|
* [getPin](#getpin) - Get a Pin
|
|
* [getToken](#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
|
|
|
|
```java
|
|
package hello.world;
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigInteger;
|
|
import java.time.LocalDate;
|
|
import java.time.OffsetDateTime;
|
|
import java.util.Optional;
|
|
import lukehagar.plexapi.plexapi.PlexAPI;
|
|
import lukehagar.plexapi.plexapi.models.operations.*;
|
|
import lukehagar.plexapi.plexapi.models.shared.*;
|
|
import lukehagar.plexapi.plexapi.models.shared.Security;
|
|
import lukehagar.plexapi.plexapi.utils.EventStream;
|
|
import org.openapitools.jackson.nullable.JsonNullable;
|
|
import static java.util.Map.entry;
|
|
|
|
public class Application {
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
try {
|
|
PlexAPI sdk = PlexAPI.builder()
|
|
.accessToken("<YOUR_API_KEY_HERE>")
|
|
.xPlexClientIdentifier("Postman")
|
|
.build();
|
|
|
|
GetHomeDataResponse res = sdk.plex().getHomeData()
|
|
.call();
|
|
|
|
if (res.object().isPresent()) {
|
|
// handle response
|
|
}
|
|
} catch (lukehagar.plexapi.plexapi.models.errors.GetHomeDataResponseBody e) {
|
|
// handle exception
|
|
throw e;
|
|
} catch (lukehagar.plexapi.plexapi.models.errors.SDKError e) {
|
|
// handle exception
|
|
throw e;
|
|
} catch (Exception e) {
|
|
// handle exception
|
|
throw e;
|
|
}
|
|
|
|
}
|
|
}
|
|
```
|
|
|
|
|
|
### Response
|
|
|
|
**[lukehagar.plexapi.plexapi.models.operations.GetHomeDataResponse](../../models/operations/GetHomeDataResponse.md)**
|
|
### Errors
|
|
|
|
| Error Object | Status Code | Content Type |
|
|
| ------------------------------------- | ------------------------------------- | ------------------------------------- |
|
|
| models/errors/GetHomeDataResponseBody | 401 | application/json |
|
|
| models/errors/SDKError | 4xx-5xx | \*\/* |
|
|
|
|
## getPin
|
|
|
|
Retrieve a Pin from Plex.tv for authentication flows
|
|
|
|
### Example Usage
|
|
|
|
```java
|
|
package hello.world;
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigInteger;
|
|
import java.time.LocalDate;
|
|
import java.time.OffsetDateTime;
|
|
import java.util.Optional;
|
|
import lukehagar.plexapi.plexapi.PlexAPI;
|
|
import lukehagar.plexapi.plexapi.models.operations.*;
|
|
import lukehagar.plexapi.plexapi.models.shared.*;
|
|
import lukehagar.plexapi.plexapi.utils.EventStream;
|
|
import org.openapitools.jackson.nullable.JsonNullable;
|
|
import static java.util.Map.entry;
|
|
|
|
public class Application {
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
try {
|
|
PlexAPI sdk = PlexAPI.builder()
|
|
.xPlexClientIdentifier("Postman")
|
|
.build();
|
|
|
|
GetPinResponse res = sdk.plex().getPin()
|
|
.strong(false)
|
|
.xPlexClientIdentifier("Postman")
|
|
.xPlexProduct("Postman")
|
|
.call();
|
|
|
|
if (res.object().isPresent()) {
|
|
// handle response
|
|
}
|
|
} catch (lukehagar.plexapi.plexapi.models.errors.GetPinResponseBody e) {
|
|
// handle exception
|
|
throw e;
|
|
} catch (lukehagar.plexapi.plexapi.models.errors.SDKError e) {
|
|
// handle exception
|
|
throw e;
|
|
} catch (Exception e) {
|
|
// handle exception
|
|
throw e;
|
|
}
|
|
|
|
}
|
|
}
|
|
```
|
|
|
|
### Parameters
|
|
|
|
| Parameter | Type | Required | Description | Example |
|
|
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
| `strong` | *Optional<? extends Boolean>* | :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` | *Optional<? extends 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/> | Postman |
|
|
| `xPlexProduct` | *String* | :heavy_check_mark: | Product name of the application shown in the list of devices<br/> | Postman |
|
|
| `serverURL` | *String* | :heavy_minus_sign: | An optional server URL to use. | http://localhost:8080 |
|
|
|
|
|
|
### Response
|
|
|
|
**[lukehagar.plexapi.plexapi.models.operations.GetPinResponse](../../models/operations/GetPinResponse.md)**
|
|
### Errors
|
|
|
|
| Error Object | Status Code | Content Type |
|
|
| -------------------------------- | -------------------------------- | -------------------------------- |
|
|
| models/errors/GetPinResponseBody | 400 | application/json |
|
|
| models/errors/SDKError | 4xx-5xx | \*\/* |
|
|
|
|
## getToken
|
|
|
|
Retrieve an Access Token from Plex.tv after the Pin has already been authenticated
|
|
|
|
### Example Usage
|
|
|
|
```java
|
|
package hello.world;
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigInteger;
|
|
import java.time.LocalDate;
|
|
import java.time.OffsetDateTime;
|
|
import java.util.Optional;
|
|
import lukehagar.plexapi.plexapi.PlexAPI;
|
|
import lukehagar.plexapi.plexapi.models.operations.*;
|
|
import lukehagar.plexapi.plexapi.models.shared.*;
|
|
import lukehagar.plexapi.plexapi.utils.EventStream;
|
|
import org.openapitools.jackson.nullable.JsonNullable;
|
|
import static java.util.Map.entry;
|
|
|
|
public class Application {
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
try {
|
|
PlexAPI sdk = PlexAPI.builder()
|
|
.xPlexClientIdentifier("Postman")
|
|
.build();
|
|
|
|
GetTokenResponse res = sdk.plex().getToken()
|
|
.pinID("<value>")
|
|
.xPlexClientIdentifier("Postman")
|
|
.call();
|
|
|
|
if (res.object().isPresent()) {
|
|
// handle response
|
|
}
|
|
} catch (lukehagar.plexapi.plexapi.models.errors.GetTokenResponseBody e) {
|
|
// handle exception
|
|
throw e;
|
|
} catch (lukehagar.plexapi.plexapi.models.errors.SDKError e) {
|
|
// handle exception
|
|
throw e;
|
|
} catch (Exception e) {
|
|
// handle exception
|
|
throw e;
|
|
}
|
|
|
|
}
|
|
}
|
|
```
|
|
|
|
### Parameters
|
|
|
|
| Parameter | Type | Required | Description | Example |
|
|
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
| `pinID` | *String* | :heavy_check_mark: | The PinID to retrieve an access token for | |
|
|
| `xPlexClientIdentifier` | *Optional<? extends 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/> | Postman |
|
|
| `serverURL` | *String* | :heavy_minus_sign: | An optional server URL to use. | http://localhost:8080 |
|
|
|
|
|
|
### Response
|
|
|
|
**[lukehagar.plexapi.plexapi.models.operations.GetTokenResponse](../../models/operations/GetTokenResponse.md)**
|
|
### Errors
|
|
|
|
| Error Object | Status Code | Content Type |
|
|
| ---------------------------------- | ---------------------------------- | ---------------------------------- |
|
|
| models/errors/GetTokenResponseBody | 400 | application/json |
|
|
| models/errors/SDKError | 4xx-5xx | \*\/* |
|