# Plex Show Episode Count API

**URL:** <https://forums.plex.tv/t/plex-show-episode-count-api/589640>\
**Category:** Dev/API Corner\
**Tags:** server-unraid\
**Created:** [May 13, 2020, 1:25pm UTC](https://forums.plex.tv/t/plex-show-episode-count-api/589640 "2020-05-13T13:25:17Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![KJThaDon](https://avatars.discourse-cdn.com/v4/letter/k/f0a364/32.png) [@KJThaDon](https://forums.plex.tv/u/KJThaDon)\
**Post date:** [May 13, 2020, 1:25pm UTC](https://forums.plex.tv/t/plex-show-episode-count-api/589640/1 "2020-05-13T13:25:17Z")

</div>

I am trying to come up with a simple way to grab my total episode count from plex.

Here is what I have for total show count, but I need episodes. What needs to be changed? Or is there another way, preferably with PHP.

Thanks

```auto
$show_url = 'https://www. ******.com/library/sections/3/all?X-Plex-Token=xxxxxxx';
$show_xml = simplexml_load_file($show_url);
$show_count = count($show_xml);
echo $show_count;

```

---

<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:** [May 13, 2020, 1:34pm UTC](https://forums.plex.tv/t/plex-show-episode-count-api/589640/2 "2020-05-13T13:34:24Z")

</div>

Web client

Select your show library, and notice second top item says `TV Shows`  
Change that to `episodes`

---

<div class="post-metadata">

**Author:** ![KJThaDon](https://avatars.discourse-cdn.com/v4/letter/k/f0a364/32.png) [@KJThaDon](https://forums.plex.tv/u/KJThaDon)\
**Post date:** [May 13, 2020, 2:07pm UTC](https://forums.plex.tv/t/plex-show-episode-count-api/589640/3 "2020-05-13T14:07:12Z")

</div>

Yes, but how do you pull that externally?

---

<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:** [May 13, 2020, 5:00pm UTC](https://forums.plex.tv/t/plex-show-episode-count-api/589640/4 "2020-05-13T17:00:20Z")

</div>

> [@KJThaDon](#):
>
> externally

So you want not the number, but be able to do it from Code 😉

Issue a `GET` like: `<PMS_IP>:32400/library/sections/<SECTIONKEY>/all?type=4&X-Plex-Container-Start=0&X-Plex-Container-Size=0&X-Plex-Token=XXXXX`

You’ll get an XML returned, with an element named `totalSize` which will be the amount of episodes

---

<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:** [May 13, 2020, 5:05pm UTC](https://forums.plex.tv/t/plex-show-episode-count-api/589640/5 "2020-05-13T17:05:38Z")

</div>

And adding to self 😉

In above url, set `type=2` to get the count of shows

And here’s some types:

- Movie : 1
- Show : 2
- Season : 3
- Episode : 4
- Trailer : 5
- Comic : 6
- Person : 7
- Artist : 8
- Album : 9
- Track : 10
- Clip : 12
- Photo : 13
- Photo\_Album : 14
- Playlist: 15
- Playlist\_Folder : 16
- Podcast : 17

---

<div class="post-metadata">

**Author:** ![KJThaDon](https://avatars.discourse-cdn.com/v4/letter/k/f0a364/32.png) [@KJThaDon](https://forums.plex.tv/u/KJThaDon)\
**Post date:** [May 14, 2020, 8:06am UTC](https://forums.plex.tv/t/plex-show-episode-count-api/589640/6 "2020-05-14T08:06:23Z")

</div>

Thank you, sir!

---

<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:** [August 12, 2020, 8:06am UTC](https://forums.plex.tv/t/plex-show-episode-count-api/589640/7 "2020-08-12T08:06:26Z")

</div>

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