Plex API - get show metadata with folder location and possibly extras

I am trying to get the library items metadata from plex API (referencing https://developer.plex.tv/pms/).

Here’s what I have done so far:

  • Got the Auth Token Request figured out - successfully able to use OAuth to get the Token
  • Got the library sections from api using {self.server_url}/library/sections
  • Now I am trying to get the media metadata with folder path, GUIDs, Extras (if possible). I tried using {self.server_url}/library/sections/{section_key}/all?includeGuids=1&includeDetails=1 and also {self.server_url}/library/sections/{section_key}/all?includeGuids=1&includeDetails=1
  • Also tried adding extra query parameters like includeExtras=1, includeFields=OnDeck,Extras, includeOptionalFields=OnDeck,Extras. No luck.

Now here’s my problem:

  • When I use the /library/sections/{sectionKey}/all it works for movies to get GUIDs, media file path, but not extras in the same request. Also, didn’t find an API call to get extras info for all items in a single call (or paginated). Requesting extras for 1 movie at a time didn’t seem like a good solution. And for shows section this doesn’t include any media file/folder paths - which is a requirement for my use case.
  • When I use the /library/sections/{sectionKey}/allLeaves it works for both movies and shows, but not extras, or GUIDs for shows as this is episode data for shows section. So, to get the GUIDs I need to make another call to the /library/sections/{sectionKey}/all endpoint - which doesn’t seem like a good solution either.

The API documentation does have a section for “Response Customization”, wasn’t able to figure how to customize the responses with the GUIDs. file/folder path, and Extras.

Has anyone figured it out? Can someone please help?

When you go to endpoint all you should use Pagination
Ref: https://developer.plex.tv/pms/#section/API-Info/Pagination

When said, what’s returned will show you a key/value entry like: key="/library/metadata/9036"

So you need an additional call to the value to get more info, as well as use extra query parameters

Apologies for the delayed response, but yes, I know about pagination and I am already using it - otherwise I would get a huge json file which increases memory usage in my app.

I can fetch the metadata of the library item but what I am trying to find out is if I can somehow tweak the all or allLeaves query with include*, includeFields, includeOptionalFields etc to get that in a single call (which I can run in a loop with pagination) instead of doing individual calls one for each item.

I created a new library sections, one with about 20 movies and other with like 3 shows the other day, gave the Plex API doc to claude along with a JWT token (temporary as I later removed it from authorized sources) and asking it to explore different API calls and experiment with the available options. And it could not find a query to get extras in all or allLeaves and calling individually on the media item seems like the only option at this point.

Sadly, there’s no such thing as a single call, AFAIK

Yeah, that’s what I realized but by using claude to explore the API, it gave me a query with excludeOptions so that my app doesn’t have to fetch all the data from Plex it isn’t gonna use.

I now fetch the movie and shows at first and only get extras when needed.

Appreciate the help though. Thank you!