{"id":16633513,"url":"https://github.com/lukehagar/plex-api-oauth","last_synced_at":"2025-12-26T04:33:09.307Z","repository":{"id":48142527,"uuid":"516571185","full_name":"LukeHagar/plex-api-oauth","owner":"LukeHagar","description":"An NPM Module designed to make Plex Media Server and plex.tv API calls easier to implement in JavaScript and React projects","archived":false,"fork":false,"pushed_at":"2024-01-19T17:53:38.000Z","size":2322,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-18T09:13:30.781Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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":null,"funding":null,"license":"LICENSE","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":"2022-07-22T01:29:06.000Z","updated_at":"2022-07-22T21:35:49.000Z","dependencies_parsed_at":"2024-11-17T13:45:46.873Z","dependency_job_id":"7a7f475e-b181-452d-8caf-e68846d087d5","html_url":"https://github.com/LukeHagar/plex-api-oauth","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LukeHagar%2Fplex-api-oauth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LukeHagar%2Fplex-api-oauth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LukeHagar%2Fplex-api-oauth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LukeHagar%2Fplex-api-oauth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LukeHagar","download_url":"https://codeload.github.com/LukeHagar/plex-api-oauth/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243125639,"owners_count":20240276,"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:52.320Z","updated_at":"2025-12-26T04:33:09.255Z","avatar_url":"https://github.com/LukeHagar.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# plex-api-oauth\n\n# THIS PACKAGE IS DEPRECATED IN FAVOR OF https://github.com/LukeHagar/plexjs\n\nAn NPM Module designed to make Plex Media Server and plex.tv API calls easier to implement in JavaScript and React projects\n\n\u003cimg src=\"https://img.shields.io/lgtm/grade/javascript/github/LukeHagar/plex-api-oauth\" /\u003e \u003cimg src=\"https://img.shields.io/npm/dw/plex-api-oauth\" /\u003e\n\nhttps://www.npmjs.com/package/plex-api-oauth\n\nThis is a JavaScript Module written to take the OAuth Module written by @Dmbob https://github.com/Dmbob/plex-oauth and incorporate it into a front end friend frame work to make development of Plex API Based applications better\n\n## How to Use\n\nExamples Assume React Syntax\n\n### Loading a Saved Session\n\nLoadPlexSession:  \nFunction returns an object that contains the plexClientInformation and plexTVAuthToken keys/values according to how they were created\n\n```JavaScript\nconst loadedSession = LoadPlexSession();\nif (loadedSession.plexClientInformation == null){\n    loadedSession.plexClientInformation = CreatePlexClientInformation();\n}\n\nconst [plexClientInformation, setPlexClientInformation] = useState(\n  loadedSession.plexClientInformation\n);\nconst [plexTVAuthToken, setPlexTVAuthToken] = useState(\n  loadedSession.plexTVAuthToken\n);\n```\n\n### Login Button + Save Session\n\n```JavaScript\n async function PlexLoginButton() {\n    const tempPlexTVAuthToken = await PlexLogin(plexClientInformation);\n    const tempPlexTVUserData = await GetPlexUserData(\n      plexClientInformation,\n      tempPlexTVAuthToken\n    );\n    const tempPlexServers = await GetPlexServers(\n      plexClientInformation,\n      tempPlexTVAuthToken\n    );\n    const tempPlexLibraries = await GetPlexLibraries(tempPlexServers);\n    setPlexTVAuthToken(tempPlexTVAuthToken);\n    setPlexServers(tempPlexServers);\n    setPlexTVUserData(tempPlexTVUserData);\n    setPlexLibraries(tempPlexLibraries);\n    SavePlexSession(plexClientInformation, tempPlexTVAuthToken);\n  }\n```\n\n### Refresh Data with Saved Session\n\n```JavaScript\n async function Refresh() {\n    const tempPlexTVUserData = await GetPlexUserData(\n      plexClientInformation,\n      plexTVAuthToken\n    );\n    const tempPlexServers = await GetPlexServers(\n      plexClientInformation,\n      plexTVAuthToken\n    );\n    const tempPlexDevices = await GetPlexDevices(\n      plexClientInformation,\n      plexTVAuthToken\n    );\n    const tempPlexLibraries = await GetPlexLibraries(tempPlexServers);\n    UpdateHubs(tempPlexServers, tempPlexLibraries);\n    setPlexServers(tempPlexServers);\n    setPlexDevices(tempPlexDevices);\n    setPlexTVUserData(tempPlexTVUserData);\n    setPlexLibraries(tempPlexLibraries);\n    setIsRefreshing(false);\n  }\n```\n\n### Update Library list when the topic is changed (artists. albums, songs)\n\n```JavaScript\n async function UpdateLibrary() {\n    setIsLoading(true);\n    const returnObject = await GetLibraryPages(\n      plexServers,\n      plexLibraries,\n      topic,\n      pageNumber,\n      250\n    );\n    console.log(returnObject);\n    const tempItemArray = Array.from([\n      ...new Set([...libraryItems, ...returnObject.items]),\n    ]);\n\n    setLibraryItems(tempItemArray);\n    setLibraryHasMore(returnObject.hasMore);\n    setIsLoading(false);\n  }\n```\n\n### Intersection observer to load more library items when the callbackref object comes into view\n\n```JavaScript\n const observer = useRef();\n  const lastLibraryItem = useCallback(\n    (node) =\u003e {\n      if (isLoading) return;\n      if (observer.current) observer.current.disconnect();\n      observer.current = new IntersectionObserver((entries) =\u003e {\n        if (entries[0].isIntersecting \u0026\u0026 libraryHasMore) {\n          setPageNumber(pageNumber + 1);\n        }\n      });\n      if (node) observer.current.observe(node);\n      console.log(node);\n    },\n    [isLoading, libraryHasMore]\n  );\n```\n\n### Intersection observer Callback usage\n\n```JavaScript\n  if (libraryItems?.length === index + 100) {\n    return (\n          \u003cGrid item xs=\"12\" key={Obj.guid + index}\u003e\n            \u003cListItem ref={lastLibraryItem}\u003e\n              \u003cListItemAvatar\u003e\n                \u003cAvatar alt={NoArt} src={Obj.thumb} /\u003e\n              \u003c/ListItemAvatar\u003e\n              \u003cTypography variant=\"h6\" noWrap\u003e\n                {Obj.title} - {Obj.grandparentTitle} -{' '}\n                {Obj.parentTitle}\n              \u003c/Typography\u003e\n            \u003c/ListItem\u003e\n        \u003c/Grid\u003e\n      );\n    }\n```\n\n### Intersection observer to load more library items when the callbackref object comes into view\n\n```JavaScript\n const observer = useRef();\n  const lastLibraryItem = useCallback(\n    (node) =\u003e {\n      if (isLoading) return;\n      if (observer.current) observer.current.disconnect();\n      observer.current = new IntersectionObserver((entries) =\u003e {\n        if (entries[0].isIntersecting \u0026\u0026 libraryHasMore) {\n          setPageNumber(pageNumber + 1);\n        }\n      });\n      if (node) observer.current.observe(node);\n      console.log(node);\n    },\n    [isLoading, libraryHasMore]\n  );\n```\n\n### Get Plex Music Hub data\n\n```JavaScript\n async function UpdateHubs(plexClientInformation, plexServers, plexLibraries) {\n    const tempMusicHubs = await GetMusicHub(\n      plexClientInformation,\n      plexServers, // No Auth Token is needed since the server objects have their own access tokens\n      plexLibraries\n    );\n    setMusicHubs(tempMusicHubs);\n  }\n```\n\n## Commands:\n\n### CreatePlexClientInformation\n\nAccepts: input values\n\nGenerates the Client Information to uniquely identify the Authenticated client\nSave between sessions for consistency\n\n```JavaScript\ninput = {product:\"LukeHagar.com\"}\nplexClientInformation = CreatePlexClientInformation(input);\n```\n\n### PlexLogin\n\nAccepts: plexClientInformation\n\nIf command is run in a browser window it will open the new login window automatically\n\n```JavaScript\nplexTVAuthToken = PlexLogin(plexClientInformation);\n```\n\n### GetPlexUserData\n\nAccepts: plexClientInformation, plexTVAuthToken\n\nQueries the plex.tv api to get information on the authenticated user\n\n```JavaScript\nplexUserData = GetPlexUserData(plexClientInformation, plexTVAuthToken);\n```\n\n### GetPlexServers\n\nAccepts an Object with partial client values, will populate the remaining ones left blank if needed\n\n```JavaScript\nplexServers = GetPlexServers(plexClientInformation, plexTVAuthToken);\n```\n\n### GetPlexMovies\n\nAccepts an Object with partial client values, will populate the remaining ones left blank if needed\n\n```JavaScript\ninput = {product:\"LukeHagar.com\"}\nplexClientInformation = CreatePlexClientInformation(input);\n```\n\n### GetPlexShows\n\nAccepts an Object with partial client values, will populate the remaining ones left blank if needed\n\n```JavaScript\ninput = {product:\"LukeHagar.com\"}\nplexClientInformation = CreatePlexClientInformation(input);\n```\n\n### GetPlexSeasons\n\nAccepts an Object with partial client values, will populate the remaining ones left blank if needed\n\n```JavaScript\ninput = {product:\"LukeHagar.com\"}\nplexClientInformation = CreatePlexClientInformation(input);\n```\n\n### GetPlexEpisodes\n\nAccepts an Object with partial client values, will populate the remaining ones left blank if needed\n\n```JavaScript\ninput = {product:\"LukeHagar.com\"}\nplexClientInformation = CreatePlexClientInformation(input);\n```\n\n### GetPlexMovieLibraries\n\nAccepts an Object with partial client values, will populate the remaining ones left blank if needed\n\n```JavaScript\ninput = {product:\"LukeHagar.com\"}\nplexClientInformation = CreatePlexClientInformation(input);\n```\n\n### GetPlexMusicLibraries\n\nAccepts an Object with partial client values, will populate the remaining ones left blank if needed\n\n```JavaScript\ninput = {product:\"LukeHagar.com\"}\nplexClientInformation = CreatePlexClientInformation(input);\n```\n\n### GetPlexTVShowLibraries\n\nAccepts an Object with partial client values, will populate the remaining ones left blank if needed\n\n```JavaScript\ninput = {product:\"LukeHagar.com\"}\nplexClientInformation = CreatePlexClientInformation(input);\n```\n\n### GetPlexArtists\n\nAccepts an Object with partial client values, will populate the remaining ones left blank if needed\n\n```JavaScript\ninput = {product:\"LukeHagar.com\"}\nplexClientInformation = CreatePlexClientInformation(input);\n```\n\n### GetPlexAlbums\n\nAccepts an Object with partial client values, will populate the remaining ones left blank if needed\n\n```JavaScript\ninput = {product:\"LukeHagar.com\"}\nplexClientInformation = CreatePlexClientInformation(input);\n```\n\n### GetPlexSongs\n\nAccepts an Object with partial client values, will populate the remaining ones left blank if needed\n\n```JavaScript\ninput = {product:\"LukeHagar.com\"}\nplexClientInformation = CreatePlexClientInformation(input);\n```\n\n### GetPlexLibraries\n\nAccepts an Object with partial client values, will populate the remaining ones left blank if needed\n\n```JavaScript\ninput = {product:\"LukeHagar.com\"}\nplexClientInformation = CreatePlexClientInformation(input);\n```\n\n### GetPlexDevices\n\nAccepts an Object with partial client values, will populate the remaining ones left blank if needed\n\n```JavaScript\ninput = {product:\"LukeHagar.com\"}\nplexClientInformation = CreatePlexClientInformation(input);\n```\n\n### ### GetLibraryPages\n\nAccepts an Object with partial client values, will populate the remaining ones left blank if needed\n\n```JavaScript\ninput = {product:\"LukeHagar.com\"}\nplexClientInformation = CreatePlexClientInformation(input);\n```\n\n### LoadPlexSession\n\nAccepts an Object with partial client values, will populate the remaining ones left blank if needed\n\n```JavaScript\ninput = {product:\"LukeHagar.com\"}\nplexClientInformation = CreatePlexClientInformation(input);\n```\n\n### SavePlexSession\n\nAccepts an Object with partial client values, will populate the remaining ones left blank if needed\n\n```JavaScript\ninput = {product:\"LukeHagar.com\"}\nplexClientInformation = CreatePlexClientInformation(input);\n```\n\n### GetMusicHub\n\nAccepts an Object with partial client values, will populate the remaining ones left blank if needed\n\n```JavaScript\ninput = {product:\"LukeHagar.com\"}\nplexClientInformation = CreatePlexClientInformation(input);\n```\n\n### GetArtistPage\n\nAccepts an Object with partial client values, will populate the remaining ones left blank if needed\n\n```JavaScript\ninput = {product:\"LukeHagar.com\"}\nplexClientInformation = CreatePlexClientInformation(input);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukehagar%2Fplex-api-oauth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flukehagar%2Fplex-api-oauth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukehagar%2Fplex-api-oauth/lists"}