Files
plexgo/docs/sdks/sessions
2024-09-09 18:15:22 +00:00
..
2024-09-09 18:15:22 +00:00

Sessions

(Sessions)

Overview

API Calls that perform search operations with Plex Media Server Sessions

Available Operations

GetSessions

This will retrieve the "Now Playing" Information of the PMS.

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.Sessions.GetSessions(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.GetSessionsResponse, error

Errors

Error Object Status Code Content Type
sdkerrors.GetSessionsResponseBody 400 application/json
sdkerrors.GetSessionsSessionsResponseBody 401 application/json
sdkerrors.SDKError 4xx-5xx /

GetSessionHistory

This will Retrieve a listing of all history views.

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.Sessions.GetSessionHistory(ctx, plexgo.String("viewedAt:desc"), plexgo.Int64(1), &operations.QueryParamFilter{}, plexgo.Int64(12))
    if err != nil {
        log.Fatal(err)
    }
    if res.Object != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description Example
ctx context.Context ✔️ The context to use for the request.
sort *string Sorts the results by the specified field followed by the direction (asc, desc)
accountID *int64 Filter results by those that are related to a specific users id
1
filter *operations.QueryParamFilter Filters content by field and direction/equality
(Unknown if viewedAt is the only supported column)
{
"viewed-at-greater-than": {
"value": "viewedAt\u003e"
},
"viewed-at-greater-than-or-equal-to": {
"value": "viewedAt\u003e=\u003e"
},
"viewed-at-less-than": {
"value": "viewedAt\u003c"
}
}
librarySectionID *int64 Filters the results based on the id of a valid library section
12
opts []operations.Option The options for this request.

Response

*operations.GetSessionHistoryResponse, error

Errors

Error Object Status Code Content Type
sdkerrors.GetSessionHistoryResponseBody 400 application/json
sdkerrors.GetSessionHistorySessionsResponseBody 401 application/json
sdkerrors.SDKError 4xx-5xx /

GetTranscodeSessions

Get Transcode Sessions

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.Sessions.GetTranscodeSessions(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.GetTranscodeSessionsResponse, error

Errors

Error Object Status Code Content Type
sdkerrors.GetTranscodeSessionsResponseBody 400 application/json
sdkerrors.GetTranscodeSessionsSessionsResponseBody 401 application/json
sdkerrors.SDKError 4xx-5xx /

StopTranscodeSession

Stop a Transcode Session

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.Sessions.StopTranscodeSession(ctx, "zz7llzqlx8w9vnrsbnwhbmep")
    if err != nil {
        log.Fatal(err)
    }
    if res != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description Example
ctx context.Context ✔️ The context to use for the request.
sessionKey string ✔️ the Key of the transcode session to stop zz7llzqlx8w9vnrsbnwhbmep
opts []operations.Option The options for this request.

Response

*operations.StopTranscodeSessionResponse, error

Errors

Error Object Status Code Content Type
sdkerrors.StopTranscodeSessionResponseBody 400 application/json
sdkerrors.StopTranscodeSessionSessionsResponseBody 401 application/json
sdkerrors.SDKError 4xx-5xx /