{"id":16633528,"url":"https://github.com/lukehagar/plexjs","last_synced_at":"2025-03-16T22:31:03.436Z","repository":{"id":151821695,"uuid":"624673035","full_name":"LukeHagar/plexjs","owner":"LukeHagar","description":"A Typescript SDK for interacting with Plex Media Server","archived":false,"fork":false,"pushed_at":"2025-03-09T00:10:58.000Z","size":40337,"stargazers_count":32,"open_issues_count":12,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-16T01:17:34.913Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LukeHagar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-07T01:56:42.000Z","updated_at":"2025-03-13T17:47:59.000Z","dependencies_parsed_at":null,"dependency_job_id":"cca1faac-bc18-4fae-879b-113dae9c7012","html_url":"https://github.com/LukeHagar/plexjs","commit_stats":null,"previous_names":[],"tags_count":110,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LukeHagar%2Fplexjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LukeHagar%2Fplexjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LukeHagar%2Fplexjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LukeHagar%2Fplexjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LukeHagar","download_url":"https://codeload.github.com/LukeHagar/plexjs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243830952,"owners_count":20354854,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-12T05:23:56.032Z","updated_at":"2025-03-16T22:31:03.422Z","avatar_url":"https://github.com/LukeHagar.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @lukehagar/plexjs\n\n\u003cdiv align=\"left\"\u003e\n    \u003ca href=\"https://speakeasyapi.dev/\"\u003e\u003cimg src=\"https://custom-icon-badges.demolab.com/badge/-Built%20By%20Speakeasy-212015?style=for-the-badge\u0026logoColor=FBE331\u0026logo=speakeasy\u0026labelColor=545454\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://opensource.org/licenses/MIT\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/License-MIT-blue.svg\" style=\"width: 100px; height: 28px;\" /\u003e\n    \u003c/a\u003e\n\u003c/div\u003e\n\n\u003c!-- Start Summary [summary] --\u003e\n## Summary\n\nPlex-API: An Open API Spec for interacting with Plex.tv and Plex Media Server\n\n# Plex Media Server OpenAPI Specification\n\nAn Open Source OpenAPI Specification for Plex Media Server\n\nAutomation and SDKs provided by [Speakeasy](https://speakeasyapi.dev/)\n\n## Documentation\n\n[API Documentation](https://plexapi.dev)\n\n## SDKs\n\nThe following SDKs are generated from the OpenAPI Specification. They are automatically generated and may not be fully tested. If you find any issues, please open an issue on the [main specification Repository](https://github.com/LukeHagar/plex-api-spec).\n\n| Language              | Repository                                        | Releases                                                                                         | Other                                                   |\n| --------------------- | ------------------------------------------------- | ------------------------------------------------------------------------------------------------ | ------------------------------------------------------- |\n| Python                | [GitHub](https://github.com/LukeHagar/plexpy)     | [PyPI](https://pypi.org/project/plex-api-client/)                                                | -                                                       |\n| JavaScript/TypeScript | [GitHub](https://github.com/LukeHagar/plexjs)     | [NPM](https://www.npmjs.com/package/@lukehagar/plexjs) \\ [JSR](https://jsr.io/@lukehagar/plexjs) | -                                                       |\n| Go                    | [GitHub](https://github.com/LukeHagar/plexgo)     | [Releases](https://github.com/LukeHagar/plexgo/releases)                                         | [GoDoc](https://pkg.go.dev/github.com/LukeHagar/plexgo) |\n| Ruby                  | [GitHub](https://github.com/LukeHagar/plexruby)   | [Releases](https://github.com/LukeHagar/plexruby/releases)                                       | -                                                       |\n| Swift                 | [GitHub](https://github.com/LukeHagar/plexswift)  | [Releases](https://github.com/LukeHagar/plexswift/releases)                                      | -                                                       |\n| PHP                   | [GitHub](https://github.com/LukeHagar/plexphp)    | [Releases](https://github.com/LukeHagar/plexphp/releases)                                        | -                                                       |\n| Java                  | [GitHub](https://github.com/LukeHagar/plexjava)   | [Releases](https://github.com/LukeHagar/plexjava/releases)                                       | -                                                       |\n| C#                    | [GitHub](https://github.com/LukeHagar/plexcsharp) | [Releases](https://github.com/LukeHagar/plexcsharp/releases)                                     | -\n\u003c!-- End Summary [summary] --\u003e\n\n\u003c!-- Start Table of Contents [toc] --\u003e\n## Table of Contents\n\u003c!-- $toc-max-depth=2 --\u003e\n* [@lukehagar/plexjs](#lukehagarplexjs)\n* [Plex Media Server OpenAPI Specification](#plex-media-server-openapi-specification)\n  * [Documentation](#documentation)\n  * [SDKs](#sdks)\n  * [SDK Installation](#sdk-installation)\n  * [SDK Example Usage](#sdk-example-usage)\n  * [Available Resources and Operations](#available-resources-and-operations)\n  * [Error Handling](#error-handling)\n  * [Server Selection](#server-selection)\n  * [Custom HTTP Client](#custom-http-client)\n  * [Authentication](#authentication)\n  * [Requirements](#requirements)\n  * [Standalone functions](#standalone-functions)\n  * [Retries](#retries)\n  * [Debugging](#debugging)\n* [Development](#development)\n  * [Maturity](#maturity)\n  * [Contributions](#contributions)\n\n\u003c!-- End Table of Contents [toc] --\u003e\n\n\u003c!-- Start SDK Installation [installation] --\u003e\n## SDK Installation\n\nThe SDK can be installed with either [npm](https://www.npmjs.com/), [pnpm](https://pnpm.io/), [bun](https://bun.sh/) or [yarn](https://classic.yarnpkg.com/en/) package managers.\n\n### NPM\n\n```bash\nnpm add @lukehagar/plexjs\n```\n\n### PNPM\n\n```bash\npnpm add @lukehagar/plexjs\n```\n\n### Bun\n\n```bash\nbun add @lukehagar/plexjs\n```\n\n### Yarn\n\n```bash\nyarn add @lukehagar/plexjs zod\n\n# Note that Yarn does not install peer dependencies automatically. You will need\n# to install zod as shown above.\n```\n\u003c!-- End SDK Installation [installation] --\u003e\n\n\u003c!-- Start SDK Example Usage [usage] --\u003e\n## SDK Example Usage\n\n### Example\n\n```typescript\nimport { PlexAPI } from \"@lukehagar/plexjs\";\n\nconst plexAPI = new PlexAPI({\n  accessToken: \"\u003cYOUR_API_KEY_HERE\u003e\",\n});\n\nasync function run() {\n  const result = await plexAPI.server.getServerCapabilities();\n\n  // Handle the result\n  console.log(result);\n}\n\nrun();\n\n```\n\u003c!-- End SDK Example Usage [usage] --\u003e\n\n\u003c!-- Start Available Resources and Operations [operations] --\u003e\n## Available Resources and Operations\n\n\u003cdetails open\u003e\n\u003csummary\u003eAvailable methods\u003c/summary\u003e\n\n### [activities](docs/sdks/activities/README.md)\n\n* [getServerActivities](docs/sdks/activities/README.md#getserveractivities) - Get Server Activities\n* [cancelServerActivities](docs/sdks/activities/README.md#cancelserveractivities) - Cancel Server Activities\n\n### [authentication](docs/sdks/authentication/README.md)\n\n* [getTransientToken](docs/sdks/authentication/README.md#gettransienttoken) - Get a Transient Token\n* [getSourceConnectionInformation](docs/sdks/authentication/README.md#getsourceconnectioninformation) - Get Source Connection Information\n* [getTokenDetails](docs/sdks/authentication/README.md#gettokendetails) - Get Token Details\n* [postUsersSignInData](docs/sdks/authentication/README.md#postuserssignindata) - Get User Sign In Data\n\n### [butler](docs/sdks/butler/README.md)\n\n* [getButlerTasks](docs/sdks/butler/README.md#getbutlertasks) - Get Butler tasks\n* [startAllTasks](docs/sdks/butler/README.md#startalltasks) - Start all Butler tasks\n* [stopAllTasks](docs/sdks/butler/README.md#stopalltasks) - Stop all Butler tasks\n* [startTask](docs/sdks/butler/README.md#starttask) - Start a single Butler task\n* [stopTask](docs/sdks/butler/README.md#stoptask) - Stop a single Butler task\n\n### [hubs](docs/sdks/hubs/README.md)\n\n* [getGlobalHubs](docs/sdks/hubs/README.md#getglobalhubs) - Get Global Hubs\n* [getRecentlyAdded](docs/sdks/hubs/README.md#getrecentlyadded) - Get Recently Added\n* [getLibraryHubs](docs/sdks/hubs/README.md#getlibraryhubs) - Get library specific hubs\n\n### [library](docs/sdks/library/README.md)\n\n* [getFileHash](docs/sdks/library/README.md#getfilehash) - Get Hash Value\n* [getRecentlyAddedLibrary](docs/sdks/library/README.md#getrecentlyaddedlibrary) - Get Recently Added\n* [getAllLibraries](docs/sdks/library/README.md#getalllibraries) - Get All Libraries\n* [getLibraryDetails](docs/sdks/library/README.md#getlibrarydetails) - Get Library Details\n* [deleteLibrary](docs/sdks/library/README.md#deletelibrary) - Delete Library Section\n* [getLibraryItems](docs/sdks/library/README.md#getlibraryitems) - Get Library Items\n* [getAllMediaLibrary](docs/sdks/library/README.md#getallmedialibrary) - Get all media of library\n* [getRefreshLibraryMetadata](docs/sdks/library/README.md#getrefreshlibrarymetadata) - Refresh Metadata Of The Library\n* [getSearchLibrary](docs/sdks/library/README.md#getsearchlibrary) - Search Library\n* [getGenresLibrary](docs/sdks/library/README.md#getgenreslibrary) - Get Genres of library media\n* [getCountriesLibrary](docs/sdks/library/README.md#getcountrieslibrary) - Get Countries of library media\n* [getActorsLibrary](docs/sdks/library/README.md#getactorslibrary) - Get Actors of library media\n* [getSearchAllLibraries](docs/sdks/library/README.md#getsearchalllibraries) - Search All Libraries\n* [getMediaMetaData](docs/sdks/library/README.md#getmediametadata) - Get Media Metadata\n* [getMetadataChildren](docs/sdks/library/README.md#getmetadatachildren) - Get Items Children\n* [getTopWatchedContent](docs/sdks/library/README.md#gettopwatchedcontent) - Get Top Watched Content\n\n### [log](docs/sdks/log/README.md)\n\n* [logLine](docs/sdks/log/README.md#logline) - Logging a single line message.\n* [logMultiLine](docs/sdks/log/README.md#logmultiline) - Logging a multi-line message\n* [enablePaperTrail](docs/sdks/log/README.md#enablepapertrail) - Enabling Papertrail\n\n### [media](docs/sdks/media/README.md)\n\n* [markPlayed](docs/sdks/media/README.md#markplayed) - Mark Media Played\n* [markUnplayed](docs/sdks/media/README.md#markunplayed) - Mark Media Unplayed\n* [updatePlayProgress](docs/sdks/media/README.md#updateplayprogress) - Update Media Play Progress\n* [getBannerImage](docs/sdks/media/README.md#getbannerimage) - Get Banner Image\n* [getThumbImage](docs/sdks/media/README.md#getthumbimage) - Get Thumb Image\n\n### [playlists](docs/sdks/playlists/README.md)\n\n* [createPlaylist](docs/sdks/playlists/README.md#createplaylist) - Create a Playlist\n* [getPlaylists](docs/sdks/playlists/README.md#getplaylists) - Get All Playlists\n* [getPlaylist](docs/sdks/playlists/README.md#getplaylist) - Retrieve Playlist\n* [deletePlaylist](docs/sdks/playlists/README.md#deleteplaylist) - Deletes a Playlist\n* [updatePlaylist](docs/sdks/playlists/README.md#updateplaylist) - Update a Playlist\n* [getPlaylistContents](docs/sdks/playlists/README.md#getplaylistcontents) - Retrieve Playlist Contents\n* [clearPlaylistContents](docs/sdks/playlists/README.md#clearplaylistcontents) - Delete Playlist Contents\n* [addPlaylistContents](docs/sdks/playlists/README.md#addplaylistcontents) - Adding to a Playlist\n* [uploadPlaylist](docs/sdks/playlists/README.md#uploadplaylist) - Upload Playlist\n\n### [plex](docs/sdks/plex/README.md)\n\n* [getCompanionsData](docs/sdks/plex/README.md#getcompanionsdata) - Get Companions Data\n* [getUserFriends](docs/sdks/plex/README.md#getuserfriends) - Get list of friends of the user logged in\n* [getGeoData](docs/sdks/plex/README.md#getgeodata) - Get Geo Data\n* [getHomeData](docs/sdks/plex/README.md#gethomedata) - Get Plex Home Data\n* [getServerResources](docs/sdks/plex/README.md#getserverresources) - Get Server Resources\n* [getPin](docs/sdks/plex/README.md#getpin) - Get a Pin\n* [getTokenByPinId](docs/sdks/plex/README.md#gettokenbypinid) - Get Access Token by PinId\n\n\n### [search](docs/sdks/search/README.md)\n\n* [performSearch](docs/sdks/search/README.md#performsearch) - Perform a search\n* [performVoiceSearch](docs/sdks/search/README.md#performvoicesearch) - Perform a voice search\n* [getSearchResults](docs/sdks/search/README.md#getsearchresults) - Get Search Results\n\n### [server](docs/sdks/server/README.md)\n\n* [getServerCapabilities](docs/sdks/server/README.md#getservercapabilities) - Get Server Capabilities\n* [getServerPreferences](docs/sdks/server/README.md#getserverpreferences) - Get Server Preferences\n* [getAvailableClients](docs/sdks/server/README.md#getavailableclients) - Get Available Clients\n* [getDevices](docs/sdks/server/README.md#getdevices) - Get Devices\n* [getServerIdentity](docs/sdks/server/README.md#getserveridentity) - Get Server Identity\n* [getMyPlexAccount](docs/sdks/server/README.md#getmyplexaccount) - Get MyPlex Account\n* [getResizedPhoto](docs/sdks/server/README.md#getresizedphoto) - Get a Resized Photo\n* [getMediaProviders](docs/sdks/server/README.md#getmediaproviders) - Get Media Providers\n* [getServerList](docs/sdks/server/README.md#getserverlist) - Get Server List\n\n### [sessions](docs/sdks/sessions/README.md)\n\n* [getSessions](docs/sdks/sessions/README.md#getsessions) - Get Active Sessions\n* [getSessionHistory](docs/sdks/sessions/README.md#getsessionhistory) - Get Session History\n* [getTranscodeSessions](docs/sdks/sessions/README.md#gettranscodesessions) - Get Transcode Sessions\n* [stopTranscodeSession](docs/sdks/sessions/README.md#stoptranscodesession) - Stop a Transcode Session\n\n### [statistics](docs/sdks/statistics/README.md)\n\n* [getStatistics](docs/sdks/statistics/README.md#getstatistics) - Get Media Statistics\n* [getResourcesStatistics](docs/sdks/statistics/README.md#getresourcesstatistics) - Get Resources Statistics\n* [getBandwidthStatistics](docs/sdks/statistics/README.md#getbandwidthstatistics) - Get Bandwidth Statistics\n\n### [updater](docs/sdks/updater/README.md)\n\n* [getUpdateStatus](docs/sdks/updater/README.md#getupdatestatus) - Querying status of updates\n* [checkForUpdates](docs/sdks/updater/README.md#checkforupdates) - Checking for updates\n* [applyUpdates](docs/sdks/updater/README.md#applyupdates) - Apply Updates\n\n### [users](docs/sdks/users/README.md)\n\n* [getUsers](docs/sdks/users/README.md#getusers) - Get list of all connected users\n\n### [video](docs/sdks/video/README.md)\n\n* [getTimeline](docs/sdks/video/README.md#gettimeline) - Get the timeline for a media item\n* [startUniversalTranscode](docs/sdks/video/README.md#startuniversaltranscode) - Start Universal Transcode\n\n### [watchlist](docs/sdks/watchlist/README.md)\n\n* [getWatchList](docs/sdks/watchlist/README.md#getwatchlist) - Get User Watchlist\n\n\u003c/details\u003e\n\u003c!-- End Available Resources and Operations [operations] --\u003e\n\n\u003c!-- Start Error Handling [errors] --\u003e\n## Error Handling\n\nSome methods specify known errors which can be thrown. All the known errors are enumerated in the `sdk/models/errors/errors.ts` module. The known errors for a method are documented under the *Errors* tables in SDK docs. For example, the `getServerCapabilities` method may throw the following errors:\n\n| Error Type                               | Status Code | Content Type     |\n| ---------------------------------------- | ----------- | ---------------- |\n| errors.GetServerCapabilitiesBadRequest   | 400         | application/json |\n| errors.GetServerCapabilitiesUnauthorized | 401         | application/json |\n| errors.SDKError                          | 4XX, 5XX    | \\*/\\*            |\n\nIf the method throws an error and it is not captured by the known errors, it will default to throwing a `SDKError`.\n\n```typescript\nimport { PlexAPI } from \"@lukehagar/plexjs\";\nimport {\n  GetServerCapabilitiesBadRequest,\n  GetServerCapabilitiesUnauthorized,\n  SDKValidationError,\n} from \"@lukehagar/plexjs/sdk/models/errors\";\n\nconst plexAPI = new PlexAPI({\n  accessToken: \"\u003cYOUR_API_KEY_HERE\u003e\",\n});\n\nasync function run() {\n  let result;\n  try {\n    result = await plexAPI.server.getServerCapabilities();\n\n    // Handle the result\n    console.log(result);\n  } catch (err) {\n    switch (true) {\n      // The server response does not match the expected SDK schema\n      case (err instanceof SDKValidationError): {\n        // Pretty-print will provide a human-readable multi-line error message\n        console.error(err.pretty());\n        // Raw value may also be inspected\n        console.error(err.rawValue);\n        return;\n      }\n      case (err instanceof GetServerCapabilitiesBadRequest): {\n        // Handle err.data$: GetServerCapabilitiesBadRequestData\n        console.error(err);\n        return;\n      }\n      case (err instanceof GetServerCapabilitiesUnauthorized): {\n        // Handle err.data$: GetServerCapabilitiesUnauthorizedData\n        console.error(err);\n        return;\n      }\n      default: {\n        // Other errors such as network errors, see HTTPClientErrors for more details\n        throw err;\n      }\n    }\n  }\n}\n\nrun();\n\n```\n\nValidation errors can also occur when either method arguments or data returned from the server do not match the expected format. The `SDKValidationError` that is thrown as a result will capture the raw value that failed validation in an attribute called `rawValue`. Additionally, a `pretty()` method is available on this error that can be used to log a nicely formatted multi-line string since validation errors can list many issues and the plain error string may be difficult read when debugging.\n\nIn some rare cases, the SDK can fail to get a response from the server or even make the request due to unexpected circumstances such as network conditions. These types of errors are captured in the `sdk/models/errors/httpclienterrors.ts` module:\n\n| HTTP Client Error                                    | Description                                          |\n| ---------------------------------------------------- | ---------------------------------------------------- |\n| RequestAbortedError                                  | HTTP request was aborted by the client               |\n| RequestTimeoutError                                  | HTTP request timed out due to an AbortSignal signal  |\n| ConnectionError                                      | HTTP client was unable to make a request to a server |\n| InvalidRequestError                                  | Any input used to create a request is invalid        |\n| UnexpectedClientError                                | Unrecognised or unexpected error                     |\n\u003c!-- End Error Handling [errors] --\u003e\n\n\u003c!-- Start Server Selection [server] --\u003e\n## Server Selection\n\n### Server Variables\n\nThe default server `{protocol}://{ip}:{port}` contains variables and is set to `https://10.10.10.47:32400` by default. To override default values, the following parameters are available when initializing the SDK client instance:\n\n| Variable   | Parameter                         | Supported Values           | Default         | Description                                    |\n| ---------- | --------------------------------- | -------------------------- | --------------- | ---------------------------------------------- |\n| `protocol` | `protocol: models.ServerProtocol` | - `\"http\"`\u003cbr/\u003e- `\"https\"` | `\"https\"`       | The protocol to use for the server connection  |\n| `ip`       | `ip: string`                      | string                     | `\"10.10.10.47\"` | The IP address or hostname of your Plex Server |\n| `port`     | `port: string`                    | string                     | `\"32400\"`       | The port of your Plex Server                   |\n\n#### Example\n\n```typescript\nimport { PlexAPI } from \"@lukehagar/plexjs\";\n\nconst plexAPI = new PlexAPI({\n  protocol: \"https\",\n  ip: \"e0c3:bcc0:6bac:dccc:c4ec:34b1:ca98:4cb9\",\n  port: \"40311\",\n  accessToken: \"\u003cYOUR_API_KEY_HERE\u003e\",\n});\n\nasync function run() {\n  const result = await plexAPI.server.getServerCapabilities();\n\n  // Handle the result\n  console.log(result);\n}\n\nrun();\n\n```\n\n### Override Server URL Per-Client\n\nThe default server can be overridden globally by passing a URL to the `serverURL: string` optional parameter when initializing the SDK client instance. For example:\n```typescript\nimport { PlexAPI } from \"@lukehagar/plexjs\";\n\nconst plexAPI = new PlexAPI({\n  serverURL: \"https://10.10.10.47:32400\",\n  accessToken: \"\u003cYOUR_API_KEY_HERE\u003e\",\n});\n\nasync function run() {\n  const result = await plexAPI.server.getServerCapabilities();\n\n  // Handle the result\n  console.log(result);\n}\n\nrun();\n\n```\n\n### Override Server URL Per-Operation\n\nThe server URL can also be overridden on a per-operation basis, provided a server list was specified for the operation. For example:\n```typescript\nimport { PlexAPI } from \"@lukehagar/plexjs\";\n\nconst plexAPI = new PlexAPI({\n  accessToken: \"\u003cYOUR_API_KEY_HERE\u003e\",\n});\n\nasync function run() {\n  const result = await plexAPI.plex.getCompanionsData({\n    serverURL: \"https://plex.tv/api/v2\",\n  });\n\n  // Handle the result\n  console.log(result);\n}\n\nrun();\n\n```\n\u003c!-- End Server Selection [server] --\u003e\n\n\u003c!-- Start Custom HTTP Client [http-client] --\u003e\n## Custom HTTP Client\n\nThe TypeScript SDK makes API calls using an `HTTPClient` that wraps the native\n[Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API). This\nclient is a thin wrapper around `fetch` and provides the ability to attach hooks\naround the request lifecycle that can be used to modify the request or handle\nerrors and response.\n\nThe `HTTPClient` constructor takes an optional `fetcher` argument that can be\nused to integrate a third-party HTTP client or when writing tests to mock out\nthe HTTP client and feed in fixtures.\n\nThe following example shows how to use the `\"beforeRequest\"` hook to to add a\ncustom header and a timeout to requests and how to use the `\"requestError\"` hook\nto log errors:\n\n```typescript\nimport { PlexAPI } from \"@lukehagar/plexjs\";\nimport { HTTPClient } from \"@lukehagar/plexjs/lib/http\";\n\nconst httpClient = new HTTPClient({\n  // fetcher takes a function that has the same signature as native `fetch`.\n  fetcher: (request) =\u003e {\n    return fetch(request);\n  }\n});\n\nhttpClient.addHook(\"beforeRequest\", (request) =\u003e {\n  const nextRequest = new Request(request, {\n    signal: request.signal || AbortSignal.timeout(5000)\n  });\n\n  nextRequest.headers.set(\"x-custom-header\", \"custom value\");\n\n  return nextRequest;\n});\n\nhttpClient.addHook(\"requestError\", (error, request) =\u003e {\n  console.group(\"Request Error\");\n  console.log(\"Reason:\", `${error}`);\n  console.log(\"Endpoint:\", `${request.method} ${request.url}`);\n  console.groupEnd();\n});\n\nconst sdk = new PlexAPI({ httpClient });\n```\n\u003c!-- End Custom HTTP Client [http-client] --\u003e\n\n\u003c!-- Start Authentication [security] --\u003e\n## Authentication\n\n### Per-Client Security Schemes\n\nThis SDK supports the following security scheme globally:\n\n| Name          | Type   | Scheme  |\n| ------------- | ------ | ------- |\n| `accessToken` | apiKey | API key |\n\nTo authenticate with the API the `accessToken` parameter must be set when initializing the SDK client instance. For example:\n```typescript\nimport { PlexAPI } from \"@lukehagar/plexjs\";\n\nconst plexAPI = new PlexAPI({\n  accessToken: \"\u003cYOUR_API_KEY_HERE\u003e\",\n});\n\nasync function run() {\n  const result = await plexAPI.server.getServerCapabilities();\n\n  // Handle the result\n  console.log(result);\n}\n\nrun();\n\n```\n\u003c!-- End Authentication [security] --\u003e\n\n\u003c!-- Start Requirements [requirements] --\u003e\n## Requirements\n\nFor supported JavaScript runtimes, please consult [RUNTIMES.md](RUNTIMES.md).\n\u003c!-- End Requirements [requirements] --\u003e\n\n\u003c!-- Start Standalone functions [standalone-funcs] --\u003e\n## Standalone functions\n\nAll the methods listed above are available as standalone functions. These\nfunctions are ideal for use in applications running in the browser, serverless\nruntimes or other environments where application bundle size is a primary\nconcern. When using a bundler to build your application, all unused\nfunctionality will be either excluded from the final bundle or tree-shaken away.\n\nTo read more about standalone functions, check [FUNCTIONS.md](./FUNCTIONS.md).\n\n\u003cdetails\u003e\n\n\u003csummary\u003eAvailable standalone functions\u003c/summary\u003e\n\n- [`activitiesCancelServerActivities`](docs/sdks/activities/README.md#cancelserveractivities) - Cancel Server Activities\n- [`activitiesGetServerActivities`](docs/sdks/activities/README.md#getserveractivities) - Get Server Activities\n- [`authenticationGetSourceConnectionInformation`](docs/sdks/authentication/README.md#getsourceconnectioninformation) - Get Source Connection Information\n- [`authenticationGetTokenDetails`](docs/sdks/authentication/README.md#gettokendetails) - Get Token Details\n- [`authenticationGetTransientToken`](docs/sdks/authentication/README.md#gettransienttoken) - Get a Transient Token\n- [`authenticationPostUsersSignInData`](docs/sdks/authentication/README.md#postuserssignindata) - Get User Sign In Data\n- [`butlerGetButlerTasks`](docs/sdks/butler/README.md#getbutlertasks) - Get Butler tasks\n- [`butlerStartAllTasks`](docs/sdks/butler/README.md#startalltasks) - Start all Butler tasks\n- [`butlerStartTask`](docs/sdks/butler/README.md#starttask) - Start a single Butler task\n- [`butlerStopAllTasks`](docs/sdks/butler/README.md#stopalltasks) - Stop all Butler tasks\n- [`butlerStopTask`](docs/sdks/butler/README.md#stoptask) - Stop a single Butler task\n- [`hubsGetGlobalHubs`](docs/sdks/hubs/README.md#getglobalhubs) - Get Global Hubs\n- [`hubsGetLibraryHubs`](docs/sdks/hubs/README.md#getlibraryhubs) - Get library specific hubs\n- [`hubsGetRecentlyAdded`](docs/sdks/hubs/README.md#getrecentlyadded) - Get Recently Added\n- [`libraryDeleteLibrary`](docs/sdks/library/README.md#deletelibrary) - Delete Library Section\n- [`libraryGetActorsLibrary`](docs/sdks/library/README.md#getactorslibrary) - Get Actors of library media\n- [`libraryGetAllLibraries`](docs/sdks/library/README.md#getalllibraries) - Get All Libraries\n- [`libraryGetAllMediaLibrary`](docs/sdks/library/README.md#getallmedialibrary) - Get all media of library\n- [`libraryGetCountriesLibrary`](docs/sdks/library/README.md#getcountrieslibrary) - Get Countries of library media\n- [`libraryGetFileHash`](docs/sdks/library/README.md#getfilehash) - Get Hash Value\n- [`libraryGetGenresLibrary`](docs/sdks/library/README.md#getgenreslibrary) - Get Genres of library media\n- [`libraryGetLibraryDetails`](docs/sdks/library/README.md#getlibrarydetails) - Get Library Details\n- [`libraryGetLibraryItems`](docs/sdks/library/README.md#getlibraryitems) - Get Library Items\n- [`libraryGetMediaMetaData`](docs/sdks/library/README.md#getmediametadata) - Get Media Metadata\n- [`libraryGetMetadataChildren`](docs/sdks/library/README.md#getmetadatachildren) - Get Items Children\n- [`libraryGetRecentlyAddedLibrary`](docs/sdks/library/README.md#getrecentlyaddedlibrary) - Get Recently Added\n- [`libraryGetRefreshLibraryMetadata`](docs/sdks/library/README.md#getrefreshlibrarymetadata) - Refresh Metadata Of The Library\n- [`libraryGetSearchAllLibraries`](docs/sdks/library/README.md#getsearchalllibraries) - Search All Libraries\n- [`libraryGetSearchLibrary`](docs/sdks/library/README.md#getsearchlibrary) - Search Library\n- [`libraryGetTopWatchedContent`](docs/sdks/library/README.md#gettopwatchedcontent) - Get Top Watched Content\n- [`logEnablePaperTrail`](docs/sdks/log/README.md#enablepapertrail) - Enabling Papertrail\n- [`logLogLine`](docs/sdks/log/README.md#logline) - Logging a single line message.\n- [`logLogMultiLine`](docs/sdks/log/README.md#logmultiline) - Logging a multi-line message\n- [`mediaGetBannerImage`](docs/sdks/media/README.md#getbannerimage) - Get Banner Image\n- [`mediaGetThumbImage`](docs/sdks/media/README.md#getthumbimage) - Get Thumb Image\n- [`mediaMarkPlayed`](docs/sdks/media/README.md#markplayed) - Mark Media Played\n- [`mediaMarkUnplayed`](docs/sdks/media/README.md#markunplayed) - Mark Media Unplayed\n- [`mediaUpdatePlayProgress`](docs/sdks/media/README.md#updateplayprogress) - Update Media Play Progress\n- [`playlistsAddPlaylistContents`](docs/sdks/playlists/README.md#addplaylistcontents) - Adding to a Playlist\n- [`playlistsClearPlaylistContents`](docs/sdks/playlists/README.md#clearplaylistcontents) - Delete Playlist Contents\n- [`playlistsCreatePlaylist`](docs/sdks/playlists/README.md#createplaylist) - Create a Playlist\n- [`playlistsDeletePlaylist`](docs/sdks/playlists/README.md#deleteplaylist) - Deletes a Playlist\n- [`playlistsGetPlaylist`](docs/sdks/playlists/README.md#getplaylist) - Retrieve Playlist\n- [`playlistsGetPlaylistContents`](docs/sdks/playlists/README.md#getplaylistcontents) - Retrieve Playlist Contents\n- [`playlistsGetPlaylists`](docs/sdks/playlists/README.md#getplaylists) - Get All Playlists\n- [`playlistsUpdatePlaylist`](docs/sdks/playlists/README.md#updateplaylist) - Update a Playlist\n- [`playlistsUploadPlaylist`](docs/sdks/playlists/README.md#uploadplaylist) - Upload Playlist\n- [`plexGetCompanionsData`](docs/sdks/plex/README.md#getcompanionsdata) - Get Companions Data\n- [`plexGetGeoData`](docs/sdks/plex/README.md#getgeodata) - Get Geo Data\n- [`plexGetHomeData`](docs/sdks/plex/README.md#gethomedata) - Get Plex Home Data\n- [`plexGetPin`](docs/sdks/plex/README.md#getpin) - Get a Pin\n- [`plexGetServerResources`](docs/sdks/plex/README.md#getserverresources) - Get Server Resources\n- [`plexGetTokenByPinId`](docs/sdks/plex/README.md#gettokenbypinid) - Get Access Token by PinId\n- [`plexGetUserFriends`](docs/sdks/plex/README.md#getuserfriends) - Get list of friends of the user logged in\n- [`searchGetSearchResults`](docs/sdks/search/README.md#getsearchresults) - Get Search Results\n- [`searchPerformSearch`](docs/sdks/search/README.md#performsearch) - Perform a search\n- [`searchPerformVoiceSearch`](docs/sdks/search/README.md#performvoicesearch) - Perform a voice search\n- [`serverGetAvailableClients`](docs/sdks/server/README.md#getavailableclients) - Get Available Clients\n- [`serverGetDevices`](docs/sdks/server/README.md#getdevices) - Get Devices\n- [`serverGetMediaProviders`](docs/sdks/server/README.md#getmediaproviders) - Get Media Providers\n- [`serverGetMyPlexAccount`](docs/sdks/server/README.md#getmyplexaccount) - Get MyPlex Account\n- [`serverGetResizedPhoto`](docs/sdks/server/README.md#getresizedphoto) - Get a Resized Photo\n- [`serverGetServerCapabilities`](docs/sdks/server/README.md#getservercapabilities) - Get Server Capabilities\n- [`serverGetServerIdentity`](docs/sdks/server/README.md#getserveridentity) - Get Server Identity\n- [`serverGetServerList`](docs/sdks/server/README.md#getserverlist) - Get Server List\n- [`serverGetServerPreferences`](docs/sdks/server/README.md#getserverpreferences) - Get Server Preferences\n- [`sessionsGetSessionHistory`](docs/sdks/sessions/README.md#getsessionhistory) - Get Session History\n- [`sessionsGetSessions`](docs/sdks/sessions/README.md#getsessions) - Get Active Sessions\n- [`sessionsGetTranscodeSessions`](docs/sdks/sessions/README.md#gettranscodesessions) - Get Transcode Sessions\n- [`sessionsStopTranscodeSession`](docs/sdks/sessions/README.md#stoptranscodesession) - Stop a Transcode Session\n- [`statisticsGetBandwidthStatistics`](docs/sdks/statistics/README.md#getbandwidthstatistics) - Get Bandwidth Statistics\n- [`statisticsGetResourcesStatistics`](docs/sdks/statistics/README.md#getresourcesstatistics) - Get Resources Statistics\n- [`statisticsGetStatistics`](docs/sdks/statistics/README.md#getstatistics) - Get Media Statistics\n- [`updaterApplyUpdates`](docs/sdks/updater/README.md#applyupdates) - Apply Updates\n- [`updaterCheckForUpdates`](docs/sdks/updater/README.md#checkforupdates) - Checking for updates\n- [`updaterGetUpdateStatus`](docs/sdks/updater/README.md#getupdatestatus) - Querying status of updates\n- [`usersGetUsers`](docs/sdks/users/README.md#getusers) - Get list of all connected users\n- [`videoGetTimeline`](docs/sdks/video/README.md#gettimeline) - Get the timeline for a media item\n- [`videoStartUniversalTranscode`](docs/sdks/video/README.md#startuniversaltranscode) - Start Universal Transcode\n- [`watchlistGetWatchList`](docs/sdks/watchlist/README.md#getwatchlist) - Get User Watchlist\n\n\u003c/details\u003e\n\u003c!-- End Standalone functions [standalone-funcs] --\u003e\n\n\u003c!-- Start Retries [retries] --\u003e\n## Retries\n\nSome of the endpoints in this SDK support retries.  If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API.  However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.\n\nTo change the default retry strategy for a single API call, simply provide a retryConfig object to the call:\n```typescript\nimport { PlexAPI } from \"@lukehagar/plexjs\";\n\nconst plexAPI = new PlexAPI({\n  accessToken: \"\u003cYOUR_API_KEY_HERE\u003e\",\n});\n\nasync function run() {\n  const result = await plexAPI.server.getServerCapabilities({\n    retries: {\n      strategy: \"backoff\",\n      backoff: {\n        initialInterval: 1,\n        maxInterval: 50,\n        exponent: 1.1,\n        maxElapsedTime: 100,\n      },\n      retryConnectionErrors: false,\n    },\n  });\n\n  // Handle the result\n  console.log(result);\n}\n\nrun();\n\n```\n\nIf you'd like to override the default retry strategy for all operations that support retries, you can provide a retryConfig at SDK initialization:\n```typescript\nimport { PlexAPI } from \"@lukehagar/plexjs\";\n\nconst plexAPI = new PlexAPI({\n  retryConfig: {\n    strategy: \"backoff\",\n    backoff: {\n      initialInterval: 1,\n      maxInterval: 50,\n      exponent: 1.1,\n      maxElapsedTime: 100,\n    },\n    retryConnectionErrors: false,\n  },\n  accessToken: \"\u003cYOUR_API_KEY_HERE\u003e\",\n});\n\nasync function run() {\n  const result = await plexAPI.server.getServerCapabilities();\n\n  // Handle the result\n  console.log(result);\n}\n\nrun();\n\n```\n\u003c!-- End Retries [retries] --\u003e\n\n\u003c!-- Start Debugging [debug] --\u003e\n## Debugging\n\nYou can setup your SDK to emit debug logs for SDK requests and responses.\n\nYou can pass a logger that matches `console`'s interface as an SDK option.\n\n\u003e [!WARNING]\n\u003e Beware that debug logging will reveal secrets, like API tokens in headers, in log messages printed to a console or files. It's recommended to use this feature only during local development and not in production.\n\n```typescript\nimport { PlexAPI } from \"@lukehagar/plexjs\";\n\nconst sdk = new PlexAPI({ debugLogger: console });\n```\n\u003c!-- End Debugging [debug] --\u003e\n\n\u003c!-- Placeholder for Future Speakeasy SDK Sections --\u003e\n\n# Development\n\n## Maturity\n\nThis SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage\nto a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally\nlooking for the latest version.\n\n## Contributions\n\nWhile we value open-source contributions to this SDK, this library is generated programmatically.\nFeel free to open a PR or a Github issue as a proof of concept and we'll do our best to include it in a future release!\n\n### SDK Created by [Speakeasy](https://docs.speakeasyapi.dev/docs/using-speakeasy/client-sdks)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukehagar%2Fplexjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flukehagar%2Fplexjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukehagar%2Fplexjs/lists"}