# Sessions (*sessions*) ## Overview API Calls that perform search operations with Plex Media Server Sessions ### Available Operations * [getSessions](#getsessions) - Get Active Sessions * [getSessionHistory](#getsessionhistory) - Get Session History * [getTranscodeSessions](#gettranscodesessions) - Get Transcode Sessions * [stopTranscodeSession](#stoptranscodesession) - Stop a Transcode Session ## getSessions This will retrieve the "Now Playing" Information of the PMS. ### Example Usage ```typescript import { PlexAPI } from "@lukehagar/plexjs"; const plexAPI = new PlexAPI({ accessToken: "", xPlexClientIdentifier: "Postman", }); async function run() { const result = await plexAPI.sessions.getSessions(); // Handle the result console.log(result) } run(); ``` ### Parameters | Parameter | Type | Required | Description | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. | | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | ### Response **Promise\<[models.GetSessionsResponse](../../models/getsessionsresponse.md)\>** ### Errors | Error Object | Status Code | Content Type | | -------------------------------------- | -------------------------------------- | -------------------------------------- | | models.GetSessionsSessionsResponseBody | 401 | application/json | | models.SDKError | 4xx-5xx | */* | ## getSessionHistory This will Retrieve a listing of all history views. ### Example Usage ```typescript import { PlexAPI } from "@lukehagar/plexjs"; const plexAPI = new PlexAPI({ accessToken: "", xPlexClientIdentifier: "Postman", }); async function run() { const result = await plexAPI.sessions.getSessionHistory(); // Handle the result console.log(result) } run(); ``` ### Parameters | Parameter | Type | Required | Description | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. | | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | ### Response **Promise\<[models.GetSessionHistoryResponse](../../models/getsessionhistoryresponse.md)\>** ### Errors | Error Object | Status Code | Content Type | | -------------------------------------------- | -------------------------------------------- | -------------------------------------------- | | models.GetSessionHistorySessionsResponseBody | 401 | application/json | | models.SDKError | 4xx-5xx | */* | ## getTranscodeSessions Get Transcode Sessions ### Example Usage ```typescript import { PlexAPI } from "@lukehagar/plexjs"; const plexAPI = new PlexAPI({ accessToken: "", xPlexClientIdentifier: "Postman", }); async function run() { const result = await plexAPI.sessions.getTranscodeSessions(); // Handle the result console.log(result) } run(); ``` ### Parameters | Parameter | Type | Required | Description | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. | | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | ### Response **Promise\<[models.GetTranscodeSessionsResponse](../../models/gettranscodesessionsresponse.md)\>** ### Errors | Error Object | Status Code | Content Type | | ----------------------------------------------- | ----------------------------------------------- | ----------------------------------------------- | | models.GetTranscodeSessionsSessionsResponseBody | 401 | application/json | | models.SDKError | 4xx-5xx | */* | ## stopTranscodeSession Stop a Transcode Session ### Example Usage ```typescript import { PlexAPI } from "@lukehagar/plexjs"; const plexAPI = new PlexAPI({ accessToken: "", xPlexClientIdentifier: "Postman", }); async function run() { const result = await plexAPI.sessions.stopTranscodeSession("zz7llzqlx8w9vnrsbnwhbmep"); // Handle the result console.log(result) } run(); ``` ### Parameters | Parameter | Type | Required | Description | Example | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `sessionKey` | *string* | :heavy_check_mark: | the Key of the transcode session to stop | [object Object] | | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. | | | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | ### Response **Promise\<[models.StopTranscodeSessionResponse](../../models/stoptranscodesessionresponse.md)\>** ### Errors | Error Object | Status Code | Content Type | | --------------------------------------- | --------------------------------------- | --------------------------------------- | | models.StopTranscodeSessionResponseBody | 401 | application/json | | models.SDKError | 4xx-5xx | */* |