Options
All
  • Public
  • Public/Protected
  • All
Menu

Plex Media Server HTTP API Client

This library makes it easier to use the Plex Media Server HTTP API.

This library was written to be used to create fully featured PMS clients, which would allow users to login with a Plex account and select an available server.

It also provides quite a few helper methods in the Library class so you don't have to manually construct the API paths yourself.

Note: This library only support music libraries at the moment, but there is no reason it couldn't support other library types as well.

Usage

First add the library to your project

$ yarn add perplexed

Then create a new client instance. This describes the client that is making the request. You can find more about these options on the node-plex-api README.

const {Client} = require('perplexed')

const client = new Client({
  identifier: 'f5941591-ef73-45e1-99c0-8f3a56941617',
  product: 'Node.js App',
  version: '1.0.0',
  device: 'linux',
  deviceName: 'Node.js App',
  platform: 'Node.js',
  platformVersion: '7.2.0',
})

Now you can create an account instance.

const {Account} = require('perplexed')

const account = new Account(client)

account.authenticate(username, password).then(() => {
  // we now have an auth token
})

Now you can create an server connection.

const {ServerConnection} = require('perplexed')

const uri = 'http://192.168.1.100:32400'
const serverConnection = new ServerConnection(uri, account)

Now use this connection to create a Library, which allows you to do awesome stuff.

const {Library} = require('perplexed')

const library = new Library(serverConnection)

// like get all the playlists in a library
library.playlists().then((playlists) => {
  // do something with playlists
})

Index

Enumerations

Classes

Interfaces

Type aliases

Variables

Functions

Object literals

Type aliases

CountryRecord

CountryRecord: Record<string, number>

GenreRecord

GenreRecord: Record<string, number>

ReturnType

ReturnType<T>: T extends ARTIST ? ArtistContainer : T extends ALBUM ? AlbumContainer : T extends TRACK ? TrackContainer : T extends PLAYLIST ? PlaylistContainer : never

Parse a plex response based on the data type

param

data type

param

response from plex api

returns

Type parameters

  • T

Value

Value: number | string | string[]

Variables

Const DAYS

DAYS: "d" = "d"

Const HOURS

HOURS: "h" = "h"

Const MINUTES

MINUTES: "m" = "m"

Const MONTHS

MONTHS: "mon" = "mon"

Const PLAYLIST_TYPE_MUSIC

PLAYLIST_TYPE_MUSIC: "audio" = "audio"

Const PLAYLIST_TYPE_PHOTO

PLAYLIST_TYPE_PHOTO: "photo" = "photo"

Const PLAYLIST_TYPE_VIDEO

PLAYLIST_TYPE_VIDEO: "video" = "video"

Const PLEX_API

PLEX_API: "https://plex.tv" = "https://plex.tv"

Const SECONDS

SECONDS: "s" = "s"

Const SORT_ALBUMS_BY_ALBUM_ARTIST

SORT_ALBUMS_BY_ALBUM_ARTIST: string[] = sort('artist.titleSort,album.year','artist.titleSort:desc,album.year',)

Const SORT_ALBUMS_BY_DATE_ADDED

SORT_ALBUMS_BY_DATE_ADDED: string[] = sort('addedAt')

Const SORT_ALBUMS_BY_DATE_PLAYED

SORT_ALBUMS_BY_DATE_PLAYED: string[] = sort('lastViewedAt')

Const SORT_ALBUMS_BY_RATING

SORT_ALBUMS_BY_RATING: string[] = sort('userRating')

Const SORT_ALBUMS_BY_RELEASE_DATE

SORT_ALBUMS_BY_RELEASE_DATE: string[] = sort('originallyAvailableAt')

Const SORT_ALBUMS_BY_TITLE

SORT_ALBUMS_BY_TITLE: string[] = sort('titleSort')

Const SORT_ALBUMS_BY_VIEWS

SORT_ALBUMS_BY_VIEWS: string[] = sort('viewCount')

Const SORT_ALBUMS_BY_YEAR

SORT_ALBUMS_BY_YEAR: string[] = sort('year')

Const SORT_ARTISTS_BY_DATE_ADDED

SORT_ARTISTS_BY_DATE_ADDED: string[] = sort('addedAt')

Const SORT_ARTISTS_BY_DATE_PLAYED

SORT_ARTISTS_BY_DATE_PLAYED: string[] = sort('lastViewedAt')

Const SORT_ARTISTS_BY_PLAYS

SORT_ARTISTS_BY_PLAYS: string[] = sort('viewCount')

Const SORT_ARTISTS_BY_TITLE

SORT_ARTISTS_BY_TITLE: string[] = sort('titleSort')

Const SORT_PLAYLISTS_BY_DATE_ADDED

SORT_PLAYLISTS_BY_DATE_ADDED: string[] = sort('addedAt')

Const SORT_PLAYLISTS_BY_DURATION

SORT_PLAYLISTS_BY_DURATION: string[] = sort('duration')

Const SORT_PLAYLISTS_BY_ITEM_COUNT

SORT_PLAYLISTS_BY_ITEM_COUNT: string[] = sort('mediaCount')

Const SORT_PLAYLISTS_BY_LAST_PLAYED

SORT_PLAYLISTS_BY_LAST_PLAYED: string[] = sort('lastViewedAt')

Const SORT_PLAYLISTS_BY_NAME

SORT_PLAYLISTS_BY_NAME: string[] = sort('titleSort')

Const SORT_PLAYLISTS_BY_PLAYS

SORT_PLAYLISTS_BY_PLAYS: string[] = sort('viewCount')

Const SORT_TRACKS_BY_ALBUM

SORT_TRACKS_BY_ALBUM: string[] = sort('album.titleSort,track.index')

Const SORT_TRACKS_BY_ALBUM_ARTIST

SORT_TRACKS_BY_ALBUM_ARTIST: string[] = sort('artist.titleSort,album.titleSort,track.index',)

Const SORT_TRACKS_BY_ARTIST

SORT_TRACKS_BY_ARTIST: string[] = sort('track.originalTitle,album.titleSort,track.index',)

Const SORT_TRACKS_BY_BITRATE

SORT_TRACKS_BY_BITRATE: string[] = sort('mediaBitrate')

Const SORT_TRACKS_BY_DATE_ADDED

SORT_TRACKS_BY_DATE_ADDED: string[] = sort('addedAt')

Const SORT_TRACKS_BY_DURATION

SORT_TRACKS_BY_DURATION: string[] = sort('duration')

Const SORT_TRACKS_BY_PLAYS

SORT_TRACKS_BY_PLAYS: string[] = sort('viewCount')

Const SORT_TRACKS_BY_POPULARITY

SORT_TRACKS_BY_POPULARITY: string[] = sort('ratingCount')

Const SORT_TRACKS_BY_RATING

SORT_TRACKS_BY_RATING: string[] = sort('userRating')

Const SORT_TRACKS_BY_TITLE

SORT_TRACKS_BY_TITLE: string[] = sort('titleSort')

Const SORT_TRACKS_BY_YEAR

SORT_TRACKS_BY_YEAR: string[] = sort('year')

Const WEEKS

WEEKS: "w" = "w"

Const YEARS

YEARS: "y" = "y"

Const albumCollection

albumCollection: FilterValue = new FilterValue('album.collection')

Const albumDecade

albumDecade: FilterNumber = new FilterNumber('album.decade')

Const albumGenre

albumGenre: FilterReference = new FilterReference('album.genre')

Const albumLastPlayed

albumLastPlayed: FilterDate = new FilterDate('album.lastViewdAt')

Const albumPlays

albumPlays: FilterNumber = new FilterNumber('album.viewCount')

Const albumRating

albumRating: FilterNumber = new FilterNumber('album.userRating')

Const albumTitle

albumTitle: FilterString = new FilterString('album.title')

Const artistCollection

artistCollection: FilterValue = new FilterValue('artist.collection')

Const artistCountry

artistCountry: FilterReference = new FilterReference('artist.country')

Const artistGenre

artistGenre: FilterReference = new FilterReference('artist.genre')

Const artistRating

artistRating: FilterNumber = new FilterNumber('artist.userRating')

Const artistTitle

artistTitle: FilterString = new FilterString('artist.title')

Const dateAlbumAdded

dateAlbumAdded: FilterDate = new FilterDate('album.addedAt')

Const dateArtistAdded

dateArtistAdded: FilterDate = new FilterDate('artist.addedAt')

Const trackLastPlayed

trackLastPlayed: FilterDate = new FilterDate('track.viewCount')

Const trackLastSkipped

trackLastSkipped: FilterDate = new FilterDate('track.lastSkippedAt')

Const trackPlays

trackPlays: FilterNumber = new FilterNumber('track.viewCount')

Const trackRating

trackRating: FilterNumber = new FilterNumber('track.userRating')

Const trackSkips

trackSkips: FilterNumber = new FilterNumber('track.skipCount')

Const trackTitle

trackTitle: FilterString = new FilterString('track.title')

Const year

year: FilterNumber = new FilterNumber('album.year')

Functions

Const limit

  • limit(value: number): object
  • Parameters

    • value: number

    Returns object

    • limit: string

normalize

  • normalize<T>(promise: Promise<Record<string, any>>): Promise<Normalized<T>>
  • Type parameters

    • T

    Parameters

    • promise: Promise<Record<string, any>>

    Returns Promise<Normalized<T>>

normalizeSync

  • normalizeSync<T>(data: Record<string, any>): Normalized<T>

parseType

  • parseType<T>(type: T, data: Record<string, any>): ReturnType<T>

Const serialize

  • serialize(value: Value): string

Const sort

  • sort(asc: string, desc?: string): string[]
  • Parameters

    • asc: string
    • Default value desc: string = `${asc}:desc`

    Returns string[]

Object literals

Const availableDateUnits

availableDateUnits: object

__computed

__computed: string = "Years"

Const availableTrackOptions

availableTrackOptions: object

albumCollection

albumCollection: string = "Album Collection"

albumDecade

albumDecade: string = "Album Decade"

albumGenre

albumGenre: string = "Album Genre"

albumLastPlayed

albumLastPlayed: string = "Album Last Played"

albumPlays

albumPlays: string = "Album Plays"

albumRating

albumRating: string = "Album Rating"

albumTitle

albumTitle: string = "Album Title"

artistCollection

artistCollection: string = "Artist Collection"

artistCountry

artistCountry: string = "Artist Country"

artistGenre

artistGenre: string = "Artist Genre"

artistRating

artistRating: string = "Artist Rating"

artistTitle

artistTitle: string = "Artist Title"

dateAlbumAdded

dateAlbumAdded: string = "Date Album Added"

dateArtistAdded

dateArtistAdded: string = "Date Artist Added"

trackLastPlayed

trackLastPlayed: string = "Track Last Played"

trackLastSkipped

trackLastSkipped: string = "Track Last Skipped"

trackPlays

trackPlays: string = "Track Plays"

trackRating

trackRating: string = "Track Rating"

trackSkips

trackSkips: string = "Track Skips"

trackTitle

trackTitle: string = "Track Title"

year

year: string = "Year"

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc