(sessions)
API Calls that perform search operations with Plex Media Server Sessions
- get_sessions - Get Active Sessions
- get_session_history - Get Session History
- get_transcode_sessions - Get Transcode Sessions
- stop_transcode_session - Stop a Transcode Session
This will retrieve the "Now Playing" Information of the PMS.
from plex_api_client import PlexAPI
s = PlexAPI(
access_token="<YOUR_API_KEY_HERE>",
client_id="gcgzw5rz2xovp84b4vha3a40",
client_name="Plex Web",
client_version="4.133.0",
client_platform="Chrome",
device_name="Linux",
)
res = s.sessions.get_sessions()
if res.object is not None:
# handle response
pass
Parameter | Type | Required | Description |
---|---|---|---|
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
operations.GetSessionsResponse
Error Type | Status Code | Content Type |
---|---|---|
errors.GetSessionsBadRequest | 400 | application/json |
errors.GetSessionsUnauthorized | 401 | application/json |
errors.SDKError | 4XX, 5XX | */* |
This will Retrieve a listing of all history views.
from plex_api_client import PlexAPI
s = PlexAPI(
access_token="<YOUR_API_KEY_HERE>",
client_id="gcgzw5rz2xovp84b4vha3a40",
client_name="Plex Web",
client_version="4.133.0",
client_platform="Chrome",
device_name="Linux",
)
res = s.sessions.get_session_history(sort="viewedAt:desc", account_id=1, filter_={}, library_section_id=12)
if res.object is not None:
# handle response
pass
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
sort |
Optional[str] | ➖ | Sorts the results by the specified field followed by the direction (asc, desc) |
|
account_id |
Optional[int] | ➖ | Filter results by those that are related to a specific users id |
1 |
filter_ |
Optional[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" } } |
library_section_id |
Optional[int] | ➖ | Filters the results based on the id of a valid library section |
12 |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
operations.GetSessionHistoryResponse
Error Type | Status Code | Content Type |
---|---|---|
errors.GetSessionHistoryBadRequest | 400 | application/json |
errors.GetSessionHistoryUnauthorized | 401 | application/json |
errors.SDKError | 4XX, 5XX | */* |
Get Transcode Sessions
from plex_api_client import PlexAPI
s = PlexAPI(
access_token="<YOUR_API_KEY_HERE>",
client_id="gcgzw5rz2xovp84b4vha3a40",
client_name="Plex Web",
client_version="4.133.0",
client_platform="Chrome",
device_name="Linux",
)
res = s.sessions.get_transcode_sessions()
if res.object is not None:
# handle response
pass
Parameter | Type | Required | Description |
---|---|---|---|
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
operations.GetTranscodeSessionsResponse
Error Type | Status Code | Content Type |
---|---|---|
errors.GetTranscodeSessionsBadRequest | 400 | application/json |
errors.GetTranscodeSessionsUnauthorized | 401 | application/json |
errors.SDKError | 4XX, 5XX | */* |
Stop a Transcode Session
from plex_api_client import PlexAPI
s = PlexAPI(
access_token="<YOUR_API_KEY_HERE>",
client_id="gcgzw5rz2xovp84b4vha3a40",
client_name="Plex Web",
client_version="4.133.0",
client_platform="Chrome",
device_name="Linux",
)
res = s.sessions.stop_transcode_session(session_key="zz7llzqlx8w9vnrsbnwhbmep")
if res is not None:
# handle response
pass
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
session_key |
str | ✔️ | the Key of the transcode session to stop | zz7llzqlx8w9vnrsbnwhbmep |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
operations.StopTranscodeSessionResponse
Error Type | Status Code | Content Type |
---|---|---|
errors.StopTranscodeSessionBadRequest | 400 | application/json |
errors.StopTranscodeSessionUnauthorized | 401 | application/json |
errors.SDKError | 4XX, 5XX | */* |