ApiClient. ApiClient

ApiClient provides a centralized, stateful wrapper around the Jellyfin API. It automatically injects image parameters and version-specific fields for consistent, bulletproof item fetching across all Jellyfin server versions (10.7.0+).

The singleton pattern ensures one instance is shared across the entire app.

Constructor

new ApiClient() → {ApiClient}

Returns:
Type: 
ApiClient

Methods

AuthenticateByName(username, password) → {dynamic}

Authenticate user by username and password

Parameters:
NameTypeDescription
usernamestring

User's username

passwordstring

User's password

Returns:

API response with auth token or invalid on error

Type: 
dynamic

BuildAuthenticateWithQuickConnectRequest(secret) → {dynamic}

Build a request AA to exchange an APPROVED Quick Connect secret for an auth token, for use with fetchAsync() / fetchRes().

The body's field name changed at 10.8.0 — a FINER boundary than the V1/V2 apiVersion split, so it reads the server version directly rather than m.getApiVersion(): 10.7.x: { "Token": secret } (QuickConnectDto.Token, required) 10.8.0+: { "Secret": secret } (QuickConnectDto.Secret, required) Confirmed against every published spec from 10.7.0 to 10.11.8 — the rename lands at exactly 10.8.0, with no version carrying both names.

DON'T BRANCH ON THE ERROR CODE HERE. The spec declares only 400 ("Missing token") plus 503 from 10.11.0, but a live 10.11.11 answered 404 for a secret it had not seen approved — an undeclared code. So a non-ok response means "this secret cannot be exchanged" and nothing finer; quickConnectExchangeFailure (source/utils/quickConnect.bs) owns the one distinction worth making.

Parameters:
NameTypeDescription
secretstring

The Quick Connect secret from Initiate

Returns:

Request AA: { method, url, body, headers } or invalid if server URL not set

Type: 
dynamic

BuildCancelSeriesTimerRequest(timerId) → {dynamic}

Build a request AA to cancel a Live TV series recording timer, for use with SubmitSideEffect().

Parameters:
NameTypeDescription
timerIdstring

The series timer ID to cancel

Returns:

Request AA: { method, url } or invalid if server URL not set

Type: 
dynamic

BuildCancelTimerRequest(timerId) → {dynamic}

Build a request AA to cancel a Live TV recording timer, for use with SubmitSideEffect().

Parameters:
NameTypeDescription
timerIdstring

The timer ID to cancel

Returns:

Request AA: { method, url } or invalid if server URL not set

Type: 
dynamic

BuildConnectQuickConnectRequest(secret) → {dynamic}

Build a request AA to poll whether a Quick Connect secret has been approved, for use with fetchAsync() / fetchRes(). Responds 200 with the same QuickConnectResult shape Initiate returned, its Authenticated flag now true once someone approved the code.

An UNKNOWN or EXPIRED secret answers 404 ("Unknown quick connect secret"), declared by EVERY published spec from 10.7.0 to 10.11.8 and corroborated by a live 10.11.11. That is the only signal separating "not approved yet" from "this code is dead", and it is invisible to a caller that only parses the body — which is why this endpoint has to go through the pool (res.statusCode) rather than a sync JSON helper.

Parameters:
NameTypeDescription
secretstring

The Quick Connect secret from Initiate

Returns:

Request AA: { method, url } or invalid if server URL not set

Type: 
dynamic

BuildCreateSeriesTimerRequest(defaults) → {dynamic}

Build a request AA to create a Live TV series recording timer, for use with fetchRes() or fetchJson().

Parameters:
NameTypeDescription
defaultsobject

Timer defaults AA from BuildGetLiveTvTimerDefaultsRequest response

Returns:

Request AA: { method, url, body, headers } or invalid if server URL not set

Type: 
dynamic

BuildCreateTimerRequest(defaults) → {dynamic}

Build a request AA to create a Live TV recording timer, for use with fetchRes() or fetchJson().

Parameters:
NameTypeDescription
defaultsobject

Timer defaults AA from BuildGetLiveTvTimerDefaultsRequest response

Returns:

Request AA: { method, url, body, headers } or invalid if server URL not set

Type: 
dynamic

BuildDeleteItemRequest(itemId) → {dynamic}

Build a request AA to delete an item, for use with SubmitSideEffect().

Parameters:
NameTypeDescription
itemIdstring

The item ID to delete

Returns:

Request AA: { method, url }

Type: 
dynamic

BuildGetAdditionalPartsRequest(itemId) → {dynamic}

Build a request AA for GetAdditionalParts, for use with fetchRes() or fetchJson().

Parameters:
NameTypeDescription
itemIdstring

The video item ID

Returns:

Request AA: { method, url } or invalid if server URL not set

Type: 
dynamic

BuildGetAlbumArtistsRequest(paramsopt) → {dynamic}

Build a request AA to fetch all album artists, for use with fetchRes() or fetchJson(). Mirrors GetAlbumArtists(): applies injectDefaults and injects UserId.

Parameters:
NameTypeAttributesDefaultDescription
paramsobject<optional>
{}

Query parameters

Returns:

Request AA: { method, url } or invalid if no userId

Type: 
dynamic

BuildGetArtistByNameRequest(name, paramsopt) → {dynamic}

Build a request AA for GetArtistByName, for use with fetchJson().

Parameters:
NameTypeAttributesDefaultDescription
namestring

Artist name (will be URI-encoded)

paramsobject<optional>
{}

Optional query parameters

Returns:

Request AA: { method, url } or invalid if server URL not set

Type: 
dynamic

BuildGetArtistSimilarRequest(itemId, paramsopt) → {dynamic}

Build a request AA to get similar artists, for use with fetchRes() or fetchJson().

Parameters:
NameTypeAttributesDefaultDescription
itemIdstring

The artist item ID

paramsobject<optional>
{}

Optional query parameters (userId, limit, etc.)

Returns:

Request AA: { method, url } or invalid if server URL not set

Type: 
dynamic

BuildGetArtistsRequest(paramsopt) → {dynamic}

Build a request AA to fetch all artists, for use with fetchRes() or fetchJson(). Mirrors GetArtists(): applies injectDefaults and injects UserId.

Parameters:
NameTypeAttributesDefaultDescription
paramsobject<optional>
{}

Query parameters

Returns:

Request AA: { method, url } or invalid if no userId

Type: 
dynamic

BuildGetBrandingConfigurationRequest() → {dynamic}

Build a request AA for GetBrandingConfiguration, for use with fetchRes() or fetchJson().

Returns:

Request AA: { method, url } or invalid if server URL not set

Type: 
dynamic

BuildGetEpisodesRequest(seriesId, paramsopt) → {dynamic}

Build a request AA for GetEpisodes, for use with fetchRes() or fetchJson().

Parameters:
NameTypeAttributesDefaultDescription
seriesIdstring

The series ID

paramsobject<optional>
{}

Optional query parameters (StartItemId, Limit, etc.)

Returns:

Request AA: { method, url } or invalid if no user

Type: 
dynamic

BuildGetFiltersRequest(paramsopt) → {dynamic}

Build a request AA for GetFilters, for use with fetchRes() or fetchJson().

Parameters:
NameTypeAttributesDefaultDescription
paramsobject<optional>
{}

Query parameters (userid, parentid, includeitemtypes, etc.)

Returns:

Request AA: { method, url } or invalid if server URL not set

Type: 
dynamic

BuildGetGenresRequest(paramsopt) → {dynamic}

Build a request AA to fetch genres, for use with fetchRes() or fetchJson().

Parameters:
NameTypeAttributesDefaultDescription
paramsobject<optional>
{}

Query parameters

Returns:

Request AA: { method, url } or invalid if server URL not set

Type: 
dynamic

BuildGetInstantMixRequest(itemId, paramsopt) → {dynamic}

Build a request AA for GetInstantMix, for use with fetchJson().

Parameters:
NameTypeAttributesDefaultDescription
itemIdstring

The item ID

paramsobject<optional>
{}

Optional query parameters (Limit, etc.)

Returns:

Request AA: { method, url } or invalid if no user

Type: 
dynamic

BuildGetIntrosRequest(itemId) → {dynamic}

Build a request AA for GetIntros, for use with fetchJson().

Parameters:
NameTypeDescription
itemIdstring

The item ID

Returns:

Request AA: { method, url } or invalid if no user

Type: 
dynamic

BuildGetItemLyricsRequest(itemId) → {dynamic}

Build a request AA for GetItemLyrics, for use with fetchJson().

Parameters:
NameTypeDescription
itemIdstring

The Audio item ID

Returns:

Request AA: { method, url } or invalid if server URL not set

Type: 
dynamic

BuildGetItemRawRequest(itemId, paramsopt) → {dynamic}

Build a request AA to get a single item WITHOUT image/version field injection.

Parameters:
NameTypeAttributesDefaultDescription
itemIdstring

The item ID

paramsobject<optional>
{}

Optional query parameters (passed through as-is)

Returns:

Request AA: { method, url } or invalid if no user

Type: 
dynamic

BuildGetItemRequest(itemId, paramsopt) → {dynamic}

Get a single item by ID with automatic image and version field injection Build a request AA to get a single item with automatic image/version field injection.

Parameters:
NameTypeAttributesDefaultDescription
itemIdstring

The item ID

paramsobject<optional>
{}

Optional query parameters (fields, etc.)

Returns:

Request AA: { method, url } or invalid if no user

Type: 
dynamic

BuildGetItemsByQueryRequest(paramsopt) → {dynamic}

Build a request AA for GetItemsByQuery, for use with fetchRes() or fetchJson().

Parameters:
NameTypeAttributesDefaultDescription
paramsobject<optional>
{}

Query parameters (limit, sortBy, filters, etc.)

Returns:

Request AA: { method, url } or invalid if no user

Type: 
dynamic

BuildGetLatestMediaRequest(paramsopt) → {dynamic}

Build a request AA for GetLatestMedia, for use with fetchRes() or fetchJson(). Both V1 and V2 return a bare array of BaseItemDto (not paginated). V1: /users/{id}/items/latest (10.7.x–10.8.x) V2: /Items/Latest?userId= (10.9+)

Parameters:
NameTypeAttributesDefaultDescription
paramsobject<optional>
{}

Optional query parameters (ParentId, Limit, etc.)

Returns:

Request AA: { method, url } or invalid if no userId

Type: 
dynamic

BuildGetLiveTVChannelsRequest(paramsopt) → {dynamic}

Build a request AA to fetch Live TV channels, for use with fetchRes() or fetchJson().

Parameters:
NameTypeAttributesDefaultDescription
paramsobject<optional>
{}

Query parameters

Returns:

Request AA: { method, url } or invalid if server URL not set

Type: 
dynamic

BuildGetLiveTVProgramsRequest(paramsopt) → {dynamic}

Build a request AA for GetLiveTVPrograms (full EPG search), for use with fetchRes() or fetchJson(). Mirrors GetLiveTVPrograms(): applies injectDefaults.

Parameters:
NameTypeAttributesDefaultDescription
paramsobject<optional>
{}

Query parameters (SearchTerm, Limit, etc.)

Returns:

Request AA: { method, url } or invalid if server URL not set

Type: 
dynamic

BuildGetLiveTvProgramRequest(programId, paramsopt) → {dynamic}

Build a request AA to fetch a single Live TV program, for use with fetchRes() or fetchJson().

Parameters:
NameTypeAttributesDefaultDescription
programIdstring

The program ID

paramsobject<optional>
{}

Optional query parameters (UserId, etc.)

Returns:

Request AA: { method, url } or invalid if server URL not set

Type: 
dynamic

BuildGetLiveTvRecommendedProgramsRequest(paramsopt) → {dynamic}

Build a request AA to get recommended Live TV programs (On Now), for use with fetchRes() or fetchJson().

Parameters:
NameTypeAttributesDefaultDescription
paramsobject<optional>
{}

Query parameters (userId, isAiring, limit, etc.)

Returns:

Request AA: { method, url } or invalid if server URL not set

Type: 
dynamic

BuildGetLiveTvRecordingsRequest(paramsopt) → {dynamic}

Build a request AA to get Live TV recordings, for use with fetchRes() or fetchJson().

Parameters:
NameTypeAttributesDefaultDescription
paramsobject<optional>
{}

Query parameters (isInProgress, limit, status, etc.)

Returns:

Request AA: { method, url } or invalid if server URL not set

Type: 
dynamic

BuildGetLiveTvScheduleRequest(params) → {dynamic}

Build a request AA to fetch the Live TV schedule, for use with fetchRes() or fetchJson(). Uses POST because the channelIds list can exceed URL length limits.

Parameters:
NameTypeDescription
paramsobject

Query/body parameters (channelIds, startTime, endTime, UserId, etc.)

Returns:

Request AA: { method, url, body, headers } or invalid if server URL not set

Type: 
dynamic

BuildGetLiveTvTimerDefaultsRequest(programId) → {dynamic}

Build a request AA to fetch Live TV timer defaults for a program, for use with fetchRes() or fetchJson().

Parameters:
NameTypeDescription
programIdstring

The program ID to pre-fill timer defaults

Returns:

Request AA: { method, url } or invalid if server URL not set

Type: 
dynamic

BuildGetLocalTrailersRequest(itemId) → {dynamic}

Build a request AA for GetLocalTrailers, for use with submitApiRequest() or fetchJson(). Version-aware: V2 uses /Items/{id}/LocalTrailers, V1 uses /users/{userId}/items/{id}/localtrailers.

Parameters:
NameTypeDescription
itemIdstring

The item ID

Returns:

Request AA: { method, url } or invalid if no userId (V1 only)

Type: 
dynamic

BuildGetMediaSegmentsRequest(itemId, includeSegmentTypesopt) → {dynamic}

Build a request AA for GetMediaSegments, for use with fetchJson(). Only available on Jellyfin 10.10.0+ servers.

Parameters:
NameTypeAttributesDefaultDescription
itemIdstring

The item ID

includeSegmentTypesstring<optional>
""

Optional comma-separated segment types to filter (e.g., "Intro,Outro")

Returns:

Request AA: { method, url } or invalid if server URL not set

Type: 
dynamic

BuildGetNextUpRequest(paramsopt) → {dynamic}

Build a request AA for GetNextUp, for use with fetchRes() or fetchJson(). Mirrors GetNextUp(): applies injectDefaults and injects UserId.

Parameters:
NameTypeAttributesDefaultDescription
paramsobject<optional>
{}

Query parameters (SeriesId, limit, EnableRewatching, etc.)

Returns:

Request AA: { method, url } or invalid if no userId

Type: 
dynamic

BuildGetPersonsRequest(paramsopt) → {dynamic}

Build a request AA for GetPersons, for use with fetchRes() or fetchJson(). Mirrors GetPersons(): applies injectDefaults and injects UserId.

Parameters:
NameTypeAttributesDefaultDescription
paramsobject<optional>
{}

Query parameters (e.g. IsFavorite, searchTerm)

Returns:

Request AA: { method, url } or invalid if no userId

Type: 
dynamic

BuildGetPlaylistItemsRequest(playlistId, paramsopt) → {dynamic}

Build a request AA for GetPlaylistItems, for use with fetchRes() or fetchJson().

Parameters:
NameTypeAttributesDefaultDescription
playlistIdstring

The playlist ID

paramsobject<optional>
{}

Optional query parameters

Returns:

Request AA: { method, url } or invalid if no user

Type: 
dynamic

BuildGetQuickConnectEnabledRequest() → {dynamic}

Build a request AA for GetQuickConnectEnabled, for use with fetchRes() or fetchJson(). Server responds with a plain boolean body (true = enabled, false = disabled). Lowercase path matches the existing /quickconnect/initiate convention - Jellyfin's routing is case-insensitive but reverse proxies in the wild sometimes are not.

Returns:

Request AA: { method, url } or invalid if server URL not set

Type: 
dynamic

BuildGetResumeItemsRequest(paramsopt) → {dynamic}

Build a request AA for GetResumeItems (Continue Watching), for use with fetchRes() or fetchJson(). Mirrors GetResumeItems(): applies injectDefaults, version-aware endpoint.

The server hardcodes Recursive, OrderBy=DatePlayed and IsResumable on this endpoint, so MediaTypes is the ONLY narrowing a client controls — don't bother sending recursive / SortBy / SortOrder / Filters, they are ignored. Since 12.0 a folder also matches IsResumable when a descendant is in progress, so an unfiltered query returns Seasons and Series (by design) mixed in with the episodes. Every JellyRock resume flow is video, so default to Video; pass MediaTypes as a comma-separated STRING to widen it.

Parameters:
NameTypeAttributesDefaultDescription
paramsobject<optional>
{}

Optional query parameters

Returns:

Request AA: { method, url } or invalid if no userId

Type: 
dynamic

BuildGetSeasonsRequest(seriesId, paramsopt) → {dynamic}

Build a request AA for GetSeasons, for use with fetchRes() or fetchJson(). Mirrors GetSeasons(): applies injectDefaults and injects UserId.

Parameters:
NameTypeAttributesDefaultDescription
seriesIdstring

The series ID

paramsobject<optional>
{}

Optional query parameters

Returns:

Request AA: { method, url } or invalid if no userId

Type: 
dynamic

BuildGetSessionsRequest(paramsopt) → {dynamic}

Build a request AA to get active sessions, for use with fetchJson().

Parameters:
NameTypeAttributesDefaultDescription
paramsobject<optional>
{}

Query parameters (e.g. { deviceId: "..." })

Returns:

Request AA: { method, url } or invalid if server URL not set

Type: 
dynamic

BuildGetSimilarItemsRequest(itemId, paramsopt) → {dynamic}

Build a request AA to get similar items, for use with fetchRes() or fetchJson().

Parameters:
NameTypeAttributesDefaultDescription
itemIdstring

The item ID

paramsobject<optional>
{}

Optional query parameters (userId, limit, etc.)

Returns:

Request AA: { method, url } or invalid if server URL not set

Type: 
dynamic

BuildGetSpecialFeaturesRequest(itemId) → {dynamic}

Build a request AA for GetSpecialFeatures, for use with fetchRes() or fetchJson(). Mirrors GetSpecialFeatures(): version-aware endpoint.

Parameters:
NameTypeDescription
itemIdstring

The item ID

Returns:

Request AA: { method, url } or invalid if no userId (V1 only)

Type: 
dynamic

BuildGetStudiosRequest(paramsopt) → {dynamic}

Build a request AA to fetch studios, for use with fetchRes() or fetchJson().

Parameters:
NameTypeAttributesDefaultDescription
paramsobject<optional>
{}

Query parameters

Returns:

Request AA: { method, url } or invalid if server URL not set

Type: 
dynamic

BuildGetViewsRequest() → {dynamic}

Build a request AA for GetViews, for use with fetchRes() or fetchJson(). Mirrors GetViews(): version-aware endpoint.

Returns:

Request AA: { method, url } or invalid if no userId

Type: 
dynamic

BuildHeadItemImageRequest(id, imageType, imageIndexopt) → {dynamic}

Build a HEAD request AA to check if an item image exists, for use with fetchRes() or fetchJson(). Caller checks res.ok — no body is returned for HEAD requests.

Parameters:
NameTypeAttributesDefaultDescription
idstring

Item ID

imageTypestring

Type of image (e.g. "logo", "Primary")

imageIndexinteger<optional>
0

Image index (default 0)

Returns:

Request AA: { method, url } or invalid if server URL not set

Type: 
dynamic

BuildInitiateQuickConnectRequest() → {dynamic}

Build a request AA to start a Quick Connect request, for use with fetchAsync() / fetchRes(). The response carries the Secret we poll with and the Code the user types on their other device.

The HTTP METHOD moved at the same boundary as the apiVersion split: apiVersion 1 (10.7.0 - 10.8.13): GET (no POST route exists) apiVersion 2 (10.9.0+): POST (no GET route exists) Confirmed against every published spec from 10.7.0 to 10.11.8: each version declares exactly one of the two verbs, and the swap is at exactly 10.9.0.

Sending the wrong method to a modern server yields 401 ("Quick connect is not active on this server"), which reads as a feature gate but is actually a route mismatch — so the dispatch is load-bearing, not cosmetic. That collision is also why quickConnectInitiateFailure treats 401 as "disabled": it is the same code either way, and a route mismatch is our bug, not something to tell a user.

Returns:

Request AA: { method, url } or invalid if server URL not set

Type: 
dynamic

BuildMarkFavoriteRequest(itemId) → {dynamic}

Build a request AA to mark an item as favorite, for use with SubmitSideEffect().

Parameters:
NameTypeDescription
itemIdstring

The item ID

Returns:

Request AA: { method, url } or invalid if no user

Type: 
dynamic

BuildMarkPlayedRequest(itemId) → {dynamic}

Build a request AA to mark an item as played, for use with SubmitSideEffect(). Includes default DatePlayed (now) and PlaybackPositionTicks (0) matching Jellyfin API expectations.

Parameters:
NameTypeDescription
itemIdstring

The item ID

Returns:

Request AA: { method, url } or invalid if no user

Type: 
dynamic

BuildPlaystateRequest(state, params) → {dynamic}

Build a playstate request AA for use with SubmitSideEffect(). Applies default playstate fields and routes to the correct session endpoint.

Parameters:
NameTypeDescription
statestring

"start" | "update" | "stop" | "finished"

paramsobject

Playback parameters (ItemId, PositionTicks, IsPaused, etc.)

Returns:

Request AA: { method, url, body, headers } or invalid if state unknown

Type: 
dynamic

BuildPostPlaybackInfoRequest(itemId, postData) → {dynamic}

Build a request AA for PostPlaybackInfo, for use with fetchJson().

Parameters:
NameTypeDescription
itemIdstring

The item ID

postDataobject

Request body data (DeviceProfile, MediaSourceId, etc.)

Returns:

Request AA: { method, url, body } or invalid if server URL not set

Type: 
dynamic

BuildPostSessionCapabilitiesRequest(capabilities) → {dynamic}

Build a request AA to post full session capabilities, for use with SubmitSideEffect().

Parameters:
NameTypeDescription
capabilitiesobject

Device capabilities AA from getDeviceCapabilities()

Returns:

Request AA: { method, url, body, headers } or invalid if server URL not set

Type: 
dynamic

BuildUnmarkFavoriteRequest(itemId) → {dynamic}

Build a request AA to unmark an item as favorite, for use with SubmitSideEffect().

Parameters:
NameTypeDescription
itemIdstring

The item ID

Returns:

Request AA: { method, url } or invalid if no user

Type: 
dynamic

BuildUnmarkPlayedRequest(itemId) → {dynamic}

Build a request AA to mark an item as unplayed, for use with SubmitSideEffect().

Parameters:
NameTypeDescription
itemIdstring

The item ID

Returns:

Request AA: { method, url } or invalid if no user

Type: 
dynamic

GetConfigurationByName(name) → {dynamic}

Get configuration by name

Parameters:
NameTypeDescription
namestring

Configuration name

Returns:

API response or invalid on error

Type: 
dynamic

GetDisplayPreferences(id, paramsopt) → {dynamic}

Get display preferences

Parameters:
NameTypeAttributesDefaultDescription
idstring

Preference ID

paramsobject<optional>
{}

Query parameters

Returns:

API response or invalid on error

Type: 
dynamic

GetImageURL(id, imageType, imageIndexopt, paramsopt) → {dynamic}

Get image URL

Parameters:
NameTypeAttributesDefaultDescription
idstring

Item ID

imageTypestring

Type of image

imageIndexinteger<optional>
0

Image index

paramsobject<optional>
{}

Optional parameters

Returns:

API response or invalid on error

Type: 
dynamic

GetPublicUsers() → {dynamic}

Get public users

Returns:

API response or invalid on error

Type: 
dynamic

GetUser(userId) → {dynamic}

Get user by ID

Parameters:
NameTypeDescription
userIdstring

The user ID

Returns:

API response or invalid on error

Type: 
dynamic

GetUserImageURL(id, imageType, imageIndexopt, paramsopt) → {dynamic}

Get user image URL

Parameters:
NameTypeAttributesDefaultDescription
idstring

User ID

imageTypestring

Type of image

imageIndexinteger<optional>
0

Image index

paramsobject<optional>
{}

Optional parameters

Returns:

API response or invalid on error

Type: 
dynamic