iTunesSearchAPIClient

class minim.api.apple.iTunesSearchAPIClient(*, enable_cache: bool = True, limit_rate: bool = True, user_agent: str | None = None)[source]

Bases: APIClient

iTunes Search API client.

Parameters:
enable_cachebool; keyword-only; default: True

Whether to enable an in-memory time-to-live (TTL) cache with a least recently used (LRU) eviction policy for this client.

limit_ratebool; keyword-only; default: True

Whether to enable a token bucket rate limiter for this client.

user_agentstr; keyword-only; optional

User-Agent value to include in the headers of HTTP requests.

Methods

clear_cache

Clear specific or all cache entries for this client.

close

Terminate the underlying HTTP client session.

lookup

Get Apple catalog information for albums, artists, audiobooks, ebooks, movies, music, music videos, podcasts, and television shows using their iTunes IDs, All Music Guide (AMG) IDs, Universal Product Codes (UPCs), European Article Numbers (EANs), or International Standard Book Numbers (ISBNs).

open

Initialize a new HTTP client session.

search

Search for audiobooks, ebooks, movies, music, music videos, podcasts, and/or television shows in the Apple catalog.

set_cache_enabled

Enable or disable the in-memory TTL cache for this client.

Attributes

BASE_URL

Base URL for API endpoints.

BASE_URL: str = 'https://itunes.apple.com'

Base URL for API endpoints.

clear_cache(endpoint_methods: str | Callable[..., Any] | Collection[str | Callable[..., Any]] | None = None, /) None

Clear specific or all cache entries for this client.

Warning

If endpoint_methods is not provided, all cache entries are cleared.

Parameters:
endpoint_methodsstr, Callable, or Collection[str | Callable]; positional-only; optional

Endpoint methods whose cache entries should be cleared.

close() None

Terminate the underlying HTTP client session.

lookup(*, itunes_ids: int | str | Collection[int | str] | None = None, amg_album_ids: int | str | Collection[int | str] | None = None, amg_artist_ids: int | str | Collection[int | str] | None = None, amg_video_ids: int | str | Collection[int | str] | None = None, bundle_ids: str | Collection[str] | None = None, isbns: int | str | Collection[int | str] | None = None, barcodes: int | str | Collection[int | str] | None = None, item_type: str | None = None, limit: int | str | None = None, order: str | None = None) dict[str, Any][source]

Get Apple catalog information for albums, artists, audiobooks, ebooks, movies, music, music videos, podcasts, and television shows using their iTunes IDs, All Music Guide (AMG) IDs, Universal Product Codes (UPCs), European Article Numbers (EANs), or International Standard Book Numbers (ISBNs).

Important

Exactly one of itunes_ids, amg_album_ids, amg_artist_ids, amg_video_ids, bundle_ids, isbns, or barcodes must be provided.

Parameters:
itunes_idsint, str, or Collection[int | str]; keyword-only; optional

iTunes IDs.

Examples: 984746615, "1440935756", [984746615, "1440935756"].

amg_album_idsint, str, or Collection[int | str]; keyword-only; optional

AMG album IDs.

Examples: 2025410, "2844399", [2025410, "2844399"].

amg_artist_idsint, str, or Collection[int | str]; keyword-only; optional

AMG artist IDs.

Examples: 472102, "2913530", [472102, "2913530"].

amg_video_idsint, str, or Collection[int | str]; keyword-only; optional

AMG video IDs.

Examples: 17120, "17121", [17122, "17123"].

bundle_idsstr or Collection[str]; keyword-only; optional

App bundle IDs.

Examples: "com.tripadvisor.LocalPicks", ["com.tripadvisor.LocalPicks", "com.yelp.yelpiphone"].

isbnsint, str, or Collection[int | str]; keyword-only; optional

ISBNs.

Examples: 9781637993415, "9781705142110", [9781637993415, "9781705142110"].

barcodesint, str, or Collection[int | str]; keyword-only; optional

Barcodes (UPCs and/or EANs).

Examples: 602448438034, "075678671173", [602448438034, "075678671173"].

item_typestr; keyword-only; optional

Type of item to return.

See also

iTunes Search API documentation (archived) – Available item (or entity) types.

Example: "movieArtist".

limitint; keyword-only; optional

Maximum number of items to return.

Valid range: 1 to 200.

API default: 50.

orderstr; keyword-only; optional

Ordering mode for the items.

Valid value: "recent".

Returns:
itemsdict[str, Any]

Apple metadata for the catalog items.

open() None

Initialize a new HTTP client session.

search(query: str, /, country_code: str, *, media_type: str | None = None, item_type: str | None = None, search_field: str | None = None, limit: int | None = None, locale: str | None = None, api_version: int | None = None, include_explicit: bool | str | None = None) dict[str, Any][source]

Search for audiobooks, ebooks, movies, music, music videos, podcasts, and/or television shows in the Apple catalog.

Parameters:
querystr; positional-only

Search query.

Example: "jack johnson".

countrystr

ISO 3166-1 alpha-2 country code.

media_typestr; keyword-only; optional

Media type to search for.

Valid values: "all", "audiobook", "ebook", "movie", "music", "musicVideo", "podcast", "shortFilm", "software", "tvShow".

API default: "all".

item_typestr; keyword-only; optional

Type of item to return for the given media type.

See also

iTunes Search API documentation (archived) – Available item (or entity) types for each media type.

Example: "movieArtist" when media="movie".

API default: Track item type associated with the media type.

search_fieldstr; keyword-only; optional

Field to search within for the given media type.

See also

iTunes Search API documentation (Apple Services Performance Partner Program) – Available search fields (or attributes) for each media type.

Example: "allArtistTerm" when media="all" and entity="allArtist".

limitint; keyword-only; optional

Maximum number of items to return.

Valid range: 1 to 200.

API default: 50.

localestr; keyword-only; optional

IETF BCP 47 language tag consisting of an ISO 639-1 language code and an ISO 3166-1 alpha-2 country code joined by an underscore. If provided, items are returned in the specified language.

Valid values:

  • "en_us" – English.

  • "ja_jp" – Japanese.

API default: "en_us".

api_versionint; keyword-only; optional

Search result key version.

Valid values: 1, 2.

API default: 2.

include_explicitbool or str; keyword-only; optional

Whether to include explicit content in the results.

Valid values: "Yes" (or True), "No" (or False).

API default: "Yes".

Returns:
resultsdict[str, Any]

Apple metadata for the matching catalog items.

set_cache_enabled(enable: bool, /) None

Enable or disable the in-memory TTL cache for this client.

Parameters:
enablebool; positional-only

Whether to enable the cache.