### Example Source Attributes Source: https://github.com/lukasparke/plex-api-spec/blob/main/description.md Presents example source attributes used as a base for constructing URIs. ```string source="server://546684a3d18ac5c39037360ec9ce900b7af9cc36/com.plexapp.plugins.library" ``` ```string source="provider://tv.plex.provider.podcasts" ``` -------------------------------- ### Example Server and Provider URIs Source: https://github.com/lukasparke/plex-api-spec/blob/main/description.md Illustrates concrete examples of server and provider URIs used for referencing Plex content. ```string server://546684a3d18ac5c39037360ec9ce900b7af9cc36/com.plexapp.plugins.library/library/metadata/2814936 ``` ```string provider://tv.plex.provider.podcasts/library/sections/audio/all ``` -------------------------------- ### add-transcode-target examples Source: https://github.com/lukasparke/plex-api-spec/blob/main/description.md Examples of adding transcode targets for various media profiles including video, music, and subtitles. ```APIDOC ## add-transcode-target ### Description Adds a transcode target for a specific media profile. ### Parameters #### Query Parameters - **type** (string) - Required - The type of profile (e.g., videoProfile, musicProfile, subtitleProfile). - **context** (string) - Required - The context for the transcode (e.g., streaming, all). - **protocol** (string) - Required - The protocol to use (e.g., http). - **container** (string) - Required - The container format (e.g., mkv, flac, webvtt). - **videoCodec** (string) - Optional - The video codec to use (e.g., h264). - **audioCodec** (string) - Optional - The audio codec to use (e.g., aac, ac3, flac). - **subtitleCodec** (string) - Optional - The subtitle codec to use (e.g., srt, webvtt). ### Examples ``` add-transcode-target(type=videoProfile&context=streaming&protocol=http&container=mkv&videoCodec=h264&audioCodec=aac,ac3&subtitleCodec=srt) ``` ``` add-transcode-target(type=musicProfile&context=streaming&protocol=http&container=flac&audioCodec=flac) ``` ``` add-transcode-target(type=subtitleProfile&context=all&protocol=http&container=webvtt&subtitleCodec=webvtt) ``` ``` -------------------------------- ### Example Metadata Objects Source: https://github.com/lukasparke/plex-api-spec/blob/main/description.md Demonstrates how 'type' and 'key' attributes describe fetched elements, with 'type' indicating the returned data format. ```json [ { "key": "/foo", "type": "movie", "title": "A Movie" }, { "key": "/bar", "type": "collection", "title": "My Favorite Movies" }, { "key": "/baz", "type": "show", "title": "A Show" } ] ``` -------------------------------- ### Key Resolution Examples Source: https://github.com/lukasparke/plex-api-spec/blob/main/description.md Demonstrates how API keys are resolved to form full URLs. All requests are treated as though they have a trailing slash. ```text /library/sections/ + home => /library/sections/home /library/sections + home => /library/sections/home /library/sections + /library/sections/home => /library/sections/home ``` -------------------------------- ### Paginated Response Example Source: https://github.com/lukasparke/plex-api-spec/blob/main/description.md Demonstrates a successful paginated HTTP response with relevant headers and a MediaContainer JSON body. ```http HTTP/1.1 200 OK X-Plex-Container-Start: 2 X-Plex-Container-Total-Size: 5 Content-Type: application/xml { "MediaContainer": { "size": 3, "totalSize": 5, "offset": 2, "Metadata" : [ … ] } } ``` -------------------------------- ### PIN Response Example Source: https://github.com/lukasparke/plex-api-spec/blob/main/description.md Example JSON payload received after generating a PIN. The `id` should be stored locally, and the `code` is used to construct the authentication URL. ```json { "id": 564964751, "code": "8lzjqnq8lye02n52jq3fqxf8e", … } ``` -------------------------------- ### Add Direct Play Profile Example Source: https://github.com/lukasparke/plex-api-spec/blob/main/description.md This directive augments the set of Direct Play profiles in the client profile. It specifies video profiles for mp4 and mov containers with AC3 audio codec. ```text add-direct-play-profile(type=videoProfile&container=mp4,mov&videoCodec=*&audioCodec=ac3&subtitleCodec=*) ``` -------------------------------- ### Example Device JWT Payload Source: https://github.com/lukasparke/plex-api-spec/blob/main/description.md An example structure for a device JWT payload, including nonce, scope, audience, issuer, and timestamps. ```json { "nonce": "7c415b56-8f48-488a-98ab-847ef4460442", "scope": "username,email,friendly_name", "aud": "plex.tv", "iss": "your-client-identifier", "iat": 1705785603, "exp": 1705789203 } ``` -------------------------------- ### Grouping Results by Field Source: https://github.com/lukasparke/plex-api-spec/blob/main/description.md Example of grouping tracks by title in descending order of rating count. ```text type=10&sort=ratingCount:desc&group=title ``` -------------------------------- ### Nested Content Directory Example Source: https://github.com/lukasparke/plex-api-spec/blob/main/description.md This JSON structure defines a nested content directory, indicating to the client that it should be treated as a content directory feature entry. It includes key identifiers, type, aspect ratio, and title. ```json { "Directory":[ { "key":"foo", "hubKey":"foo2", "type":"content", "aspectRatio":"1:1", "title":"Genres and Moods" } ] } ``` -------------------------------- ### Get Nonce for Token Refresh Source: https://github.com/lukasparke/plex-api-spec/blob/main/description.md Retrieves a unique nonce from Plex.tv for initiating the JWT token refresh process. The nonce is valid for 5 minutes. ```bash GET https://clients.plex.tv/api/v2/auth/nonce Headers: X-Plex-Client-Identifier: your-device-identifier ``` -------------------------------- ### Get Nonce for Token Refresh Source: https://github.com/lukasparke/plex-api-spec/blob/main/description.md Retrieves a unique nonce required for the JWT token refresh process. ```APIDOC ## GET /api/v2/auth/nonce ### Description Retrieves a unique nonce that is valid for 5 minutes and is required for creating a device JWT during the token refresh process. ### Method GET ### Endpoint https://clients.plex.tv/api/v2/auth/nonce ### Headers - **X-Plex-Client-Identifier** (string) - Required - A unique identifier for your device. ### Response #### Success Response (200) - **nonce** (string) - The unique nonce value. ### Response Example ```json { "nonce": "7c415b56-8f48-488a-98ab-847ef4460442" } ``` ``` -------------------------------- ### Discover Plex Media Server Instances Source: https://github.com/lukasparke/plex-api-spec/blob/main/description.md Use this cURL command to query Plex.tv for available PMS instances associated with your account. Include your client identifier and user token for authentication. Prefer local connections when available. ```shell $ curl \ https://clients.plex.tv/api/v2/resources?includeHttps=1&includeRelay=1&includeIPv6=1 \ -H 'Accept: application/json' \ -H 'X-Plex-Product: My Cool App' \ -H 'X-Plex-Client-Identifier: ' \ -H 'X-Plex-Token: ' ``` -------------------------------- ### Add Settings Source: https://github.com/lukasparke/plex-api-spec/blob/main/description.md Overrides global settings for a profile with specified name/value pairs. ```bash add-settings(DirectPlayStreamSelection=false&RandomAccessDataModel=limited) ``` -------------------------------- ### Use JWT Token for API Request Source: https://github.com/lukasparke/plex-api-spec/blob/main/description.md Demonstrates how to use the obtained JWT token in the X-Plex-Token header for subsequent API requests. ```bash GET https://clients.plex.tv/api/v2/library/sections Headers: X-Plex-Token: your-jwt-token ``` -------------------------------- ### Sorting with Multiple Fields and Features Source: https://github.com/lukasparke/plex-api-spec/blob/main/description.md Demonstrates sorting by multiple fields, including descending order and handling of null values. ```text sort=title,index:desc ``` -------------------------------- ### Constructing Plex Auth App URL Source: https://github.com/lukasparke/plex-api-spec/blob/main/description.md This snippet shows the parameters needed to construct the Plex Auth App URL for initiating the authentication process. Ensure you replace placeholders with your specific client identifier and desired forward URL. ```javascript clientID: '', code: '', forwardUrl: 'https://my-cool-plex-app.com', context: { device: { product: 'My Cool App', }, }, }); ``` -------------------------------- ### Source URI Formats Source: https://github.com/lukasparke/plex-api-spec/blob/main/description.md Defines the structure for server and provider-based source URIs, including placeholders for IDs and paths. ```regex ^(server|provider):\/\/([a-fA-F0-9-]+)?\/?([^\/]+)([\^\?]+)\??(.*)?$ ``` -------------------------------- ### Construct Auth App URL Source: https://github.com/lukasparke/plex-api-spec/blob/main/description.md Construct the Plex authentication app URL by appending parameters to `https://app.plex.tv/auth#?`. The `qs` module can be used to stringify the parameters, including the nested `context` object. ```javascript const authAppUrl = 'https://app.plex.tv/auth#?' + require('qs').stringify({ ``` -------------------------------- ### Register Public Key for JWT Authentication Source: https://github.com/lukasparke/plex-api-spec/blob/main/description.md Registers a device's public key with Plex.tv for JWT authentication. Requires an existing token. ```bash POST https://clients.plex.tv/api/v2/auth/jwk Headers: X-Plex-Client-Identifier: your-device-identifier X-Plex-Token: your-existing-token Body: { "jwk": { "kty": "OKP", "crv": "Ed25519", "x": "your-public-key-data", "use": "sig", "alg": "EdDSA" } } ``` -------------------------------- ### add-settings Source: https://github.com/lukasparke/plex-api-spec/blob/main/description.md Overrides global settings for a profile with specified name/value pairs. ```APIDOC ## add-settings ### Description Overrides global settings for the profile. The parameters are name/value pairs matching existing client profile settings. ### Parameters #### Query Parameters - **name** (string) - Required - The name of the setting to override. - **value** (string) - Required - The new value for the setting. ### Example ``` add-settings(DirectPlayStreamSelection=false&RandomAccessDataModel=limited) ``` ``` -------------------------------- ### Use JWT Token for API Requests Source: https://github.com/lukasparke/plex-api-spec/blob/main/description.md Demonstrates how to use the obtained JWT token for authenticating API requests. ```APIDOC ## Using Your JWT Token Once you have a JWT token, use it exactly like the old tokens in the `X-Plex-Token` header for API requests. ### Example Request ```bash GET https://clients.plex.tv/api/v2/library/sections Headers: X-Plex-Token: your-jwt-token ``` ``` -------------------------------- ### Complex Boolean Expression with Parentheses Source: https://github.com/lukasparke/plex-api-spec/blob/main/description.md Shows how to construct complex boolean expressions using 'push' and 'pop' for parentheses and 'or' for explicit OR operations. ```text push=1&index=1&or=1&rating=2&pop=1&duration=10 ``` -------------------------------- ### Source Attribute Base Format Source: https://github.com/lukasparke/plex-api-spec/blob/main/description.md Shows the structure for a base source attribute, omitting the path component. ```string {SOURCE_TYPE}://{SOURCE_ID}/{PROVIDER_ID?} ``` -------------------------------- ### Add Music Transcode Target Source: https://github.com/lukasparke/plex-api-spec/blob/main/description.md Adds a transcode target for music profiles with specified audio codec and container. ```bash add-transcode-target(type=musicProfile&context=streaming&protocol=http&container=flac&audioCodec=flac) ``` -------------------------------- ### Register Device Public Key Source: https://github.com/lukasparke/plex-api-spec/blob/main/description.md Registers your device's public key (JWK) with Plex.tv for JWT authentication. ```APIDOC ## POST /api/v2/auth/jwk ### Description Registers your device's public key with Plex.tv to enable JWT authentication. ### Method POST ### Endpoint https://clients.plex.tv/api/v2/auth/jwk ### Headers - **X-Plex-Client-Identifier** (string) - Required - A unique identifier for your device. - **X-Plex-Token** (string) - Required - Your existing Plex authentication token. ### Request Body - **jwk** (object) - Required - The JSON Web Key object containing your public key. - **kty** (string) - Required - Key Type (e.g., OKP). - **crv** (string) - Required - Curve (e.g., Ed25519). - **x** (string) - Required - Your public key data. - **use** (string) - Required - Public key use (e.g., sig). - **alg** (string) - Required - Algorithm (e.g., EdDSA). ### Request Example ```json { "jwk": { "kty": "OKP", "crv": "Ed25519", "x": "your-public-key-data", "use": "sig", "alg": "EdDSA" } } ``` ``` -------------------------------- ### Add Video Transcode Target Source: https://github.com/lukasparke/plex-api-spec/blob/main/description.md Adds a transcode target for video profiles with specified codecs and container. ```bash add-transcode-target(type=videoProfile&context=streaming&protocol=http&container=mkv&videoCodec=h264&audioCodec=aac,ac3&subtitleCodec=srt) ``` -------------------------------- ### Generate a Time-Limited PIN Source: https://github.com/lukasparke/plex-api-spec/blob/main/description.md This cURL command creates a time-limited PIN for user sign-in. Use `strong=true` for a longer PIN with a longer lifetime, suitable when the user doesn't need to type it immediately. The response contains `id` and `code` properties. ```bash $ curl -X POST https://plex.tv/api/v2/pins?strong=true \ -H 'Accept: application/json' \ -H 'X-Plex-Product: My Cool App' \ -H 'X-Plex-Client-Identifier: ' ``` -------------------------------- ### Add Subtitle Transcode Target Source: https://github.com/lukasparke/plex-api-spec/blob/main/description.md Adds a transcode target for subtitle profiles with specified subtitle codec and container. ```bash add-transcode-target(type=subtitleProfile&context=all&protocol=http&container=webvtt&subtitleCodec=webvtt) ``` -------------------------------- ### Source Attribute Regex Source: https://github.com/lukasparke/plex-api-spec/blob/main/description.md Provides a regular expression to validate the format of source attributes. ```regex ^(server|provider):\/\/([a-fA-F0-9-]+)?\/?([^\/]+)$ ``` -------------------------------- ### Exchange Device JWT for Plex Token Source: https://github.com/lukasparke/plex-api-spec/blob/main/description.md Exchanges a signed device JWT for a new Plex.tv JWT token. ```APIDOC ## POST /api/v2/auth/token ### Description Exchanges a device-signed JWT, containing a nonce and requested scopes, for a new Plex.tv JWT token valid for 7 days. ### Method POST ### Endpoint https://clients.plex.tv/api/v2/auth/token ### Headers - **X-Plex-Client-Identifier** (string) - Required - A unique identifier for your device. ### Request Body - **jwt** (string) - Required - The device-signed JWT. ### Request Example ```json { "jwt": "your-device-signed-jwt" } ``` ### Response #### Success Response (200) - **auth_token** (string) - The new Plex.tv JWT token. ### Response Example ```json { "auth_token": "eyJraWQiOiJYeVRRN21seXFtVmhJcEo0U1pDZGltdXo3ZjdEYXU1Ym9MLXU2MG5JeEdJIiwidHlwIjoiSldUIiwiYWxnIjoiRWREU0EifQ..." } ``` ``` -------------------------------- ### Boolean OR Operator with Comma Source: https://github.com/lukasparke/plex-api-spec/blob/main/description.md Illustrates using the comma as an OR operator for the 'rating' field, combined with an AND condition for 'index'. ```text rating=1,2,3&index=5 ``` -------------------------------- ### Exchange Device JWT for Plex Token Source: https://github.com/lukasparke/plex-api-spec/blob/main/description.md Exchanges a device-signed JWT for a new Plex.tv JWT token. This is part of the token refresh process. ```bash POST https://clients.plex.tv/api/v2/auth/token Headers: X-Plex-Client-Identifier: your-device-identifier Body: { "jwt": "your-device-signed-jwt" } ``` -------------------------------- ### Verify Access Token Validity Source: https://github.com/lukasparke/plex-api-spec/blob/main/description.md Use this cURL command to check if a user's stored Access Token is valid by requesting user info from the Plex API. A 200 status code indicates a valid token, while a 401 indicates an invalid token. ```bash $ curl -X GET https://plex.tv/api/v2/user \ -H 'Accept: application/json' \ -H 'X-Plex-Product: My Cool App' \ -H 'X-Plex-Client-Identifier: ' \ -H 'X-Plex-Token: ' ``` -------------------------------- ### Polling Plex PIN Status Source: https://github.com/lukasparke/plex-api-spec/blob/main/description.md Use this cURL command to periodically check the status of a Plex PIN. This is part of the Polling authentication flow, where you repeatedly query the PIN's state until it's claimed or authentication fails. ```bash $ curl -X GET 'https://plex.tv/api/v2/pins/' -H 'Accept: application/json' -H 'X-Plex-Client-Identifier: ' ``` -------------------------------- ### Add Transcode Target Codec for HTTP Live Streaming Source: https://github.com/lukasparke/plex-api-spec/blob/main/description.md Adds 'ac3' as an additional audio codec option to a video profile for HTTP Live Streaming transcode targets. This expands the supported audio formats for streaming. ```plaintext add-transcode-target-codec(type=videoProfile&context=streaming&protocol=hls&audioCodec=ac3) ``` -------------------------------- ### Append Transcode Target Codec for HTTP Live Streaming Source: https://github.com/lukasparke/plex-api-spec/blob/main/description.md Appends 'dca' as an additional audio codec to the end of the audioCodec list for a video profile targeting HTTP Live Streaming. This is useful for adding fallback or preferred codecs. ```plaintext append-transcode-target-codec(type=videoProfile&context=streaming&protocol=hls&audioCodec=dca) ``` -------------------------------- ### Add Limitation on AC3 Audio Channels Source: https://github.com/lukasparke/plex-api-spec/blob/main/description.md Adds a limitation to AC3 audio tracks in video media, specifying a maximum of 6 channels. This is useful for enforcing specific audio configurations. ```plaintext add-limitation(scope=videoAudioCodec&scopeName=ac3&type=upperBound&name=audio.channels&value=6) ``` -------------------------------- ### Add Limitation on AC3 Audio Bitrate Source: https://github.com/lukasparke/plex-api-spec/blob/main/description.md Adds a limitation to AC3 audio tracks in video media, specifying a maximum bitrate. This helps in managing bandwidth usage for audio streams. ```plaintext add-limitation(scope=videoAudioCodec&scopeName=ac3&type=upperBound&name=audio.bitrate&value=160) ``` -------------------------------- ### Add Limitation on H264 Video Level Source: https://github.com/lukasparke/plex-api-spec/blob/main/description.md Adds a limitation on H264 video streams, specifying a maximum level and marking it as required. This ensures compatibility with specific playback devices. ```plaintext add-limitation(scope=videoCodec&scopeName=h264&type=upperBound&name=video.level&value=40&isRequired=true) ``` -------------------------------- ### Add Limitation to Transcode Target Source: https://github.com/lukasparke/plex-api-spec/blob/main/description.md Adds a limitation to a specific transcode target, such as limiting the number of audio channels. This allows for fine-grained control over transcoding processes. ```plaintext add-limitation(scope=transcodeTarget&scopeName=MyTranscodeProfile&type=upperBound&name=audio.channels&value=2) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.