Skip to content
@deckyard/jellyfin

jellyfin cheatsheet

Every export of @deckyard/jellyfin. Guides are listed in the introduction.

jennifer
import "@deckyard/jellyfin/" as jellyfin;

A request the server refused throws HttpError (kind jellyfin.http) with the HTTP status and the validation errors as fields (field -> first message); every other failure is Error{kind: "jellyfin"} (a cancelled task stays "task cancelled"). A c argument is a Client; a query is a list of string of name=value parameters. "Per-user" calls need a user: login, or withUser with an API key.

Constants

ConstantValueMeaning
VERSION"0.1.0"this deck's version, sent in the authorization header
DEFAULT_TIMEOUT_MS30000how long one request may take
DEFAULT_MAX_BYTES16777216the largest response read
MIN_MAJOR10the oldest Jellyfin major version serverInfo accepts
MAX_ITEMS20000the most items allItems reads, about 450 MB with their JSON

The client

FunctionReturnsDoes
jellyfin.client(baseUrl)Clienta client, not signed in; plain http only to this machine
jellyfin.login(c, username, password)Clientsign in; the client carries the token and the user
jellyfin.logout(c)Clientsign out; a login's token stops working (an API key does not)
jellyfin.withToken(c, token)Clientsign in with an access token or API key
jellyfin.withUser(c, userId)Clientact for a user in the per-user calls
jellyfin.withDevice(c, clientName, deviceName, deviceId)Clientthe names and stable id the server shows
jellyfin.withPlainHttp(c)Clientallow plain http to another machine
jellyfin.withTls(c, tls)Clientcertificate options (caCert, skipVerify)
jellyfin.withTimeout(c, ms)Clientthe deadline of one request, 1000 to 86400000 ms
jellyfin.withMaxBytes(c, most)Clientthe largest response, 65536 to 268435456 bytes
jellyfin.call(c, method, path, query, body)json.Valueany other endpoint

The library

FunctionReturnsDoes
jellyfin.libraries(c)list of Libraryper-user; the user's libraries
jellyfin.items(c, query)Pageper-user; one page of items, filtered and sorted by the server
jellyfin.allItems(c, query, most)list of Itemper-user; every matching item, page by page, at most most
jellyfin.item(c, id)Itemper-user; one item
jellyfin.search(c, term, limit)list of Itemper-user; items by name
jellyfin.latest(c, parentId, limit)list of Itemper-user; the latest additions, of one library or all ("")
jellyfin.resume(c, limit)list of Itemper-user; started and not finished
jellyfin.nextUp(c, limit)list of Itemper-user; the next episode of each series in progress
jellyfin.episodes(c, seriesId)list of Itemper-user; every episode of a series that has a file
jellyfin.setPlayed(c, id, played)nullper-user; mark played or not
jellyfin.setFavorite(c, id, favorite)nullper-user; add to or take out of the favourites
jellyfin.image(c, id, type, maxWidth)bytesan item's poster, backdrop, logo, ...
jellyfin.refreshItem(c, id)nulladministrator; rescan an item, filling in missing metadata and images

Administration

FunctionReturnsDoes
jellyfin.serverInfo(c)ServerInfothe server's name and version; no sign-in needed
jellyfin.me(c)Userthe signed-in user
jellyfin.users(c)list of Userthe user accounts the client may see (every one, on a default server)
jellyfin.refreshLibrary(c)nulladministrator; scan every library
jellyfin.tasks(c)list of Taskadministrator; the scheduled tasks
jellyfin.runTask(c, id)nulladministrator; start a task now
jellyfin.sessions(c)list of Sessionthe sessions the server knows, recently active included, and what they play
jellyfin.sendMessage(c, sessionId, header, text, timeoutMs)nullshow a message on a client
jellyfin.playstate(c, sessionId, command)nullpause, resume, stop, skip a client's playback

Types

Client

FieldMeaning
baseUrl as stringthe server's URL without a trailing slash
token as stringthe access token or API key, "" before signing in
userId as stringthe user of the per-user calls, "" when not set
clientName as stringthe client name the server shows
deviceName as stringthe device name the server shows
deviceId as stringthe device id
tls as http.TlsOptionscertificate checks for https
allowPlainHttp as boolplain http to another machine allowed
timeoutMs as intthe deadline of one request
maxBytes as intthe largest response

HttpError

FieldMeaning
kind as stringalways "jellyfin.http"
message as stringjellyfin: <request>: <why> (HTTP nnn)
status as intthe HTTP status, such as 401 or 404
fields as map of string to stringthe validation errors, field -> its first message; empty when none

Item

FieldMeaning
id as stringthe item's id
name as stringits name
type as stringMovie, Series, Season, Episode, MusicAlbum, Audio, Folder, ...
parentId as stringwhat it is in
seriesId as stringan episode's or season's series
seriesName as stringthat series' name
season as intan episode's season number, 0 if none
episode as intan episode's (or track's) number, 0 if none
year as intthe production year, 0 if unknown
runtimeSeconds as intthe length, 0 if unknown
path as stringthe file on the server, "" when not told
played as boolthe user played it
favorite as boola favourite of the user
positionSeconds as intwhere the user stopped
raw as json.Valuethe item as the server sent it

Page

FieldMeaning
items as list of Itemthe items on this page
total as inthow many match in all
start as intthe index of the first on this page

Library

FieldMeaning
id as stringits id, the parentId of what is in it
name as stringits name
collectionType as stringmovies, tvshows, music, ... or ""

ServerInfo

FieldMeaning
name as stringthe server's name
version as stringits version
id as stringits id
productName as stringJellyfin Server
operatingSystem as stringthe host's OS, "" when not told
wizardCompleted as boolthe first-run wizard is done

User

FieldMeaning
id as stringthe user's id
name as stringthe user name
hasPassword as boolthe account has a password
isAdministrator as boolthe user administers the server
isDisabled as boolthe account is disabled
lastLogin as stringthe last sign-in, ISO 8601, "" if never

Task

FieldMeaning
id as stringthe task's id
key as stringits stable key, such as RefreshLibrary
name as stringits name, in the server's language
category as stringits category
state as stringIdle, Running or Cancelling
lastResult as stringCompleted, Failed, Cancelled, Aborted, or ""

Session

FieldMeaning
id as stringthe session's id
userName as stringwho is signed in
client as stringthe application
deviceName as stringthe device
nowPlaying as list of Itemwhat it plays: one item, or nothing
paused as boolplayback is paused
positionSeconds as intthe playback position
remoteControl as boolit takes commands
lastActivity as stringwhen it was last active