Files
plexjava/docs/sdks/sessions
2024-07-01 16:03:10 +00:00
..
2024-07-01 16:03:10 +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 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();

            GetSessionsResponse res = sdk.sessions().getSessions()
                .call();

            if (res.object().isPresent()) {
                // handle response
            }
        } catch (lukehagar.plexapi.plexapi.models.errors.GetSessionsResponseBody 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.GetSessionsResponse

Errors

Error Object Status Code Content Type
models/errors/GetSessionsResponseBody 401 application/json
models/errors/SDKError 4xx-5xx */*

getSessionHistory

This will Retrieve a listing of all history views.

Example Usage

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();

            GetSessionHistoryResponse res = sdk.sessions().getSessionHistory()
                .sort("<value>")
                .accountId(1L)
                .filter(Filter.builder()
                    .build())
                .librarySectionID(12L)
                .call();

            if (res.object().isPresent()) {
                // handle response
            }
        } catch (lukehagar.plexapi.plexapi.models.errors.GetSessionHistoryResponseBody 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
sort Optional<? extends String> Sorts the results by the specified field followed by the direction (asc, desc)
accountId Optional<? extends Long> Filter results by those that are related to a specific users id
1
filter Optional<? extends lukehagar.plexapi.plexapi.models.operations.Filter> 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 Optional<? extends Long> Filters the results based on the id of a valid library section
12

Response

lukehagar.plexapi.plexapi.models.operations.GetSessionHistoryResponse

Errors

Error Object Status Code Content Type
models/errors/GetSessionHistoryResponseBody 401 application/json
models/errors/SDKError 4xx-5xx */*

getTranscodeSessions

Get Transcode Sessions

Example Usage

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();

            GetTranscodeSessionsResponse res = sdk.sessions().getTranscodeSessions()
                .call();

            if (res.object().isPresent()) {
                // handle response
            }
        } catch (lukehagar.plexapi.plexapi.models.errors.GetTranscodeSessionsResponseBody 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.GetTranscodeSessionsResponse

Errors

Error Object Status Code Content Type
models/errors/GetTranscodeSessionsResponseBody 401 application/json
models/errors/SDKError 4xx-5xx */*

stopTranscodeSession

Stop a Transcode Session

Example Usage

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();

            StopTranscodeSessionResponse res = sdk.sessions().stopTranscodeSession()
                .sessionKey("zz7llzqlx8w9vnrsbnwhbmep")
                .call();

            // handle response
        } catch (lukehagar.plexapi.plexapi.models.errors.StopTranscodeSessionResponseBody 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
sessionKey String ✔️ the Key of the transcode session to stop zz7llzqlx8w9vnrsbnwhbmep

Response

lukehagar.plexapi.plexapi.models.operations.StopTranscodeSessionResponse

Errors

Error Object Status Code Content Type
models/errors/StopTranscodeSessionResponseBody 401 application/json
models/errors/SDKError 4xx-5xx */*