Skip to content

API Reference

Generate a login URL for the Audible PKCE OAuth flow.

const { loginUrl, session, cookies } = await login('fr')

Parameters:

NameTypeDescription
localeAudibleLocaleThe Audible marketplace to authenticate against

Returns: Promise<{ loginUrl: string, session: AuthSession, cookies: AudibleCookie[] }>


Complete device registration using the authorization code from the OAuth callback.

const credentials = await register(code, session)
console.log(`Authenticated! Expires: ${credentials.expiresAt}`)

Parameters:

NameTypeDescription
authorizationCodestringThe code from the OAuth callback URL
sessionAuthSessionThe session returned by login()

Returns: Promise<AudibleCredentials>

Throws: Error if registration fails (invalid code, expired session, etc.)


Manually refresh an access token. Usually not needed — all API functions auto-refresh credentials before each call.

const updated = await refresh(credentials)
console.log(`New expiration: ${updated.expiresAt}`)

Parameters:

NameTypeDescription
credentialsAudibleCredentialsCurrent credentials with a valid refreshToken

Returns: Promise<AudibleCredentials> — New credentials with updated accessToken and expiresAt

Throws: Error if the refresh token is invalid


Fetch the user’s entire Audible library with automatic pagination. Credentials are auto-refreshed before the call.

const { items } = await library(credentials)
// Each item has full details: rating, categories, listening progress, etc.
items.map((book) => {
const rating = book.rating?.overallDistribution
console.log(`${book.title}${rating?.averageRating?.toFixed(1)}/5`)
if (book.listeningStatus?.finishedAt) {
console.log(` Finished on ${book.listeningStatus.finishedAt.toLocaleDateString()}`)
}
})

Parameters:

NameTypeDescription
credentialsAudibleCredentialsValid credentials

Returns: Promise<{ items: AudibleItem[], credentials: AudibleCredentials }>

Pagination is automatic — all items are fetched (50 per page).


Fetch the user’s entire Audible wishlist with automatic pagination. Credentials are auto-refreshed before the call.

const { items } = await wishlist(credentials)
items.map((book) =>
console.log(`${book.title}${book.durationMinutes} min — ${book.publisher}`)
)

Parameters:

NameTypeDescription
credentialsAudibleCredentialsValid credentials

Returns: Promise<{ items: AudibleItem[], credentials: AudibleCredentials }>


Search the Audible catalog by category with optional filters. Credentials are auto-refreshed before the call.

// Science Fiction sorted by relevance (default sort)
const { items } = await catalog(credentials, {
category: 'science-fiction',
limit: 20,
})
// Or using raw category ID
const { items: items2 } = await catalog(credentials, {
categoryId: '21229020031',
limit: 20,
})
items.map((book, i) => {
const r = book.rating?.overallDistribution
console.log(
`${i + 1}. ${book.title}${r?.averageRating?.toFixed(1)}/5 (${r?.numRatings} votes)`
)
})

Parameters:

NameTypeDefaultDescription
credentialsAudibleCredentialsValid credentials
options.categoryAudibleGenreGenre name, resolved per locale
options.categoryIdstringRaw category ID (alternative to category)
options.sortBystring'Relevance'Sort order (see below)
options.limitnumber | 'all'50Max results to return. Use 'all' to fetch everything
options.keywordsstringSearch term filter
options.authorstringFilter by author name
options.narratorstringFilter by narrator name

API sorts (fast) — single request, returns limit items: 'Relevance' (default), 'BestSellers', 'AvgRating', 'ReleaseDate', '-ReleaseDate', 'Title'

Client sort (slow): 'MostVoted' — fetches ALL pages (up to 1000 items), sorts by votes desc then rating desc, returns limit items. Can take 10-60 seconds on large categories.

Returns: Promise<{ items: AudibleItem[], credentials: AudibleCredentials }>


Verify that credentials are valid by making a minimal API call. Credentials are auto-refreshed before the call.

try {
await verify(credentials)
console.log('Connected')
} catch {
console.log('Credentials invalid')
}

Parameters:

NameTypeDescription
credentialsAudibleCredentialsCredentials to verify

Returns: Promise<void>

Throws: Error if credentials are invalid or expired


A record mapping each AudibleLocale to its marketplace configuration.

import { AUDIBLE_LOCALES } from 'audible-api-ts'
AUDIBLE_LOCALES['fr']
// { domain: 'fr', marketplaceId: 'A2728XDNODOQ8T', countryCode: 'fr' }
AUDIBLE_LOCALES['com']
// { domain: 'com', marketplaceId: 'AF2M0KC94RCEA', countryCode: 'us' }

Type: Record<AudibleLocale, LocaleConfig>