Audiobooks
Audiobook operations live under client.audiobooks.
Methods
| Method | Returns | Description |
|---|---|---|
get(id, market=None) |
Audiobook |
Fetch a single audiobook by Spotify ID |
get_several(ids, market=None) |
list[Audiobook] |
Fetch multiple audiobooks (max 50 IDs) |
get_chapters(id, market=None, limit=20, offset=0) |
Page[SimplifiedChapter] |
Fetch chapters for an audiobook |
Market parameter
Pass an ISO 3166-1 alpha-2 country code to market to ensure availability.
Limited availability
Audiobooks are currently available only in select markets.
Examples
import asyncio
from spotify_sdk import AsyncSpotifyClient
async def main() -> None:
async with AsyncSpotifyClient(access_token="your-access-token") as client:
audiobook = await client.audiobooks.get("7iHfbu1YPACw6oZPAFJtqe")
chapters = await client.audiobooks.get_chapters(audiobook.id, limit=10)
asyncio.run(main())
API details
The sync client mirrors these methods, minus the await keywords.
Bases: AsyncBaseService
Operations for Spotify audiobooks.
get(id, market=None)
async
Get an audiobook by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str
|
The Spotify ID for the audiobook. |
required |
market
|
str | None
|
An ISO 3166-1 alpha-2 country code for availability. |
None
|
Returns:
| Type | Description |
|---|---|
Audiobook
|
The requested audiobook. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If id is empty. |
get_chapters(id, market=None, limit=20, offset=0)
async
Get an audiobook's chapters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str
|
The Spotify ID for the audiobook. |
required |
market
|
str | None
|
An ISO 3166-1 alpha-2 country code for availability. |
None
|
limit
|
int
|
Maximum number of chapters to return (1-50, default 20). |
20
|
offset
|
int
|
Index of the first chapter to return. |
0
|
Returns:
| Type | Description |
|---|---|
Page[SimplifiedChapter]
|
Paginated list of chapters. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If id is empty. |
get_several(ids, market=None)
async
Get multiple audiobooks by IDs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ids
|
list[str]
|
List of Spotify audiobook IDs. The Spotify API enforces a maximum of 50 IDs per request. |
required |
market
|
str | None
|
An ISO 3166-1 alpha-2 country code for availability. |
None
|
Returns:
| Type | Description |
|---|---|
list[Audiobook]
|
List of audiobooks. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If ids is empty. |