Plex icon

Plex

Interact with Plex Media Server API

Session → Get History

AI-generated

Summary

Retrieve the playback history of sessions from the Plex Media Server, optionally filtered by account ID and library section, and sorted by viewed time.

Inputs

  • Sort — Choose the sort order of the history items, either 'Newest First' (viewedAt descending) or 'Oldest First' (viewedAt ascending). Defaults to 'Newest First'.
  • Account ID — Filter playback history by a specific account ID. Use 0 to include all accounts.
  • Library Section ID — Filter playback history to a specific library section by its ID.
  • Return All — Boolean to return all playback history items matching the filters or limit the number of results.
  • Limit — Maximum number of history items to return when 'Return All' is false. Range: 1 to 500. Default is 50.

Output shape

a list of playback history items in JSON format

If 'Return All' is true, returns all matching history items; otherwise returns up to 'Limit' items. The response includes playback metadata under 'MediaContainer.Metadata'. Filtering by account and library section is supported via query parameters.

Examples

Example 1: Get the 50 most recent playback history items across all accounts and libraries, sorted newest first

Return All is false, Limit is 50, Sort is 'Newest First', Account ID is 0, Library Section ID is empty

Example 2: Get all playback history items sorted oldest first for a specific account and library section

Return All is true, Sort is 'Oldest First', Account ID is set to specific account number, Library Section ID is set to target library

Discussion