30 KiB
Plex
(Plex)
Overview
API Calls that perform operations directly against https://Plex.tv
Available Operations
- GetCompanionsData - Get Companions Data
- GetUserFriends - Get list of friends of the user logged in
- GetGeoData - Get Geo Data
- GetHomeData - Get Plex Home Data
- GetServerResources - Get Server Resources
- GetPin - Get a Pin
- GetTokenByPinID - Get Access Token by PinId
GetCompanionsData
Get Companions Data
Example Usage
package main
import(
"github.com/LukeHagar/plexgo"
"context"
"log"
)
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("gcgzw5rz2xovp84b4vha3a40"),
)
ctx := context.Background()
res, err := s.Plex.GetCompanionsData(ctx)
if err != nil {
log.Fatal(err)
}
if res.ResponseBodies != nil {
// handle response
}
}
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
Response
*operations.GetCompanionsDataResponse, error
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| sdkerrors.GetCompanionsDataBadRequest | 400 | application/json |
| sdkerrors.GetCompanionsDataUnauthorized | 401 | application/json |
| sdkerrors.SDKError | 4xx-5xx | / |
GetUserFriends
Get friends of provided auth token.
Example Usage
package main
import(
"github.com/LukeHagar/plexgo"
"context"
"log"
)
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("gcgzw5rz2xovp84b4vha3a40"),
)
ctx := context.Background()
res, err := s.Plex.GetUserFriends(ctx)
if err != nil {
log.Fatal(err)
}
if res.Friends != nil {
// handle response
}
}
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
Response
*operations.GetUserFriendsResponse, error
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| sdkerrors.GetUserFriendsBadRequest | 400 | application/json |
| sdkerrors.GetUserFriendsUnauthorized | 401 | application/json |
| sdkerrors.SDKError | 4xx-5xx | / |
GetGeoData
Returns the geolocation and locale data of the caller
Example Usage
package main
import(
"github.com/LukeHagar/plexgo"
"context"
"log"
)
func main() {
s := plexgo.New(
plexgo.WithXPlexClientIdentifier("gcgzw5rz2xovp84b4vha3a40"),
)
ctx := context.Background()
res, err := s.Plex.GetGeoData(ctx)
if err != nil {
log.Fatal(err)
}
if res.GeoData != nil {
// handle response
}
}
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
Response
*operations.GetGeoDataResponse, error
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| sdkerrors.GetGeoDataBadRequest | 400 | application/json |
| sdkerrors.GetGeoDataUnauthorized | 401 | application/json |
| sdkerrors.SDKError | 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
package main
import(
"github.com/LukeHagar/plexgo"
"context"
"log"
)
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("gcgzw5rz2xovp84b4vha3a40"),
)
ctx := context.Background()
res, err := s.Plex.GetHomeData(ctx)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
Response
*operations.GetHomeDataResponse, error
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| sdkerrors.GetHomeDataBadRequest | 400 | application/json |
| sdkerrors.GetHomeDataUnauthorized | 401 | application/json |
| sdkerrors.SDKError | 4xx-5xx | / |
GetServerResources
Get Plex server access tokens and server connections
Example Usage
package main
import(
"github.com/LukeHagar/plexgo"
"context"
"github.com/LukeHagar/plexgo/models/operations"
"log"
)
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
plexgo.WithXPlexClientIdentifier("gcgzw5rz2xovp84b4vha3a40"),
)
ctx := context.Background()
res, err := s.Plex.GetServerResources(ctx, plexgo.String("gcgzw5rz2xovp84b4vha3a40"), operations.IncludeHTTPSOne.ToPointer(), operations.IncludeRelayOne.ToPointer(), operations.IncludeIPv6One.ToPointer())
if err != nil {
log.Fatal(err)
}
if res.PlexDevices != nil {
// handle response
}
}
Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. | |
xPlexClientIdentifier |
*string | ➖ | 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) |
gcgzw5rz2xovp84b4vha3a40 |
includeHTTPS |
*operations.IncludeHTTPS | ➖ | Include Https entries in the results | 1 |
includeRelay |
*operations.IncludeRelay | ➖ | Include Relay addresses in the results E.g: https://10-0-0-25.bbf8e10c7fa20447cacee74cd9914cde.plex.direct:32400 |
1 |
includeIPv6 |
*operations.IncludeIPv6 | ➖ | Include IPv6 entries in the results | 1 |
opts |
[]operations.Option | ➖ | The options for this request. |
Response
*operations.GetServerResourcesResponse, error
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| sdkerrors.GetServerResourcesBadRequest | 400 | application/json |
| sdkerrors.GetServerResourcesUnauthorized | 401 | application/json |
| sdkerrors.SDKError | 4xx-5xx | / |
GetPin
Retrieve a Pin from Plex.tv for authentication flows
Example Usage
package main
import(
"github.com/LukeHagar/plexgo"
"context"
"log"
)
func main() {
s := plexgo.New(
plexgo.WithXPlexClientIdentifier("gcgzw5rz2xovp84b4vha3a40"),
)
ctx := context.Background()
res, err := s.Plex.GetPin(ctx, nil, plexgo.String("gcgzw5rz2xovp84b4vha3a40"), plexgo.String("Plex Web"))
if err != nil {
log.Fatal(err)
}
if res.AuthPinContainer != nil {
// handle response
}
}
Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. | |
strong |
*bool | ➖ | 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 |
*string | ➖ | 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) |
gcgzw5rz2xovp84b4vha3a40 |
xPlexProduct |
*string | ➖ | N/A | Plex Web |
opts |
[]operations.Option | ➖ | The options for this request. |
Response
*operations.GetPinResponse, error
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| sdkerrors.GetPinBadRequest | 400 | application/json |
| sdkerrors.SDKError | 4xx-5xx | / |
GetTokenByPinID
Retrieve an Access Token from Plex.tv after the Pin has been authenticated
Example Usage
package main
import(
"github.com/LukeHagar/plexgo"
"context"
"log"
)
func main() {
s := plexgo.New(
plexgo.WithXPlexClientIdentifier("gcgzw5rz2xovp84b4vha3a40"),
)
ctx := context.Background()
res, err := s.Plex.GetTokenByPinID(ctx, 408895, plexgo.String("gcgzw5rz2xovp84b4vha3a40"))
if err != nil {
log.Fatal(err)
}
if res.AuthPinContainer != nil {
// handle response
}
}
Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. | |
pinID |
int64 | ✔️ | The PinID to retrieve an access token for | |
xPlexClientIdentifier |
*string | ➖ | 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) |
gcgzw5rz2xovp84b4vha3a40 |
opts |
[]operations.Option | ➖ | The options for this request. |
Response
*operations.GetTokenByPinIDResponse, error
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| sdkerrors.GetTokenByPinIDBadRequest | 400 | application/json |
| sdkerrors.GetTokenByPinIDResponseBody | 404 | application/json |
| sdkerrors.SDKError | 4xx-5xx | / |