### Start Playback Source: https://minim.readthedocs.io/en/latest/_modules/minim/spotify Starts or resumes playback on the user's active device. Requires the 'user-modify-playback-state' scope. Supports starting playback with a context URI, track URIs, an offset, and/or a specific position in milliseconds. ```python def start_playback( self, *, device_id: str = None, context_uri: str = None, uris: list[str] = None, offset: dict[str, Any], position_ms: int = None, ) -> None: """ `Player > Start/Resume Playback `_: Start a new context or resume current playback on the user's active device. .. admonition:: Authorization scope :class: warning Requires the :code:`user-modify-playback-state` scope. Parameters ---------- device_id : `str`, keyword-only, optional The ID of the device this method is targeting. If not supplied, the user's currently active device is the target. **Example**: :code:`"0d1841b0976bae2a3a310dd74c0f3df354899bc8"`. context_uri : `str`, keyword-only, optional Spotify URI of the context to play. Only album, artist, and playlist contexts are valid. **Example**: :code:`"spotify:album:1Je1IMUlBXcx1Fz0WE7oPT"`. uris : `list`, keyword-only, optional A JSON array of the Spotify track URIs to play. **Example**: :code:`["spotify:track:4iV5W9uYEdYUVa79Axb7Rh", "spotify:track:1301WleyT98MSxVHPZCA6M"]`. offset : `dict`, keyword-only, optional Indicates from where in the context playback should start. Only available when `context_uri` corresponds to an album or a playlist. .. container:: **Valid values**: * The value corresponding to the :code:`"position"` key is zero-based and can't be negative. * The value corresponding to the :code:`"uri"` key is a string representing the URI of the item to start at. **Examples**: * :code:`{"position": 5}` to start playback at the sixth item of the collection specified in `context_uri`. * :code:`{"uri": }` to start playback at the item designated by the URI. position_ms : `int`, keyword-only, optional The position in milliseconds to seek to. Passing in a position that is greater than the length of the track will cause the player to start playing the next song. **Valid values**: `position_ms` must be a positive number. """ self._check_scope("start_playback", "user-modify-playback-state") json = {} if context_uri is not None: json["context_uri"] = context_uri if uris is not None: json["uris"] = uris if offset is not None: json["offset"] = offset if position_ms is not None: json["position_ms"] = position_ms self._request( "put", f"{self.API_URL}/me/player/play", params={"device_id": device_id}, json=json, ) ``` -------------------------------- ### Get Spotify Recommendations and Create Playlist Source: https://minim.readthedocs.io/en/latest/notebooks/user_guide/getting_recommendations This snippet demonstrates how to get track recommendations from Spotify using a list of seed tracks and then create a private playlist with these recommendations. It also includes adding a custom cover image to the playlist. Dependencies include the 'random' module for track selection and 'b64encode' for image encoding. ```python import random from base64 import b64encode # Assuming 'client_spotify' is an initialized Spotify API client # and 'seed_tracks' is a list of Spotify track IDs. seed_tracks = [ "2V65y3PX4DkRhy1djlxd9p", # Swedish House Mafia - Don't You Worry Child (feat. John Martin) "1gpF8IwQQj8qOeVjHfIIDU" # Zedd - Find You (feat. Matthew Koma & Miriam Bryant) ] recommended_tracks = client_spotify.get_recommendations( seed_tracks=random.choices(seed_tracks, k=5) ){"tracks"} spotify_playlist = client_spotify.create_playlist("Minim Mix", public=False) client_spotify.add_playlist_items( spotify_playlist["id"], [f"spotify:track:{track['id']}" for track in recommended_tracks] ) # This part assumes access to the current working directory's parent structure. # It's illustrative and might need adjustment based on actual file paths. # For example: # from pathlib import Path # import os # base_path = Path(os.getcwd()).parents[3] # with open(base_path / "assets/minim_mix_small.jpg", "rb") as f: # client_spotify.add_playlist_cover_image(spotify_playlist["id"], b64encode(f.read())) ``` -------------------------------- ### Spotify Web API Setup Source: https://minim.readthedocs.io/en/latest/notebooks/getting_started Instructions for setting up and using the Spotify Web API client, with options for client credentials only or user authentication. ```APIDOC ## Spotify Web API (`minim.spotify.WebAPI`) ### Description This section covers the setup and usage of the Spotify Web API client within the minim library. You can initialize the client using either client credentials or by authenticating a user. ### Initialization with Client Credentials To use the Spotify Web API without user authentication, provide your Spotify application's client ID and client secret to the constructor. Alternatively, these can be set as environment variables (`SPOTIFY_CLIENT_ID`, `SPOTIFY_CLIENT_SECRET`). ### Method Constructor ### Endpoint N/A (Client-side setup) ### Parameters #### Keyword Arguments for Constructor - **access_token** (string) - Optional - An existing access token. - **refresh_token** (string) - Optional - The accompanying refresh token. - **expiry** (datetime) - Optional - The expiry time of the access token. - **client_id** (string) - Optional - Your Spotify application's client ID. Required if not set as environment variable. - **client_secret** (string) - Optional - Your Spotify application's client secret. Required if not set as environment variable. - **port** (int) - Optional - The port to use for the callback URI if not the default `8888`. ### Initialization with User Authentication (PKCE Flow) For user authentication, you need to obtain authorization scopes, set up the client with PKCE flow, and handle the authorization process. ### Method Constructor with specific arguments ### Endpoint N/A (Client-side setup) ### Parameters #### Keyword Arguments for Constructor - **client_id** (string) - Required - Your Spotify application's client ID. - **client_secret** (string) - Required - Your Spotify application's client secret. - **flow** (string) - Required - Set to `"pkce"` for Proof Key for Code Exchange flow. - **scopes** (list) - Required - A list of authorization scopes obtained using `spotify.WebAPI.get_scopes()`. - **framework** (string) - Optional - Set to `"http.server"` to automate callback retrieval, or `None` to handle manually. ### Example (Client Credentials) ```python # Using explicit client ID and secret client_spotify = spotify.WebAPI(client_id='', \ client_secret='') # Using environment variables client_spotify = spotify.WebAPI() ``` ### Example (User Authentication - PKCE Flow) ```python # Get scopes scopes = spotify.WebAPI.get_scopes("all") # Initialize client with framework for automated callback client_spotify = spotify.WebAPI(client_id='', \ client_secret='',\ flow='pkce',\ scopes=scopes,\ framework='http.server') # If framework is None, manual handling of redirect URI is required. ``` ### Response N/A (Client initialization, actual API responses depend on subsequent calls.) ``` -------------------------------- ### Get Followed Artists Source: https://minim.readthedocs.io/en/latest/api/minim.spotify.WebAPI Retrieves the current user's followed artists, with options to paginate results and specify a starting point. ```APIDOC ## GET /users/{id}/following ### Description Get the current user’s followed artists. Requires the `user-follow-read` scope. ### Method GET ### Endpoint /users/{id}/following ### Parameters #### Query Parameters - **after** (str) - Optional - The last artist ID retrieved from the previous request. Example: `"0I2XqVXqHScXjHhk6AYYRe"` - **limit** (int) - Optional - The maximum number of results to return. Valid values: 0 to 50. Default: `20`. ### Response #### Success Response (200) - **artists** (dict) - A dictionary containing Spotify catalog information for a user’s followed artists and the number of results returned. #### Response Example { "href": "", "limit": , "next": "", "cursors": { "after": "", "before": "" }, "total": , "items": [ { "external_urls": { "spotify": "" }, "followers": { "href": "", "total": }, "genres": [], "href": "", "id": "", "images": [ { "url": "", "height": , "width": } ], "name": "", "popularity": , "type": "artist", "uri": "" } ] } ``` -------------------------------- ### Get Qobuz Favorites (Albums and Artists) Source: https://minim.readthedocs.io/en/latest/notebooks/user_guide/transferring_music_libraries Fetches the current user's favorite albums and artists from Qobuz. This is the starting point for synchronizing library content to other services. ```python qobuz_favorites = client_qobuz.get_favorites() qobuz_favorite_albums = qobuz_favorites["albums"]["items"] qobuz_favorite_artists = qobuz_favorites["artists"]["items"] ``` -------------------------------- ### TIDAL API Setup Source: https://minim.readthedocs.io/en/latest/notebooks/getting_started Instructions for setting up and using the TIDAL API client. ```APIDOC ## TIDAL API (`minim.tidal.API`) ### Description This section details the initialization of the TIDAL API client using your application's credentials. ### Method Constructor ### Endpoint N/A (Client-side setup) ### Parameters #### Keyword Arguments for Constructor - **access_token** (string) - Optional - An existing access token. - **refresh_token** (string) - Optional - The accompanying refresh token. - **expiry** (datetime) - Optional - The expiry time of the access token. - **client_id** (string) - Required if not set as environment variable - Your TIDAL application's client ID. - **client_secret** (string) - Required if not set as environment variable - Your TIDAL application's client secret. ### Example (Client Credentials) ```python # Using explicit client ID and secret client_tidal = tidal.API(client_id='', \ client_secret='') # Using environment variables client_tidal = tidal.API() ``` ### Response N/A (Client initialization, actual API responses depend on subsequent calls.) ``` -------------------------------- ### Lookup Items by AMG ID (Python) Source: https://minim.readthedocs.io/en/latest/_modules/minim/itunes This example shows how to use the iTunes API lookup function with AMG (All Media Guide) IDs. It supports looking up single artists by `amg_artist_id`, multiple artists by a list of `amg_artist_id`, and albums by `amg_album_id`. ```python >>> itunes.lookup(amg_artist_id=468749) >>> itunes.lookup(amg_artist_id=[468749, 5723]) >>> itunes.lookup(amg_album_id=[15175, 15176, 15177, 15178, 15183, 15184, 15187, 15190, 15191, 15195, 15197, 15198]) ``` -------------------------------- ### Instantiate Minim API Clients Source: https://minim.readthedocs.io/en/latest/notebooks/user_guide/editing_audio_metadata Demonstrates how to create client instances for interacting with the iTunes, Spotify, and TIDAL APIs. These clients are essential for fetching album and track metadata from these services. ```python client_itunes = itunes.SearchAPI() client_spotify = spotify.WebAPI() client_tidal = tidal.PrivateAPI() ``` -------------------------------- ### Get Spotify Albums with Limit and Offset Source: https://minim.readthedocs.io/en/latest/api/minim.spotify.WebAPI Retrieves a list of Spotify albums. Supports pagination using 'limit' for the number of results per page and 'offset' for the starting index. The 'limit' must be between 0 and 50, with a default of 20. The 'offset' must be between 0 and 1000, with a default of 0. ```python def get_albums(limit=20, offset=0): """ Retrieves a list of Spotify albums with pagination. Args: limit (int): The maximum number of results to return (0-50). Defaults to 20. offset (int): The index of the first result to return (0-1000). Defaults to 0. Returns: dict: A dictionary containing Spotify catalog information for albums. """ # API call to fetch albums would go here, using limit and offset parameters pass ``` -------------------------------- ### Private TIDAL API Setup Source: https://minim.readthedocs.io/en/latest/notebooks/getting_started Instructions for setting up and using the Private TIDAL API client, including options for client-only and user-authenticated flows. ```APIDOC ## Private TIDAL API (`minim.tidal.PrivateAPI`) ### Description This section covers the setup for the Private TIDAL API. You can initialize it without authentication or with user authentication using either the Authorization Code with PKCE flow or the Device Code flow. ### Initialization without User Authentication To use the Private TIDAL API without user authentication, simply instantiate the client with no arguments. ### Method Constructor ### Endpoint N/A (Client-side setup) ### Parameters None required for client-only instantiation. ### Initialization with User Authentication (PKCE Flow) This flow is typically used when client credentials are obtained from the TIDAL Web Player or desktop applications. ### Method Constructor with specific arguments ### Endpoint N/A (Client-side setup) ### Parameters #### Keyword Arguments for Constructor - **client_id** (string) - Required - Your TIDAL application's client ID. - **client_secret** (string) - Required - Your TIDAL application's client secret. - **flow** (string) - Required - Set to `"pkce"` for Authorization Code with PKCE flow. - **browser** (boolean) - Optional - Set to `True` to automatically open a web browser for the authorization flow. Defaults to `False`. ### Initialization with User Authentication (Device Code Flow) This flow is used when client credentials are obtained from the TIDAL Android or iOS applications. ### Method Constructor with specific arguments ### Endpoint N/A (Client-side setup) ### Parameters #### Keyword Arguments for Constructor - **client_id** (string) - Required - Your TIDAL application's client ID. - **client_secret** (string) - Required - Your TIDAL application's client secret. - **flow** (string) - Required - Set to `"device"` for Device Code flow. - **browser** (boolean) - Optional - Set to `True` to automatically open a web browser for the authorization flow. Defaults to `False`. ### Example (Client-Only) ```python client_tidal_private = tidal.PrivateAPI() ``` ### Example (User Authentication - PKCE Flow) ```python client_tidal_private = tidal.PrivateAPI(client_id='', \ client_secret='',\ flow='pkce',\ browser=True) # Set browser=False for console interaction ``` ### Example (User Authentication - Device Code Flow) ```python client_tidal_private = tidal.PrivateAPI(client_id='', \ client_secret='',\ flow='device',\ browser=True) # Set browser=False for console interaction ``` ### Response N/A (Client initialization, actual API responses depend on subsequent calls.) ``` -------------------------------- ### Get Playlist ETag - Python Source: https://minim.readthedocs.io/en/latest/_modules/minim/tidal Retrieves the entity tag (ETag) for a specific TIDAL playlist, identified by its UUID. This ETag can be used for caching and conditional requests. The method optionally accepts a country code. It requires the 'r_usr' scope for device code flows and is not a private TIDAL API endpoint. An example ETag is provided. ```python def get_playlist_etag(self, playlist_uuid: str, country_code: str = None) -> str: """ Get the entity tag (ETag) for a playlist. .. admonition:: Authorization scope :class: dropdown warning Requires the :code:`r_usr` authorization scope if the device code flow was used. .. note:: This method is provided for convenience and is not a private TIDAL API endpoint. Parameters ---------- playlist_uuid : `str` TIDAL playlist UUID. **Example**: :code:`"36ea71a8-445e-41a4-82ab-6628c581535d"`. country_code : `str`, optional ISO 3166-1 alpha-2 country code. If not provided, the country code associated with the user account in the current session or the current IP address will be used instead. **Example**: :code:`"US"`. Returns ------- etag : `str` ETag for a playlist. **Example**: :code:`"1698984074453"`. """ self._check_scope( "get_playlist_etag", "r_usr", flows={"device_code"}, require_authentication=False, ) r = self._request( "get", f"{self.API_URL}/v1/playlists/{playlist_uuid}", params={"countryCode": self._get_country_code(country_code)}, ) return r.headers["ETag"].replace('"', "") ``` -------------------------------- ### Load and Identify Audio Files with Minim Source: https://minim.readthedocs.io/en/latest/notebooks/getting_started Demonstrates loading audio files using the minim.audio.Audio constructor for automatic detection or specific classes like WAVEAudio. It shows how to instantiate an audio object and check its type. ```python from pathlib import Path from minim.audio import Audio, WAVEAudio file = Path().resolve().parents[2] / "tests/data/samples/middle_c.wav" middle_c = Audio(file) type(middle_c) ``` ```python from pathlib import Path from minim.audio import WAVEAudio middle_c = WAVEAudio(Path().resolve().parents[2] / "tests/data/samples/middle_c.wav") type(middle_c) ``` -------------------------------- ### Create Conda Environment with Dependencies Source: https://minim.readthedocs.io/en/latest/notebooks/getting_started These commands create a Conda virtual environment named 'minim' and install dependencies. One command installs only required dependencies, while the other installs all dependencies from an environment file. Conda must be installed. ```bash conda create -n minim --file requirements_minimal.txt # required dependencies only ``` ```bash conda env create -f environment.yml # all dependencies ``` -------------------------------- ### Instantiate WebAPI with Existing Access Token Source: https://minim.readthedocs.io/en/latest/api/minim.spotify.WebAPI This example shows how to initialize the WebAPI client when you already have an access token, refresh token, and expiry time. This bypasses the token retrieval process. It's recommended to also provide authorization-related parameters to handle token expiration. ```python from minim.spotify import WebAPI from datetime import datetime, timedelta existing_access_token = 'BQC...' # Your existing access token existing_refresh_token = 'AQ...' # Your existing refresh token expiry_time = datetime.now() + timedelta(hours=1) # Example expiry time api_with_existing_token = WebAPI( access_token=existing_access_token, refresh_token=existing_refresh_token, expiry=expiry_time, client_id='YOUR_CLIENT_ID', # Recommended to provide for token refresh client_secret='YOUR_CLIENT_SECRET' # Recommended to provide for token refresh ) ``` -------------------------------- ### GET /users/profile Source: https://minim.readthedocs.io/en/latest/_modules/minim/spotify Get Current User's Profile. Get detailed profile information about the current Spotify user. ```APIDOC ## GET /users/profile ### Description Get detailed profile information about the current Spotify user. ### Method GET ### Endpoint /users/profile ### Parameters No parameters are required for this endpoint. ### Request Example No request body is required. ### Response #### Success Response (200) - **display_name** (str) - The name displayed the user, if any. - **external_urls** (dict) - Known external URLs for this object. - **followers** (dict) - A link to the Web API endpoint providing full details of the follower's information. - **href** (str) - This will always be null, as the followers object is a subset of a User object. - **total** (int) - The total number of followers for the user. - **href** (str) - A link to the Web API endpoint providing full details of the user. - **id** (str) - The Spotify ID for the user. - **images** (list[dict]) - The user's profile image. - **product** (str) - The user's Spotify subscription level: "premium", "free", or "open". - **type** (str) - The type of object. - **uri** (str) - The Spotify URI for the user. - **email** (str) - The user's email address. #### Response Example ```json { "display_name": "johndoe", "external_urls": { "spotify": "https://open.spotify.com/user/johndoe" }, "followers": { "href": null, "total": 150 }, "href": "https://api.spotify.com/v1/users/johndoe", "id": "johndoe", "images": [ { "height": null, "url": "https://i.scdn.co/image/ab67757000003b8cac524480c04a31a5c347a773", "width": null } ], "product": "premium", "type": "user", "uri": "spotify:user:johndoe", "email": "johndoe@example.com" } ``` ``` -------------------------------- ### Instantiate WebAPI with Authorization Code Flow (PKCE) Source: https://minim.readthedocs.io/en/latest/api/minim.spotify.WebAPI This example shows how to initialize the WebAPI client using the Authorization Code flow with PKCE. It's designed for user authentication, allowing access to private user data and playback control. The 'browser' parameter controls whether a browser window is opened automatically. The 'redirect_uri' should be set to 'http://localhost:{port}/callback' for automatic retrieval. ```python from minim.spotify import WebAPI # With automatic browser opening api_auth_code_pkce = WebAPI(flow='pkce', browser=True, redirect_uri='http://localhost:8888/callback') # Without automatic browser opening (user must navigate to the provided URL) # api_auth_code_pkce = WebAPI(flow='pkce', browser=False, redirect_uri='http://localhost:8888/callback') ``` -------------------------------- ### Instantiate Spotify WebAPI Client (Python) Source: https://minim.readthedocs.io/en/latest/notebooks/user_guide/getting_recommendations Creates an instance of the Spotify WebAPI client. Ensure necessary credentials (client ID, client secret) and scopes are configured via environment variables, a configuration file, or passed directly during instantiation. This client is used for subsequent API calls. ```python client_spotify = spotify.WebAPI() ``` -------------------------------- ### Install Minim with Pip Source: https://minim.readthedocs.io/en/latest/notebooks/getting_started This command installs the Minim package and its required dependencies in editable mode using pip. Pip must be installed and the current directory should be the root of the Minim repository. ```bash python -m pip install -e . ``` -------------------------------- ### PrivateAPI Constructor Source: https://minim.readthedocs.io/en/latest/api/minim.qobuz.PrivateAPI Initializes the PrivateAPI client with authentication credentials and configuration options. ```APIDOC ## PrivateAPI Constructor ### Description Initializes the PrivateAPI client with authentication credentials and configuration options. ### Parameters #### Keyword-Only Parameters - **app_id** (str) - Optional - App ID. Required if an user authentication token is provided in `auth_token`. - **app_secret** (str) - Optional - App secret. Required if an user authentication token is provided in `auth_token`. - **flow** (str) - Optional - Authorization flow. Valid values: "password" or None. - **browser** (bool) - Optional, default: False - Determines whether a web browser is opened for login. - **user_agent** (str) - Optional - User agent information for HTTP requests. - **email** (str) - Optional - Account email address. Required if `auth_token` is not provided and `browser` is False. - **password** (str) - Optional - Account password. Required if `auth_token` is not provided and `browser` is False. - **auth_token** (str) - Optional - User authentication token. Bypasses authentication if provided. - **overwrite** (bool) - Optional, default: False - Overwrites existing user authentication token in the config file. - **save** (bool) - Optional, default: True - Saves newly obtained user authentication tokens to the config file. ### Request Example ```json { "app_id": "your_app_id", "app_secret": "your_app_secret", "email": "user@example.com", "password": "your_password" } ``` ### Response Example ```json { "message": "PrivateAPI client initialized successfully." } ``` ``` -------------------------------- ### GET /artists Source: https://minim.readthedocs.io/en/latest/_modules/minim/tidal Get artists in a user's collection. ```APIDOC ## GET /artists ### Description Get TIDAL catalog information for artists in a user's collection. ### Method GET ### Endpoint /artists ### Parameters #### Query Parameters - **country_code** (str) - Optional - ISO 3166-1 alpha-2 country code. **Example**: `"US"`. - **locale** (str) - Optional - IETF BCP 47 language tag. **Default**: `"en_US"`. - **include** (bool) - Optional - Specifies whether to include TIDAL content metadata for the artists. **Default**: `false`. - **cursor** (str) - Optional - Cursor for pagination. **Example**: `"3nI1Esi"`. - **sort** (str) - Optional - Field to sort the returned artists by. Prefix with `-` for descending order. **Valid values**: `"addedAt"`, `"-addedAt"`, `"name"`, `"-name"`. ### Request Example ```json { "country_code": "US", "locale": "en_US", "include": true, "cursor": "3nI1Esi", "sort": "name" } ``` ### Response #### Success Response (200) - **artists** (dict[str, Any]) - TIDAL content metadata for the artists in the user's collection. #### Response Example ```json { "artists": { "items": [ { "id": 12345, "name": "Example Artist", "picture": "example.jpg" } ], "next": "next_cursor_string" } } ``` ``` -------------------------------- ### Authenticate Minim Clients (Python) Source: https://minim.readthedocs.io/en/latest/notebooks/user_guide/transferring_music_libraries Demonstrates how to instantiate authenticated API clients for Qobuz, Spotify, and Tidal. Client credentials should be stored as environment variables. This requires the Playwright library for Qobuz browser authentication if 'browser=True' is used. ```python client_qobuz = qobuz.PrivateAPI(flow="password", browser=True) client_spotify = spotify.WebAPI(flow="pkce", scopes=spotify.WebAPI.get_scopes("all"), web_framework="http.server") client_tidal = tidal.PrivateAPI(flow="device_code", browser=True) ``` -------------------------------- ### GET /markets Source: https://minim.readthedocs.io/en/latest/_modules/minim/spotify Get the list of markets where Spotify is available. ```APIDOC ## GET /markets ### Description Get the list of markets where Spotify is available. ### Method GET ### Endpoint /markets ### Parameters None ### Request Example (No request body or parameters) ### Response #### Success Response (200) - **markets** (list[str]) - Array of country codes. #### Response Example ```json { "markets": ["CA", "BR", "IT"] } ``` ``` -------------------------------- ### Python iTunes Search Example Source: https://minim.readthedocs.io/en/latest/_modules/minim/itunes Demonstrates how to perform a basic search for content on the iTunes Store using the `itunes.search` function. This function takes a search term and optional parameters to filter results. ```python import itunes # Search for 'jack johnson' and return default results itunes.search("jack johnson") # Search for 'jack johnson' and limit to 25 results itunes.search("jack johnson", limit=25) # Search for music videos by 'jack johnson' itunes.search("jack johnson", entity="musicVideo") # Search for 'jack johnson' content from the Canada iTunes Store itunes.search("jack johnson", country="ca") ``` -------------------------------- ### GET /users/{username}/inventory Source: https://minim.readthedocs.io/en/latest/api/minim.discogs.API Get a seller’s inventory. User authentication is required if not fetching own inventory. ```APIDOC ## GET /users/{username}/inventory ### Description Get a seller’s inventory. If you are authenticated as the inventory owner, additional fields will be returned. ### Method GET ### Endpoint `/users/{username}/inventory` ### Parameters #### Path Parameters - **username** (str) - Optional - The username of the inventory owner. If not specified, the username of the authenticated user is used. #### Query Parameters - **status** (str) - Optional, Keyword-only - The status of the listings to return. Valid values: "For Sale", "Draft", "Expired", "Sold", "Deleted". - **page** (int | str) - Optional, Keyword-only - The page you want to request. - **per_page** (int | str) - Optional, Keyword-only - The number of items per page. - **sort** (str) - Optional, Keyword-only - Sort items by this field. Valid values: "listed", "price", "item", "artist", "label", "catno", "audio", "status", "location". - **sort_order** (str) - Optional, Keyword-only - Sort items in a particular order. Valid values: "asc", "desc". ### Request Example ```json { "username": "360vinyl", "status": "For Sale", "page": 3, "per_page": 25, "sort": "price", "sort_order": "desc" } ``` ### Response #### Success Response (200) - **inventory** (dict) - The seller’s inventory. - **pagination** (dict) - Pagination details. - **listings** (array) - An array of listing objects. #### Response Example ```json { "pagination": { "page": 1, "pages": 10, "per_page": 25, "items": 250, "urls": {} }, "listings": [ { "status": "For Sale", "price": { "currency": "USD", "value": 10.50 }, "allow_offers": true, "sleeve_condition": "Mint (M)", "id": 1234567, "condition": "Mint (M)", "posted": "2023-10-27T10:00:00Z", "ships_from": "USA", "uri": "https://www.discogs.com/sell/item/1234567", "comments": "Brand new copy.", "seller": { "username": "360vinyl", "resource_url": "https://api.discogs.com/users/360vinyl", "id": 98765 }, "release": { "catalog_number": "X123", "resource_url": "https://api.discogs.com/releases/12345", "year": 2020, "id": 12345 } } ] } ``` ``` -------------------------------- ### Import Minim Libraries Source: https://minim.readthedocs.io/en/latest/notebooks/user_guide/transferring_music_libraries Imports the necessary client libraries for interacting with Qobuz, Spotify, and Tidal services using Minim. Ensure Minim is installed. ```python from minim import qobuz, spotify, tidal ``` -------------------------------- ### Initialize Spotify Lyrics Client Source: https://minim.readthedocs.io/en/latest/_modules/minim/spotify Initializes the Spotify Lyrics service client, setting up a requests session and loading credentials from configuration or environment variables if not explicitly provided. It prepares the client for making authenticated API calls. ```python LYRICS_URL = "https://spclient.wg.spotify.com/color-lyrics/v2" TOKEN_URL = "https://open.spotify.com/get_access_token" def __init__( self, *, sp_dc: str = None, access_token: str = None, expiry: Union[datetime.datetime, str] = None, save: bool = True, ) -> None: """ Create a Spotify Lyrics service client. """ self.session = requests.Session() self.session.headers["App-Platform"] = "WebPlayer" if access_token is None and _config.has_section(self._NAME): sp_dc = _config.get(self._NAME, "sp_dc") access_token = _config.get(self._NAME, "access_token") expiry = _config.get(self._NAME, "expiry") self.set_sp_dc(sp_dc, save=save) self.set_access_token(access_token=access_token, expiry=expiry) ``` -------------------------------- ### GET /users/{user_id}/playlists Source: https://minim.readthedocs.io/en/latest/_modules/minim/spotify Get a list of the playlists owned by a Spotify user. ```APIDOC ## GET /users/{user_id}/playlists ### Description Get a list of the playlists owned by a Spotify user. ### Method GET ### Endpoint /users/{user_id}/playlists ### Parameters #### Path Parameters - **user_id** (str) - Required - The Spotify ID of the user. #### Query Parameters - **limit** (int) - Optional - The maximum number of playlists to return. Default: 20. Minimum: 1. Maximum: 50. - **offset** (int) - Optional - The number of playlists to offset. Default: 0. ### Response #### Success Response (200) - **href** (str) - A link to the Web API endpoint providing full details of the playlists. - **items** (list) - An array of playlist objects. - **limit** (int) - The maximum number of playlists to return. - **next** (str) - The next page of results. Null if the end of the results has been reached. - **offset** (int) - The offset of the items returned (as set in the query parameter). - **previous** (str) - The previous page of results. Null if the end of the results has been reached. - **total** (int) - The total number of playlists available. #### Response Example ```json { "href": "https://api.spotify.com/v1/users/jmpashg/playlists?offset=0&limit=20", "items": [ { "collaborative": false, "description": "", "external_urls": { "spotify": "https://open.spotify.com/playlist/37i9dQJx6j0rTmjXz1870Z" }, "followers": { "href": null, "total": 1 }, "href": "https://api.spotify.com/v1/playlists/37i9dQJx6j0rTmjXz1870Z", "id": "37i9dQJx6j0rTmjXz1870Z", "images": [ { "url": "https://i.scdn.co/image/ab67616d0000b2736e1875c01b2774890605f31a", "height": 300, "width": 300 } ], "name": "My Awesome Playlist", "owner": { "display_name": "Spotify", "external_urls": { "spotify": "https://open.spotify.com/user/spotify" }, "href": "https://api.spotify.com/v1/users/spotify", "id": "spotify", "type": "user", "uri": "spotify:user:spotify" }, "public": true, "snapshot_id": "bbgM57W12y34567890abcdefghijklm", "tracks": { "href": "https://api.spotify.com/v1/playlists/37i9dQJx6j0rTmjXz1870Z/tracks", "total": 12 }, "type": "playlist", "uri": "spotify:playlist:37i9dQJx6j0rTmjXz1870Z" } ], "limit": 20, "next": null, "offset": 0, "previous": null, "total": 1 } ``` ```