# Cannot find the correct API call/script

**URL:** https://forums.plex.tv/t/cannot-find-the-correct-api-call-script/910385
**Category:** General Discussions
**Created:** [March 26, 2025, 10:36pm UTC](https://forums.plex.tv/t/cannot-find-the-correct-api-call-script/910385 "2025-03-26T22:36:06Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![jcxfb](https://avatars.discourse-cdn.com/v4/letter/j/5fc32e/32.png) [@jcxfb](https://forums.plex.tv/u/jcxfb)
#### Post date: [March 26, 2025, 10:36pm UTC](https://forums.plex.tv/t/cannot-find-the-correct-api-call-script/910385/1 "2025-03-26T22:36:06Z")

</div>

Hello,

is there any way to use API in order to get the unwatched/watched movie numbers of non owner user?

I have an app that creates a cache file of unwatched movies but it only works for the owner.  
I tried some combinations of API calls but I only get wrong data back.

Thanks!

---

<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: [March 26, 2025, 10:37pm UTC](https://forums.plex.tv/t/cannot-find-the-correct-api-call-script/910385/2 "2025-03-26T22:37:46Z")

</div>

Short answer is no

One has to logon as the users one by one, in order to get the stats

---

<div class="post-metadata">

### Author: ![jcxfb](https://avatars.discourse-cdn.com/v4/letter/j/5fc32e/32.png) [@jcxfb](https://forums.plex.tv/u/jcxfb)
#### Post date: [March 26, 2025, 10:58pm UTC](https://forums.plex.tv/t/cannot-find-the-correct-api-call-script/910385/3 "2025-03-26T22:58:41Z")

</div>

Thanks, so this data is only available if I login as the user in the plex app? Or in my test case, switch to the user since it is a Home user.

No code alternative?

---

<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: [March 26, 2025, 11:02pm UTC](https://forums.plex.tv/t/cannot-find-the-correct-api-call-script/910385/4 "2025-03-26T23:02:35Z")

</div>

> [@jcxfb](#):
>
> No code alternative?

Nope, sorry and if doing this the right way

As an alternative, would be to get a copy of the database, since we do NOT access the live database from 3rd. Party tools, and then query the copy of that database with SQL

---

<div class="post-metadata">

### Author: ![SwiftPanda16](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/swiftpanda16/32/81839_2.png) [@SwiftPanda16](https://forums.plex.tv/u/SwiftPanda16)
#### Post date: [March 27, 2025, 12:28am UTC](https://forums.plex.tv/t/cannot-find-the-correct-api-call-script/910385/5 "2025-03-27T00:28:07Z")

</div>

Yes, you can.

All API calls are the same except you just need to use the user’s server access token (not their account access token).

You can get each user’s server access token here:

```auto
https://plex.tv/api/servers/<serverMachineIdentifier>/shared_servers

```

---

<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: [March 27, 2025, 12:33am UTC](https://forums.plex.tv/t/cannot-find-the-correct-api-call-script/910385/6 "2025-03-27T00:33:40Z")

</div>

> [@SwiftPanda16](#):
>
> All API calls are the same except you just need to use the user’s server access token

And that differs from:

> [@dane22](#):
>
> One has to logon as the users one by one, in order to get the stats

?

---

<div class="post-metadata">

### Author: ![SwiftPanda16](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/swiftpanda16/32/81839_2.png) [@SwiftPanda16](https://forums.plex.tv/u/SwiftPanda16)
#### Post date: [March 27, 2025, 12:38am UTC](https://forums.plex.tv/t/cannot-find-the-correct-api-call-script/910385/7 "2025-03-27T00:38:01Z")

</div>

You as the server admin can retrieve each user’s server access token - no login to their account required. The server token is used to access your own server.

This is not the same as the account token you get by logging in to their account with their username/password. The account token grants access to the account on plex.tv.

For the admin, both tokens are the same (access to plex.tv and your own server).

---

<div class="post-metadata">

### Author: ![SwiftPanda16](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/swiftpanda16/32/81839_2.png) [@SwiftPanda16](https://forums.plex.tv/u/SwiftPanda16)
#### Post date: [March 27, 2025, 12:45am UTC](https://forums.plex.tv/t/cannot-find-the-correct-api-call-script/910385/8 "2025-03-27T00:45:11Z")

</div>

Example Python code using `python-plexapi`:

```py
from plexapi.server import PlexServer

PLEX_URL = "http://localhost:32400"
ADMIN_TOKEN = "XXXXXXXXXXXXXXXXXXXX"

# Admin Plex server instance.
plex_admin = PlexServer(PLEX_URL, ADMIN_TOKEN)
# Unwatched movies by the admin.
movies = plex_admin.library.section("Movies").search(unwatched=True)

# Switch to "Username2" on your own server. This does the magic behind the scenes to automatically retrieve the user's server token.
# Returns a user Plex server instance.
plex_user = plex_admin.switchUser("Username2")
# Unwatched movies by "Username2"
movies = plex_user.library.section("Movies").search(unwatched=True)

```

---

<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: [March 27, 2025, 12:57am UTC](https://forums.plex.tv/t/cannot-find-the-correct-api-call-script/910385/9 "2025-03-27T00:57:18Z")

</div>

> [@SwiftPanda16](#):
>
> ou as the server admin can retrieve each user’s server access token - no login to their account required.

Not native English here, but when you call a PMS endpoint with a different token, that in my book is a sign-in/login as a different user on the PMS, not plex.tv

When said, I do agree with everything else you said!

---

<div class="post-metadata">

### Author: ![jcxfb](https://avatars.discourse-cdn.com/v4/letter/j/5fc32e/32.png) [@jcxfb](https://forums.plex.tv/u/jcxfb)
#### Post date: [March 27, 2025, 7:06am UTC](https://forums.plex.tv/t/cannot-find-the-correct-api-call-script/910385/10 "2025-03-27T07:06:22Z")

</div>

You are a legend. Thanks!!

---

<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: [June 25, 2025, 7:07am UTC](https://forums.plex.tv/t/cannot-find-the-correct-api-call-script/910385/11 "2025-06-25T07:07:08Z")

</div>

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