Using the API to retrieve Library metadata

I'm playing around with parsing and manipulating library metadata in xml. At the moment I am retrieving a token from:

 

https://my.plexapp.com/sign_in.xml

 

and getting a list of sections from:

 

https://my.plexapp.com/pms/system/library/sections

 

This allows me to retrieve a list of all the Media in a section using the "key" attribute from the above xml. This is a url pointing directly to the PMS instance e.g.:

 

http://x.x.x.x:32400/library/sections/3/all

 

I have some questions about this:

 

1. is there a way to retrieve the listing of the Media in a section from the my.plexapp.com domain or do I always need to connect directly to the server using the provide key?

 

2. Is there a better, faster way of retrieving this information? Can I get it via the JSON api? I've been trying to find out how to make these calls and get json back but it isn't clear from the documentation I can find

 

3. Media objects include a bitrate integer. This isn't provided with a unit so it is hard to know whether it is in Mb, Kb etc. How is this number calculated and is there any logic I can apply to my parser to know what unit the bitrate value is?

  1. You always need to make a GET request to the server with an access token to get the metadata. I’m not sure if you need the token if you’re doing the call locally though (http//localhost:32400 for example).

  2. As far as I know the server only returns XML responses.

  3. I don’t know, but I thought everything was returned in bytes?

I have also tried to get the server to respond with json but haven’t found a way. The only thing I know you can get by json is the token at /sign_in.json

1. You always need to make a GET request to the server with an access token to get the metadata. I'm not sure if you need the token if you're doing the call locally though (http//localhost:32400 for example).

2. As far as I know the server only returns XML responses.

3. I don't know, but I thought everything was returned in bytes?

Thanks for helping. For point 1 I know that I always need a token - I just noticed that the server list is retrieved by a call to my.plexapp.com whereas I have to ping the IP of the server itself to get the full media listing. I'm wondering if this is available through myplex.com instead....

On 3, unfortunately not. For example, I have one small Movie that has a bitrate of 1232 kbps which is reported as "128" whereas another with a bitrate of 6418 kbps is reported as 6418. For the most part it seems kbps is returned - however there are a few anomalies.....

  1. myPlex does not store that information, so you really have to connect to the PMS
  2. If you send an "Accept" header with the value "application/json" in your request, you'll get json back (although I'm not 100% sure if this works for the myPlex request, it will certainly work for the requests to your own PMS).
  3. Bitrate is the overall bit rate afaik, in Kbps

Thanks! Can you clarify regarding the application/json request to PMS. I am trying to get a full list of all the items in the section. I get xml if I request:

http://{server_ip}:32400/library/sections/3/all?X-Plex-Token={token}

If I add the application/json Accept header I get 405 method not allowed.

What else do I need to add to the request to get a full list of the section back?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.