Cannot find the correct API call/script

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!

Short answer is no

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

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?

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

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:

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

And that differs from:

?

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

Example Python code using python-plexapi:

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)

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!

You are a legend. Thanks!!

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