Skip to main content
GET
/
users
PlexPHP
declare(strict_types=1);

require 'vendor/autoload.php';

use LukeHagar\Plex_API;
use LukeHagar\Plex_API\Models\Operations;

$sdk = Plex_API\PlexAPI::builder()->build();

$request = new Operations\GetUsersRequest(
    clientID: '3381b62b-9ab7-4e37-827b-203e9809eb58',
    clientName: 'Plex for Roku',
    deviceNickname: 'Roku 3',
    deviceName: 'Chrome',
    deviceScreenResolution: '1487x1165,2560x1440',
    clientVersion: '2.4.1',
    platform: 'Roku',
    clientFeatures: 'external-media,indirect-media,hub-style-list',
    model: '4200X',
    xPlexSessionId: '97e136ef-4ddd-4ff3-89a7-a5820c96c2ca',
    xPlexLanguage: 'en',
    platformVersion: '4.3 build 1057',
    xPlexToken: 'CV5xoxjTpFKUzBTShsaf',
);

$response = $sdk->users->getUsers(
    request: $request
);

if ($response->body !== null) {
    // handle response
}
require 'plex_ruby_sdk'

s = ::PlexRubySDK::PlexAPI.new

req = Models::Operations::GetUsersRequest.new(
client_id: "3381b62b-9ab7-4e37-827b-203e9809eb58",
client_name: "Plex for Roku",
device_nickname: "Roku 3",
device_name: "Chrome",
device_screen_resolution: "1487x1165,2560x1440",
client_version: "2.4.1",
platform: "Roku",
client_features: "external-media,indirect-media,hub-style-list",
model: "4200X",
x_plex_session_id: "97e136ef-4ddd-4ff3-89a7-a5820c96c2ca",
x_plex_language: "en",
platform_version: "4.3 build 1057",
x_plex_token: "CV5xoxjTpFKUzBTShsaf",
)

res = s.users.get_users(req)

if ! res.body.nil?
# handle response
end
package main

import(
"context"
"github.com/LukeHagar/plexgo/models/components"
"github.com/LukeHagar/plexgo"
"github.com/LukeHagar/plexgo/models/operations"
"log"
)

func main() {
ctx := context.Background()

s := plexgo.New(
plexgo.WithAccepts(components.AcceptsApplicationXML),
plexgo.WithClientIdentifier("3381b62b-9ab7-4e37-827b-203e9809eb58"),
plexgo.WithProduct("Plex for Roku"),
plexgo.WithVersion("2.4.1"),
plexgo.WithPlatform("Roku"),
plexgo.WithPlatformVersion("4.3 build 1057"),
plexgo.WithDevice("Roku 3"),
plexgo.WithModel("4200X"),
plexgo.WithDeviceVendor("Roku"),
plexgo.WithDeviceName("Chrome"),
plexgo.WithMarketplace("googlePlay"),
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
)

res, err := s.Users.GetUsers(ctx, operations.GetUsersRequest{})
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
package hello.world;

import dev.plexapi.sdk.PlexAPI;
import dev.plexapi.sdk.models.errors.GetUsersBadRequest;
import dev.plexapi.sdk.models.errors.GetUsersUnauthorized;
import dev.plexapi.sdk.models.operations.GetUsersRequest;
import dev.plexapi.sdk.models.operations.GetUsersResponse;
import dev.plexapi.sdk.models.shared.Accepts;
import java.lang.Exception;

public class Application {

public static void main(String[] args) throws GetUsersBadRequest, GetUsersUnauthorized, Exception {

PlexAPI sdk = PlexAPI.builder()
.accepts(Accepts.APPLICATION_XML)
.clientIdentifier("abc123")
.product("Plex for Roku")
.version("2.4.1")
.platform("Roku")
.platformVersion("4.3 build 1057")
.device("Roku 3")
.model("4200X")
.deviceVendor("Roku")
.deviceName("Living Room TV")
.marketplace("googlePlay")
.token(System.getenv().getOrDefault("TOKEN", ""))
.build();

GetUsersRequest req = GetUsersRequest.builder()
.build();

GetUsersResponse res = sdk.users().getUsers()
.request(req)
.call();

if (res.object().isPresent()) {
// handle response
}
}
}
import { PlexAPI } from "@lukehagar/plexjs";
import { Accepts } from "@lukehagar/plexjs/models/shared";

const plexAPI = new PlexAPI({
accepts: Accepts.ApplicationXml,
clientIdentifier: "3381b62b-9ab7-4e37-827b-203e9809eb58",
product: "Plex for Roku",
version: "2.4.1",
platform: "Roku",
platformVersion: "4.3 build 1057",
device: "Roku 3",
model: "4200X",
deviceVendor: "Roku",
deviceName: "Chrome",
marketplace: "googlePlay",
token: "<YOUR_API_KEY_HERE>",
});

async function run() {
const result = await plexAPI.users.getUsers({});

console.log(result);
}

run();
curl --request GET \
--url https://plex.tv/api/users \
--header 'X-Plex-Client-Identifier: <x-plex-client-identifier>' \
--header 'X-Plex-Token: <api-key>'
import requests

url = "https://plex.tv/api/users"

headers = {
"X-Plex-Client-Identifier": "<x-plex-client-identifier>",
"X-Plex-Token": "<api-key>"
}

response = requests.get(url, headers=headers)

print(response.text)
const options = {
method: 'GET',
headers: {
'X-Plex-Client-Identifier': '<x-plex-client-identifier>',
'X-Plex-Token': '<api-key>'
}
};

fetch('https://plex.tv/api/users', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
{
  "MediaContainer": {
    "friendlyName": "myPlex",
    "identifier": "com.plexapp.plugins.myplex",
    "machineIdentifier": "3dff4c4da3b1229a649aa574a9e2b419a684a20e",
    "totalSize": 30,
    "size": 30,
    "User": [
      {
        "id": 22526914,
        "title": "Plex User",
        "username": "zgfuc7krcqfimrmb9lsl5j",
        "email": "zgfuc7krcqfimrmb9lsl5j@protonmail.com",
        "thumb": "https://plex.tv/users/3346028014e93acd/avatar?c=1731605021",
        "protected": 1,
        "home": 1,
        "allowTuners": 1,
        "allowSync": 1,
        "allowCameraUpload": 1,
        "allowChannels": 1,
        "allowSubtitleAdmin": 1,
        "restricted": 1,
        "Server": [
          {
            "id": 907759180,
            "serverId": 9999999,
            "machineIdentifier": "fbb8aa6be6e0c997c6268bc2b4431c8807f70a3",
            "name": "ConnectedUserFlix",
            "lastSeenAt": 1556281940,
            "numLibraries": 16,
            "allLibraries": 1,
            "owned": 1,
            "pending": 1
          }
        ],
        "recommendationsPlaylistId": "",
        "filterAll": "",
        "filterMovies": "",
        "filterMusic": "",
        "filterPhotos": "",
        "filterTelevision": ""
      }
    ]
  }
}
{
"errors": [
{
"code": 1000,
"message": "X-Plex-Client-Identifier is missing",
"status": 400
}
]
}
{
"errors": [
{
"code": 1001,
"message": "User could not be authenticated",
"status": 401
}
]
}

Authorizations

X-Plex-Token
string
header
required

The token which identifies the user accessing the PMS. This can be either:

  • A traditional access token obtained from plex.tv
  • A JWT token obtained through the JWT authentication flow

JWT tokens provide better security with:

  • Short-lived tokens (7 days expiration)
  • Public-key cryptography (ED25519)
  • Better clock synchronization
  • Individual device revocation capability

Headers

accepts
enum<string>
default:application/xml

Indicates the client accepts the indicated media types

Available options:
application/json,
application/xml
X-Plex-Client-Identifier
string
required

An opaque identifier unique to the client

Example:

"abc123"

X-Plex-Product
string

The name of the client product

Example:

"Plex for Roku"

X-Plex-Version
string

The version of the client application

Example:

"2.4.1"

X-Plex-Platform
string

The platform of the client

Example:

"Roku"

X-Plex-Platform-Version
string

The version of the platform

Example:

"4.3 build 1057"

X-Plex-Device
string

A relatively friendly name for the client device

Example:

"Roku 3"

X-Plex-Model
string

A potentially less friendly identifier for the device model

Example:

"4200X"

X-Plex-Device-Vendor
string

The device vendor

Example:

"Roku"

X-Plex-Device-Name
string

A friendly name for the client

Example:

"Living Room TV"

X-Plex-Marketplace
string

The marketplace on which the client application is distributed

Example:

"googlePlay"

Response

Successful response with media container data in JSON

MediaContainer
object

Container holding user and server details.