Skip to main content

Quick Start

This guide walks you through your first authenticated request to a Plex Media Server in under five minutes. It includes copy-pasteable examples for curl, Node.js, and Python.

Before you begin

You will need:
  1. The address of your Plex server, for example http://192.168.1.10:32400 or https://plex.example.com.
  2. A valid Plex token. See the Authentication guide if you do not have one yet.
  3. curl, Node.js, or Python installed.

Set environment variables

To keep the examples copy-pasteable, store your server URL and token in environment variables:
export PLEX_SERVER_URL="http://<your-server-ip>:32400"
export PLEX_TOKEN="<your-token>"
Never commit tokens to source control. Use environment variables or a secrets manager in production.

Verify the server is reachable

Plex Media Server exposes server identity and capabilities at the root path. This endpoint does not require a token on most local networks:
curl "$PLEX_SERVER_URL/"
You should receive an XML MediaContainer response with the server name, version, and other metadata. If the request fails, confirm the server address and that the server is running.

List your libraries

List the libraries on your server:
curl -H "X-Plex-Token: $PLEX_TOKEN" \
  -H "Accept: application/json" \
  "$PLEX_SERVER_URL/library/sections"
You should receive a response containing one or more Directory entries representing your libraries.

Request JSON responses

Plex returns XML by default. Add an Accept header to get JSON:
curl -H "X-Plex-Token: $PLEX_TOKEN" \
  -H "Accept: application/json" \
  "$PLEX_SERVER_URL/library/sections"
Many integrations prefer JSON, but some response fields and nested arrays are easier to read in XML. Use whichever format your tooling handles best.

List items in a library

Use the library key from the previous response to list its contents. Replace <library-key> with the value of the key field, for example 1:
curl -H "X-Plex-Token: $PLEX_TOKEN" \
  -H "Accept: application/json" \
  "$PLEX_SERVER_URL/library/sections/<library-key>/all"

Check active sessions

See what is currently playing on the server:
curl -H "X-Plex-Token: $PLEX_TOKEN" \
  -H "Accept: application/json" \
  "$PLEX_SERVER_URL/status/sessions"

Identify your client

When you move beyond experiments, add X-Plex-* headers so the server knows which client is calling. See the Authentication guide for the full list.

Next steps

  • Read the Authentication guide for token management best practices and how to obtain a token.
  • Explore the API Reference for available endpoints and parameters.
  • Learn how to request Accept: application/json and interpret Plex XML responses.