# 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("") .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* | :heavy_minus_sign: | Determines the kind of code returned by the API call
Strong codes are used for Pin authentication flows
Non-Strong codes are used for `Plex.tv/link`
| | | `xPlexClientIdentifier` | *Optional* | :heavy_minus_sign: | 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)
| Postman | | `xPlexProduct` | *String* | :heavy_check_mark: | Product name of the application shown in the list of devices
| 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("") .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* | :heavy_minus_sign: | 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)
| 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 | \*\/* |