# Plex API and Photos

**URL:** <https://forums.plex.tv/t/plex-api-and-photos/208313>\
**Category:** Dev/API Corner\
**Tags:** other-dev\
**Created:** [September 30, 2017, 1:11am UTC](https://forums.plex.tv/t/plex-api-and-photos/208313 "2017-09-30T01:11:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![DHHJ](https://avatars.discourse-cdn.com/v4/letter/d/898d66/32.png) [@DHHJ](https://forums.plex.tv/u/DHHJ)\
**Post date:** [September 30, 2017, 1:11am UTC](https://forums.plex.tv/t/plex-api-and-photos/208313/1 "2017-09-30T01:11:38Z")

</div>

I am trying to get a list of all photos (actually their aspect ratio) in my Photo library- using Python and the API. I can get the info I need, in a browser, by using: localhost:32400/library/sections/2/year/2015 and the resulting xml shows various tags, including aspectRatio.

But how can I duplicate this using the API? I don’t think year is an attribute of the Photo section as  
photos = plex.library.section(‘Photos’).year fails.

Or can I just use urllib.request and do a request/read?

---

<div class="post-metadata">

**Author:** ![dane22](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/dane22/32/4389_2.png) [@dane22](https://forums.plex.tv/u/dane22)\
**Post date:** [September 30, 2017, 8:26am UTC](https://forums.plex.tv/t/plex-api-and-photos/208313/2 "2017-09-30T08:26:28Z")

</div>

Check the source code for ExportTools.

See my signature for a link

---

<div class="post-metadata">

**Author:** ![dane22](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/dane22/32/4389_2.png) [@dane22](https://forums.plex.tv/u/dane22)\
**Post date:** [September 30, 2017, 10:05am UTC](https://forums.plex.tv/t/plex-api-and-photos/208313/3 "2017-09-30T10:05:08Z")

</div>

And did take a quick look, and it’s a multi step operation:

1. Get the key for the section:

`/library/sections/ **SectionNumber** /all`

Look up the key, and use that for the next, in a loop, getting items in chunks of 20

`/library/metadata/20703/children?year>=2014&X-Plex-Container-Start=0&X-Plex-Container-Size=20`

In above, the following is vital:

`/library/metadata/20703` is the key from the first req.

`X-Plex-Container-Start=0&X-Plex-Container-Size=20` is where you loop in multiple requests, until the answer is empty

/T

---

<div class="post-metadata">

**Author:** ![dane22](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/dane22/32/4389_2.png) [@dane22](https://forums.plex.tv/u/dane22)\
**Post date:** [September 30, 2017, 10:41pm UTC](https://forums.plex.tv/t/plex-api-and-photos/208313/4 "2017-09-30T22:41:51Z")

</div>

And when said…ExportTools can already do this for you 😉

[github.com/ukdtom/ExportTools.bundle/wiki/Photo-Export-Level](https://github.com/ukdtom/ExportTools.bundle/wiki/Photo-Export-Level "https://github.com/ukdtom/ExportTools.bundle/wiki/Photo-Export-Level")

---

<div class="post-metadata">

**Author:** ![Hellowlol](https://avatars.discourse-cdn.com/v4/letter/h/858c86/32.png) [@Hellowlol](https://forums.plex.tv/u/Hellowlol)\
**Post date:** [October 5, 2017, 5:35pm UTC](https://forums.plex.tv/t/plex-api-and-photos/208313/5 "2017-10-05T17:35:37Z")

</div>

Plexapi only supports the most basic operation when it comes to images. You have to do the filtering yourself ATM

---

<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:** [January 8, 2020, 8:05pm UTC](https://forums.plex.tv/t/plex-api-and-photos/208313/6 "2020-01-08T20:05:25Z")

</div>


