# HTTP API

**URL:** <https://forums.plex.tv/t/http-api/21949>\
**Category:** Dev/API Corner\
**Tags:** other-dev\
**Created:** [October 3, 2012, 9:15am UTC](https://forums.plex.tv/t/http-api/21949 "2012-10-03T09:15:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jpeek](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/jpeek/32/108506_2.png) [@jpeek](https://forums.plex.tv/u/jpeek)\
**Post date:** [October 3, 2012, 9:15am UTC](https://forums.plex.tv/t/http-api/21949/1 "2012-10-03T09:15:40Z")

</div>

Get watched/unwatched
Am trying to add in functionality to a management script that will purge watched TV episodes after a period of time.  
  
To do this, I need to get a complete list of TV episodes along with their watched status, ideally in a single request.  
  
The closest I seem to be able to get is:  
  
http://127.0.0.1:32400/library/sections/2/search?type=4  
  
Which returns all episodes, but doesn't include a viewCount attribute.  
  
Is there another request I could be doing to get this? Or i s something that could be added to the API?

---

<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:** [October 3, 2012, 12:22pm UTC](https://forums.plex.tv/t/http-api/21949/2 "2012-10-03T12:22:28Z")

</div>

Hi!  
  
I looked at the output of http://\*\*\*\*127.0.0.1:32400/library/sections//search?type=4 on my machine and I do see the _viewCount_ attribute on some, but not all elements. It looks like the attribute is available if the viewCount \>=1 and is missing if it’s an unwatched episode.

---

<div class="post-metadata">

**Author:** ![jam](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/jam/32/186050_2.png) [@jam](https://forums.plex.tv/u/jam)\
**Post date:** [October 3, 2012, 4:05pm UTC](https://forums.plex.tv/t/http-api/21949/3 "2012-10-03T16:05:57Z")

</div>

Try this:

```auto

http://127.0.0.1:32400/library/sections/2/allLeaves

```

---

<div class="post-metadata">

**Author:** ![jpeek](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/jpeek/32/108506_2.png) [@jpeek](https://forums.plex.tv/u/jpeek)\
**Post date:** [October 6, 2012, 12:43pm UTC](https://forums.plex.tv/t/http-api/21949/4 "2012-10-06T12:43:58Z")

</div>

Sorry, you’re right, the viewCount was there, just only for watched episodes (I didn’t scroll down far enough!).   
  
  
  
Thanks for the proper way to do it Jam, much appreciated.

---

<div class="post-metadata">

**Author:** ![JJFlix](https://avatars.discourse-cdn.com/v4/letter/j/e495f1/32.png) [@JJFlix](https://forums.plex.tv/u/JJFlix)\
**Post date:** [November 12, 2012, 3:37am UTC](https://forums.plex.tv/t/http-api/21949/5 "2012-11-12T03:37:39Z")

</div>

> [@](#):
>
> Am trying to add in functionality to a management script that will purge watched TV episodes after a period of time.  
>   
> To do this, I need to get a complete list of TV episodes along with their watched status, ideally in a single request.  
>   
> The closest I seem to be able to get is:  
>   
> http://127.0.0.1:32400/library/sections/2/search?type=4  
>   
> Which returns all episodes, but doesn't include a viewCount attribute.  
>   
> Is there another request I could be doing to get this? Or i s something that could be added to the API?

  
  
  
Did you have any luck with that script you are looking to create? I was thinking about the same thing. Any progress?  
  
Best,  
  
J

---

<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 20, 2019, 10:18pm UTC](https://forums.plex.tv/t/http-api/21949/6 "2019-12-20T22:18:12Z")

</div>

Closed on December 20, 2019, 10:18pm UTC

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