# Using the API to retrieve Library metadata

**URL:** https://forums.plex.tv/t/using-the-api-to-retrieve-library-metadata/60034
**Category:** Dev/API Corner
**Tags:** other-dev
**Created:** [March 12, 2014, 6:54pm UTC](https://forums.plex.tv/t/using-the-api-to-retrieve-library-metadata/60034 "2014-03-12T18:54:46Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![dashbad](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/dashbad/32/86287_2.png) [@dashbad](https://forums.plex.tv/u/dashbad)
#### Post date: [March 12, 2014, 6:54pm UTC](https://forums.plex.tv/t/using-the-api-to-retrieve-library-metadata/60034/1 "2014-03-12T18:54:46Z")

</div>

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

&nbsp;

[https://my.plexapp.com/sign\_in.xml](https://my.plexapp.com/sign_in.xml)

&nbsp;

and getting a list of sections from:

&nbsp;

[https://my.plexapp.com/pms/system/library/sections](https://my.plexapp.com/pms/system/library/sections)

&nbsp;

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.:

&nbsp;

[http://x.x.x.x:32400/library/sections/3/all](http://x.x.x.x:32400/library/sections/3/all)

&nbsp;

I have some questions about this:

&nbsp;

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?

&nbsp;

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

&nbsp;

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?

---

<div class="post-metadata">

### Author: ![Moussa](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/moussa/32/314364_2.png) [@Moussa](https://forums.plex.tv/u/Moussa)
#### Post date: [March 12, 2014, 8:01pm UTC](https://forums.plex.tv/t/using-the-api-to-retrieve-library-metadata/60034/2 "2014-03-12T20:01:32Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![Gyran](https://avatars.discourse-cdn.com/v4/letter/g/3ec8ea/32.png) [@Gyran](https://forums.plex.tv/u/Gyran)
#### Post date: [March 13, 2014, 5:56am UTC](https://forums.plex.tv/t/using-the-api-to-retrieve-library-metadata/60034/3 "2014-03-13T05:56:43Z")

</div>

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

---

<div class="post-metadata">

### Author: ![dashbad](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/dashbad/32/86287_2.png) [@dashbad](https://forums.plex.tv/u/dashbad)
#### Post date: [March 13, 2014, 10:59am UTC](https://forums.plex.tv/t/using-the-api-to-retrieve-library-metadata/60034/4 "2014-03-13T10:59:42Z")

</div>

> 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.....

---

<div class="post-metadata">

### Author: ![sander1](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@sander1](https://forums.plex.tv/u/sander1)
#### Post date: [March 13, 2014, 2:03pm UTC](https://forums.plex.tv/t/using-the-api-to-retrieve-library-metadata/60034/5 "2014-03-13T14:03:36Z")

</div>

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

---

<div class="post-metadata">

### Author: ![dashbad](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/dashbad/32/86287_2.png) [@dashbad](https://forums.plex.tv/u/dashbad)
#### Post date: [March 14, 2014, 11:33am UTC](https://forums.plex.tv/t/using-the-api-to-retrieve-library-metadata/60034/6 "2014-03-14T11:33:27Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![system](https://global.discourse-cdn.com/plex/original/3X/2/a/2acb9765406f63293d357b4ec509ec39aa28f2ad.png) [@system](https://forums.plex.tv/u/system)
#### Post date: [December 21, 2019, 1:32am UTC](https://forums.plex.tv/t/using-the-api-to-retrieve-library-metadata/60034/7 "2019-12-21T01:32:27Z")

</div>

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