The Artist class represents an artist in the Spotify catalog, providing methods to interact with the Spotify API for artist-related queries and actions.
-
login:
Optional[Login], optional
A logged-inLoginobject. Required for certain methods. If not provided, some methods will raise aValueError. -
client:
TLSClient, optional
ATLSClientused for making requests to the API. If not provided, a default one will be used. -
language:
str, optional
The language for API responses using ISO 639-1 language codes (e.g., 'ko', 'ja', 'zh', 'en'). Default is 'en'.
__init__(self, login: Login | None = None, *, client: TLSClient = TLSClient("chrome_120", "", auto_retries=3), language: str = "en") -> None
Initializes the Artist class. If a Login object is provided, it checks if the user is logged in. If not, a ValueError is raised.
Changes the language for API requests at runtime.
- Parameters:
language: ISO 639-1 language code (e.g., 'ko', 'ja', 'zh', 'en').
from spotapi import Artist
# Initialize with Korean language
artist_ko = Artist(language="ko")
# Change language at runtime
artist_ko.base.set_language("ja") # Switch to Japanese
# Query artist with Japanese responses
results = artist_ko.get_artist("4tZwfgrHOc3mvqYlEYSvVi")Searches for an artist in the Spotify catalog.
-
Parameters:
query: The search term for the artist.limit: The maximum number of results to return (default is 10).offset: The offset from where to start fetching results (default is 0).
-
Returns: A mapping of the search results.
Fetches detailed information about an artist by ID.
-
Parameters:
artist_id: The Spotify artist ID. Both raw IDs and URIs (artist:xxxxx) are accepted.locale_code: Locale used for language-specific content (default"en").
-
Returns: A mapping containing the artist overview.
Generates artist data in chunks.
-
Parameters:
query: The search term for the artist.
-
Yields: A generator of artist data chunks.
Follows an artist on Spotify.
- Parameters:
artist_id: The ID of the artist to follow.
Unfollows an artist on Spotify.
- Parameters:
artist_id: The ID of the artist to unfollow.