Files
plexjava/docs/sdks/sessions/README.md

14 KiB
Raw Blame History

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 dev.plexapi.sdk.PlexAPI;
import dev.plexapi.sdk.models.errors.GetSessionsBadRequest;
import dev.plexapi.sdk.models.errors.GetSessionsUnauthorized;
import dev.plexapi.sdk.models.operations.GetSessionsResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws GetSessionsBadRequest, GetSessionsUnauthorized, Exception {

        PlexAPI sdk = PlexAPI.builder()
                .accessToken("<YOUR_API_KEY_HERE>")
                .clientID("3381b62b-9ab7-4e37-827b-203e9809eb58")
                .clientName("Plex for Roku")
                .clientVersion("2.4.1")
                .platform("Roku")
                .deviceNickname("Roku 3")
            .build();

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

        if (res.object().isPresent()) {
            // handle response
        }
    }
}

Response

GetSessionsResponse

Errors

Error Type Status Code Content Type
models/errors/GetSessionsBadRequest 400 application/json
models/errors/GetSessionsUnauthorized 401 application/json
models/errors/SDKError 4XX, 5XX */*

getSessionHistory

This will Retrieve a listing of all history views.

Example Usage

package hello.world;

import dev.plexapi.sdk.PlexAPI;
import dev.plexapi.sdk.models.errors.GetSessionHistoryBadRequest;
import dev.plexapi.sdk.models.errors.GetSessionHistoryUnauthorized;
import dev.plexapi.sdk.models.operations.GetSessionHistoryResponse;
import dev.plexapi.sdk.models.operations.QueryParamFilter;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws GetSessionHistoryBadRequest, GetSessionHistoryUnauthorized, Exception {

        PlexAPI sdk = PlexAPI.builder()
                .accessToken("<YOUR_API_KEY_HERE>")
                .clientID("3381b62b-9ab7-4e37-827b-203e9809eb58")
                .clientName("Plex for Roku")
                .clientVersion("2.4.1")
                .platform("Roku")
                .deviceNickname("Roku 3")
            .build();

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

        if (res.object().isPresent()) {
            // handle response
        }
    }
}

Parameters

Parameter Type Required Description Example
sort Optional<String> Sorts the results by the specified field followed by the direction (asc, desc)
accountId Optional<Long> Filter results by those that are related to a specific users id
1
filter Optional<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 Optional<Long> Filters the results based on the id of a valid library section
12

Response

GetSessionHistoryResponse

Errors

Error Type Status Code Content Type
models/errors/GetSessionHistoryBadRequest 400 application/json
models/errors/GetSessionHistoryUnauthorized 401 application/json
models/errors/SDKError 4XX, 5XX */*

getTranscodeSessions

Get Transcode Sessions

Example Usage

package hello.world;

import dev.plexapi.sdk.PlexAPI;
import dev.plexapi.sdk.models.errors.GetTranscodeSessionsBadRequest;
import dev.plexapi.sdk.models.errors.GetTranscodeSessionsUnauthorized;
import dev.plexapi.sdk.models.operations.GetTranscodeSessionsResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws GetTranscodeSessionsBadRequest, GetTranscodeSessionsUnauthorized, Exception {

        PlexAPI sdk = PlexAPI.builder()
                .accessToken("<YOUR_API_KEY_HERE>")
                .clientID("3381b62b-9ab7-4e37-827b-203e9809eb58")
                .clientName("Plex for Roku")
                .clientVersion("2.4.1")
                .platform("Roku")
                .deviceNickname("Roku 3")
            .build();

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

        if (res.object().isPresent()) {
            // handle response
        }
    }
}

Response

GetTranscodeSessionsResponse

Errors

Error Type Status Code Content Type
models/errors/GetTranscodeSessionsBadRequest 400 application/json
models/errors/GetTranscodeSessionsUnauthorized 401 application/json
models/errors/SDKError 4XX, 5XX */*

stopTranscodeSession

Stop a Transcode Session

Example Usage

package hello.world;

import dev.plexapi.sdk.PlexAPI;
import dev.plexapi.sdk.models.errors.StopTranscodeSessionBadRequest;
import dev.plexapi.sdk.models.errors.StopTranscodeSessionUnauthorized;
import dev.plexapi.sdk.models.operations.StopTranscodeSessionResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws StopTranscodeSessionBadRequest, StopTranscodeSessionUnauthorized, Exception {

        PlexAPI sdk = PlexAPI.builder()
                .accessToken("<YOUR_API_KEY_HERE>")
                .clientID("3381b62b-9ab7-4e37-827b-203e9809eb58")
                .clientName("Plex for Roku")
                .clientVersion("2.4.1")
                .platform("Roku")
                .deviceNickname("Roku 3")
            .build();

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

        // handle response
    }
}

Parameters

Parameter Type Required Description Example
sessionKey String ✔️ the Key of the transcode session to stop zz7llzqlx8w9vnrsbnwhbmep

Response

StopTranscodeSessionResponse

Errors

Error Type Status Code Content Type
models/errors/StopTranscodeSessionBadRequest 400 application/json
models/errors/StopTranscodeSessionUnauthorized 401 application/json
models/errors/SDKError 4XX, 5XX */*