Files
plexgo/docs/sdks/plex

Plex

(Plex)

Overview

API Calls that perform operations directly against https://Plex.tv

Available Operations

GetCompanionsData

Get Companions Data

Example Usage

package main

import(
	"context"
	"github.com/LukeHagar/plexgo"
	"log"
)

func main() {
    ctx := context.Background()

    s := plexgo.New(
        plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
    )

    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 Type 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(
	"context"
	"github.com/LukeHagar/plexgo"
	"log"
)

func main() {
    ctx := context.Background()

    s := plexgo.New(
        plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
    )

    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 Type 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(
	"context"
	"github.com/LukeHagar/plexgo"
	"log"
)

func main() {
    ctx := context.Background()

    s := plexgo.New()

    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 Type 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(
	"context"
	"github.com/LukeHagar/plexgo"
	"log"
)

func main() {
    ctx := context.Background()

    s := plexgo.New(
        plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
    )

    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 Type 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(
	"context"
	"github.com/LukeHagar/plexgo"
	"github.com/LukeHagar/plexgo/models/operations"
	"log"
)

func main() {
    ctx := context.Background()

    s := plexgo.New(
        plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
    )

    res, err := s.Plex.GetServerResources(ctx, "3381b62b-9ab7-4e37-827b-203e9809eb58", operations.IncludeHTTPSEnable.ToPointer(), operations.IncludeRelayEnable.ToPointer(), operations.IncludeIPv6Enable.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.
clientID string ✔️ An opaque identifier unique to the client (UUID, serial number, or other unique device ID) 3381b62b-9ab7-4e37-827b-203e9809eb58
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 Type Status Code Content Type
sdkerrors.GetServerResourcesBadRequest 400 application/json
sdkerrors.GetServerResourcesUnauthorized 401 application/json
sdkerrors.SDKError 4XX, 5XX */*

GetPin

Retrieve a Pin ID from Plex.tv to use for authentication flows

Example Usage

package main

import(
	"context"
	"github.com/LukeHagar/plexgo"
	"github.com/LukeHagar/plexgo/models/operations"
	"log"
)

func main() {
    ctx := context.Background()

    s := plexgo.New()

    res, err := s.Plex.GetPin(ctx, operations.GetPinRequest{
        ClientID: "3381b62b-9ab7-4e37-827b-203e9809eb58",
        ClientName: plexgo.Pointer("Plex for Roku"),
        DeviceNickname: plexgo.Pointer("Roku 3"),
        ClientVersion: plexgo.Pointer("2.4.1"),
        Platform: plexgo.Pointer("Roku"),
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.AuthPinContainer != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.GetPinRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.GetPinResponse, error

Errors

Error Type 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(
	"context"
	"github.com/LukeHagar/plexgo"
	"github.com/LukeHagar/plexgo/models/operations"
	"log"
)

func main() {
    ctx := context.Background()

    s := plexgo.New()

    res, err := s.Plex.GetTokenByPinID(ctx, operations.GetTokenByPinIDRequest{
        PinID: 232248,
        ClientID: "3381b62b-9ab7-4e37-827b-203e9809eb58",
        ClientName: plexgo.Pointer("Plex for Roku"),
        DeviceNickname: plexgo.Pointer("Roku 3"),
        ClientVersion: plexgo.Pointer("2.4.1"),
        Platform: plexgo.Pointer("Roku"),
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.AuthPinContainer != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.GetTokenByPinIDRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.GetTokenByPinIDResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.GetTokenByPinIDBadRequest 400 application/json
sdkerrors.GetTokenByPinIDResponseBody 404 application/json
sdkerrors.SDKError 4XX, 5XX */*