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
endpackage 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
}
]
}Get list of all connected users
Get list of all users that are friends and have library access with the provided Plex authentication token
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
endpackage 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
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
Indicates the client accepts the indicated media types
application/json, application/xml An opaque identifier unique to the client
"abc123"
The name of the client product
"Plex for Roku"
The version of the client application
"2.4.1"
The platform of the client
"Roku"
The version of the platform
"4.3 build 1057"
A relatively friendly name for the client device
"Roku 3"
A potentially less friendly identifier for the device model
"4200X"
The device vendor
"Roku"
A friendly name for the client
"Living Room TV"
The marketplace on which the client application is distributed
"googlePlay"
Response
Successful response with media container data in JSON
Container holding user and server details.
Show child attributes
Show child attributes
Was this page helpful?