### Setup WSL2 Ubuntu Developer Toolkit Source: https://github.com/reesey275/spotify-dev-toolkit/blob/main/README.md Commands to import and set up a WSL2 Ubuntu developer toolkit. This includes running a setup script and verifying installations of Node.js, Python, and FFmpeg. ```bash wsl --import Ubuntu-22.04 C:\path\to\ubuntu-dev-toolkit.tar C:\path\to\install\location ``` ```bash chmod +x setup-dev-toolkit.sh ./setup-dev-toolkit.sh ``` ```bash node --version python3 --version ffmpeg -version ``` -------------------------------- ### Install Node.js Dependencies and Run Spotify Fan Website Source: https://github.com/reesey275/spotify-dev-toolkit/blob/main/README.md Commands to install project dependencies using npm and start the development or production server for the Spotify Fan Website. After installation, the application can be accessed via a web browser. ```bash npm install ``` ```bash npm run dev ``` ```bash npm start ``` -------------------------------- ### Node.js Virtual Environment Setup Source: https://github.com/reesey275/spotify-dev-toolkit/blob/main/README.md Sets up the Node.js environment by selecting a Node version using nvm and installing project dependencies via npm. This is a prerequisite for running the project in development mode. ```bash nvm use node npm install ``` -------------------------------- ### Development Server Commands (Bash) Source: https://context7.com/reesey275/spotify-dev-toolkit/llms.txt These bash commands are used to manage the development server for the Spotify Developer Toolkit. They cover dependency installation, starting the server with auto-reload using nodemon, starting the production server, and performing a clean restart. ```bash # Install dependencies npm install # Start with nodemon for auto-reload npm run dev # Start production server npm start # Clean restart (kill existing process on port) npm run clean-start ``` -------------------------------- ### Python Virtual Environment Setup Source: https://github.com/reesey275/spotify-dev-toolkit/blob/main/README.md Configures a Python virtual environment for the project, essential for managing dependencies for the Python export tool. It creates an isolated environment and installs required packages from a requirements file. Activation commands differ for Linux/Mac and Windows. ```bash python -m venv venv source venv/bin/activate # Linux/Mac # or venv\Scripts\activate # Windows pip install -r requirements.txt ``` -------------------------------- ### Configure Spotify App Environment Variables Source: https://github.com/reesey275/spotify-dev-toolkit/blob/main/README.md Example environment variables required for the Spotify Fan Website. This includes Spotify API credentials, redirect URI, user ID, and the port for the development server. These are typically copied from an example file and edited. ```env SPOTIFY_CLIENT_ID=your_client_id_here SPOTIFY_CLIENT_SECRET=your_client_secret_here SPOTIFY_REDIRECT_URI=http://localhost:5500/callback SPOTIFY_USER_ID=your_spotify_username PORT=5500 ``` -------------------------------- ### Example HTML Table for Playlist (HTML) Source: https://context7.com/reesey275/spotify-dev-toolkit/llms.txt An example of the HTML structure generated for an interactive playlist table. This includes table headers and rows for each track with sortable columns. ```html
Title Artists Album Duration Spotify Url
Shape of You Ed Sheeran ÷ (Deluxe) 3:53 Open in Spotify
``` -------------------------------- ### Run Development Server with Auto-Reload Source: https://github.com/reesey275/spotify-dev-toolkit/blob/main/README.md This command initiates the development server using npm and nodemon. Nodemon monitors file changes and automatically reloads the server, streamlining the development workflow. Ensure you have Node.js and npm installed. ```bash npm run dev ``` -------------------------------- ### Get User Playlists API Response Source: https://context7.com/reesey275/spotify-dev-toolkit/llms.txt Example JSON response for fetching user playlists. Includes playlist details like ID, name, owner, track count, creation date, and external URLs. The response structure is similar to featured playlists. ```json { "playlists": [ { "id": "5Gc3KsUejEGoZ2nXGwsFXJ", "name": "On My Way To You", "owner": { "display_name": "spotify" }, "tracks": { "total": 735 }, "track_count": 735, "created_date": "2024-01-15T14:23:00Z", "external_urls": { "spotify": "https://open.spotify.com/playlist/5Gc3KsUejEGoZ2nXGwsFXJ" } } ], "total": 50, "source": "featured", "message": "Spotify featured playlists" } ``` -------------------------------- ### Get Playlist Tracks API Response Source: https://context7.com/reesey275/spotify-dev-toolkit/llms.txt Example JSON response for fetching playlist tracks. Includes playlist metadata and a list of tracks with details such as ID, name, artists, album, duration, added date, preview URL, and image. Pagination details are also provided. ```json { "playlist": { "id": "37i9dQZF1DXcBWIGoYBM5M", "name": "Today's Top Hits", "description": "Ed Sheeran is on top of the Hottest 50!", "owner": "Spotify", "total_tracks": 50, "image": "https://i.scdn.co/image/ab67706f00000003...", "external_urls": { "spotify": "https://open.spotify.com/playlist/37i9dQZF1DXcBWIGoYBM5M" } }, "tracks": [ { "id": "5Z9KJZvQzH6PFmb8SNkxuk", "name": "Shape of You", "artists": ["Ed Sheeran"], "album": "÷ (Deluxe)", "duration_ms": 233713, "duration": "3:53", "added_at": "2024-01-10T12:00:00Z", "preview_url": "https://p.scdn.co/mp3-preview/...", "external_urls": { "spotify": "https://open.spotify.com/track/5Z9KJZvQzH6PFmb8SNkxuk" }, "image": "https://i.scdn.co/image/ab67616d0000b273...", "track_number": 1 } ], "pagination": { "offset": 0, "limit": 100, "total": 50, "next": false, "previous": false } } ``` -------------------------------- ### List User Playlists Output (Text) Source: https://context7.com/reesey275/spotify-dev-toolkit/llms.txt Example output format when listing user playlists. It shows the playlist name, its ID in parentheses, and the number of tracks it contains. ```text Your playlists: - R&B Mix (3Q8JYDwINCx5JhIR46hLXi) - 65 tracks - New Music (6Kzp0rOCHpFt2CWJFNgbkt) - 57 tracks - My Kinda Saturday Night Luke Combs (7ALoX2kEqX3NZh8eRUqVoF) - 239 tracks - EDM (4f4xjT2Ju1HamCornRbxIW) - 97 tracks ``` -------------------------------- ### Get Featured Playlists API Response Source: https://context7.com/reesey275/spotify-dev-toolkit/llms.txt Example JSON response for fetching featured playlists. It includes playlist details such as ID, name, description, owner, track count, images, and external URLs. The response also contains pagination information. ```json { "playlists": [ { "id": "37i9dQZF1DXcBWIGoYBM5M", "name": "Today's Top Hits", "description": "Ed Sheeran is on top of the Hottest 50!", "owner": { "display_name": "Spotify" }, "tracks": { "total": 50 }, "track_count": 50, "images": [ { "url": "https://i.scdn.co/image/ab67706f00000003..." } ], "external_urls": { "spotify": "https://open.spotify.com/playlist/37i9dQZF1DXcBWIGoYBM5M" }, "created_date": null } ], "total": 20, "source": "featured", "message": "Featured playlists from Spotify" } ``` -------------------------------- ### Spotify User Information Response (JSON) Source: https://context7.com/reesey275/spotify-dev-toolkit/llms.txt Example JSON structure for user information returned from the Spotify API. It includes user ID, display name, follower count, and image URLs. ```json { "id": "spotify", "display_name": "Spotify", "followers": 25000000, "images": [ { "url": "https://i.scdn.co/image/ab6775700000ee85...", "height": 640, "width": 640 } ], "external_urls": { "spotify": "https://open.spotify.com/user/spotify" } } ``` -------------------------------- ### Get Spotify User Information (Bash) Source: https://context7.com/reesey275/spotify-dev-toolkit/llms.txt Retrieves detailed information about a Spotify user, including follower count and profile images. This uses a simple curl command against a local API endpoint. ```bash curl "http://localhost:5500/api/user/spotify" ``` -------------------------------- ### Get Playlist Tracks Source: https://context7.com/reesey275/spotify-dev-toolkit/llms.txt Retrieve detailed track information for a specific playlist. Supports sorting tracks by name in ascending order and pagination. ```APIDOC ## GET /api/playlist/{playlist_id} ### Description Retrieve detailed track information for a specific playlist with sorting and pagination support. ### Method GET ### Endpoint /api/playlist/{playlist_id} #### Path Parameters - **playlist_id** (string) - Required - The ID of the playlist. #### Query Parameters - **sort** (string) - Optional - Sort order for tracks. Example: `name-asc` for sorting by track name in ascending order. - **offset** (integer) - Optional - The number of tracks to skip (for pagination). - **limit** (integer) - Optional - The maximum number of tracks to return. ### Response #### Success Response (200) - **playlist** (object) - Details of the playlist. - **id** (string) - Playlist ID. - **name** (string) - Playlist name. - **description** (string) - Playlist description. - **owner** (string) - Playlist owner. - **total_tracks** (integer) - Total number of tracks in the playlist. - **image** (string) - URL of the playlist image. - **external_urls** (object) - External URLs for the playlist. - **tracks** (array) - An array of track objects. - **id** (string) - Track ID. - **name** (string) - Track name. - **artists** (array) - Array of artist names. - **album** (string) - Album name. - **duration_ms** (integer) - Duration in milliseconds. - **duration** (string) - Formatted duration (e.g., "3:53"). - **added_at** (string) - Timestamp when the track was added. - **preview_url** (string) - URL for a preview of the track. - **external_urls** (object) - External URLs for the track. - **image** (string) - URL of the track's album image. - **track_number** (integer) - Track number in the album. - **pagination** (object) - Pagination details. - **offset** (integer) - Current offset. - **limit** (integer) - Current limit. - **total** (integer) - Total number of tracks. - **next** (boolean) - Whether there is a next page. - **previous** (boolean) - Whether there is a previous page. #### Response Example ```json { "playlist": { "id": "37i9dQZF1DXcBWIGoYBM5M", "name": "Today's Top Hits", "description": "Ed Sheeran is on top of the Hottest 50!", "owner": "Spotify", "total_tracks": 50, "image": "https://i.scdn.co/image/ab67706f00000003...", "external_urls": { "spotify": "https://open.spotify.com/playlist/37i9dQZF1DXcBWIGoYBM5M" } }, "tracks": [ { "id": "5Z9KJZvQzH6PFmb8SNkxuk", "name": "Shape of You", "artists": ["Ed Sheeran"], "album": "÷ (Deluxe)", "duration_ms": 233713, "duration": "3:53", "added_at": "2024-01-10T12:00:00Z", "preview_url": "https://p.scdn.co/mp3-preview/...", "external_urls": { "spotify": "https://open.spotify.com/track/5Z9KJZvQzH6PFmb8SNkxuk" }, "image": "https://i.scdn.co/image/ab67616d0000b273...", "track_number": 1 } ], "pagination": { "offset": 0, "limit": 100, "total": 50, "next": false, "previous": false } } ``` ``` -------------------------------- ### Search Playlists API Response Source: https://context7.com/reesey275/spotify-dev-toolkit/llms.txt Example JSON response for searching playlists. It contains a 'playlists' object with metadata about the search, including the API endpoint URL, a list of matching playlist items, and pagination details (limit, next, offset, previous, total). ```json { "playlists": { "href": "https://api.spotify.com/v1/search?query=rock...", "items": [ { "id": "37i9dQZF1DWXRqgorJj26U", "name": "Rock Classics", "description": "Rock legends & epic songs", "owner": { "display_name": "Spotify" }, "tracks": { "total": 150 }, "external_urls": { "spotify": "https://open.spotify.com/playlist/37i9dQZF1DWXRqgorJj26U" } } ], "limit": 20, "next": "https://api.spotify.com/v1/search?query=rock&offset=20...", "offset": 0, "previous": null, "total": 1000 } } ``` -------------------------------- ### Get User Playlists API Request Source: https://context7.com/reesey275/spotify-dev-toolkit/llms.txt Fetches public playlists for a specific Spotify user. Supports sorting by creation date in descending order and setting a limit for the number of playlists returned. Requires a username in the URL. ```bash curl "http://localhost:5500/api/user/spotify/playlists?sort=date-desc&limit=50" ``` -------------------------------- ### Get User Playlists Source: https://context7.com/reesey275/spotify-dev-toolkit/llms.txt Fetch public playlists for a specific Spotify user. Supports sorting by date in descending order and limiting the number of results. ```APIDOC ## GET /api/user/{username}/playlists ### Description Fetch public playlists for a specific Spotify user by username with sorting options. ### Method GET ### Endpoint /api/user/{username}/playlists #### Path Parameters - **username** (string) - Required - The Spotify username. #### Query Parameters - **sort** (string) - Optional - Sort order. Example: `date-desc` for sorting by creation date in descending order. - **limit** (integer) - Optional - Maximum number of playlists to return. ### Response #### Success Response (200) - **playlists** (array) - An array of playlist objects. - **total** (integer) - The total number of playlists found. - **source** (string) - The source of the playlists (e.g., 'user'). - **message** (string) - A message describing the response. #### Response Example ```json { "playlists": [ { "id": "5Gc3KsUejEGoZ2nXGwsFXJ", "name": "On My Way To You", "owner": { "display_name": "spotify" }, "tracks": { "total": 735 }, "track_count": 735, "created_date": "2024-01-15T14:23:00Z", "external_urls": { "spotify": "https://open.spotify.com/playlist/5Gc3KsUejEGoZ2nXGwsFXJ" } } ], "total": 50, "source": "user", "message": "User playlists fetched successfully" } ``` ``` -------------------------------- ### Get Featured Playlists Source: https://context7.com/reesey275/spotify-dev-toolkit/llms.txt Retrieve Spotify's curated featured playlists. Supports optional sorting by track count in descending order and limiting the number of results. ```APIDOC ## GET /api/playlists ### Description Retrieve Spotify's curated featured playlists with optional sorting and pagination. ### Method GET ### Endpoint /api/playlists #### Query Parameters - **sort** (string) - Optional - Sort order. Example: `tracks-desc` for sorting by track count in descending order. - **limit** (integer) - Optional - Maximum number of playlists to return. ### Response #### Success Response (200) - **playlists** (array) - An array of playlist objects. - **total** (integer) - The total number of playlists available. - **source** (string) - The source of the playlists (e.g., 'featured'). - **message** (string) - A message describing the response. #### Response Example ```json { "playlists": [ { "id": "37i9dQZF1DXcBWIGoYBM5M", "name": "Today's Top Hits", "description": "Ed Sheeran is on top of the Hottest 50!", "owner": { "display_name": "Spotify" }, "tracks": { "total": 50 }, "track_count": 50, "images": [ { "url": "https://i.scdn.co/image/ab67706f00000003..." } ], "external_urls": { "spotify": "https://open.spotify.com/playlist/37i9dQZF1DXcBWIGoYBM5M" }, "created_date": null } ], "total": 20, "source": "featured", "message": "Featured playlists from Spotify" } ``` ``` -------------------------------- ### Get Playlist Tracks API Request Source: https://context7.com/reesey275/spotify-dev-toolkit/llms.txt Retrieves detailed track information for a specific playlist ID. Supports sorting tracks by name in ascending order, pagination with offset and limit parameters. Requires a playlist ID in the URL. ```bash curl "http://localhost:5500/api/playlist/37i9dQZF1DXcBWIGoYBM5M?sort=name-asc&offset=0&limit=100" ``` -------------------------------- ### Get Featured Playlists API Request Source: https://context7.com/reesey275/spotify-dev-toolkit/llms.txt Retrieves Spotify's curated featured playlists. Supports optional sorting by track count in descending order and limiting the number of results. Returns a JSON object containing a list of playlists. ```bash curl "http://localhost:5500/api/playlists?sort=tracks-desc&limit=20" ``` -------------------------------- ### Generate Spotify Landing Page (Bash) Source: https://context7.com/reesey275/spotify-dev-toolkit/llms.txt Creates a comprehensive landing page with links to user playlists. This requires setting environment variables for Spotify API credentials and the redirect URI, then executing the Python script with the `--landing-page` flag. ```bash export SPOTIFY_USERNAME="your_username" export SPOTIFY_CLIENT_ID="your_client_id" export SPOTIFY_CLIENT_SECRET="your_client_secret" export SPOTIFY_REDIRECT_URI="http://localhost:8888/callback" python export_spotify_playlist.py \ --landing-page \ --username "your_username" ``` -------------------------------- ### Backup WSL2 Ubuntu Instance Source: https://github.com/reesey275/spotify-dev-toolkit/blob/main/README.md Command to export the configured WSL2 Ubuntu instance for backup purposes. This creates a tar archive of the entire instance. ```bash wsl --export Ubuntu-22.04 ~/ubuntu-dev-toolkit-backup.tar ``` -------------------------------- ### Configure Spotify API Credentials (.env) Source: https://context7.com/reesey275/spotify-dev-toolkit/llms.txt This snippet shows the necessary environment variables for authenticating with the Spotify API. Ensure these are set correctly in your .env file to use the toolkit. ```env SPOTIFY_CLIENT_ID=abc123def456 SPOTIFY_CLIENT_SECRET=xyz789uvw012 SPOTIFY_REDIRECT_URI=http://localhost:5500/callback SPOTIFY_USER_ID=your_spotify_username PORT=5500 NODE_ENV=development ``` -------------------------------- ### Export Spotify Playlist to HTML (Bash) Source: https://context7.com/reesey275/spotify-dev-toolkit/llms.txt Generates an interactive HTML page from a Spotify playlist. This command specifies the playlist ID, output format as HTML, output file name, and optionally includes audio features. ```bash python export_spotify_playlist.py \ --playlist "37i9dQZF1DXcBWIGoYBM5M" \ --format html \ -o "todays_top_hits.html" \ --include-audio-features ``` -------------------------------- ### Initiate Spotify OAuth Flow (Bash) Source: https://context7.com/reesey275/spotify-dev-toolkit/llms.txt Initiates the OAuth authentication flow for a user to grant access to private playlists and user-specific features. This involves redirecting the user to Spotify's login endpoint. ```bash # Redirect user to login endpoint curl "http://localhost:5500/login" # User is redirected to Spotify authorization page # After authorization, callback receives auth code # Callback processes the authorization code curl "http://localhost:5500/callback?code=AQDaF8xKL..." # Returns: Redirect to /?authenticated=true with token stored server-side ``` -------------------------------- ### Configure Express.js Server (Bash) Source: https://context7.com/reesey275/spotify-dev-toolkit/llms.txt Bash command to set environment variables for configuring an Express.js server for Spotify API integration. This typically involves setting client ID, client secret, redirect URI, and scope. ```bash # Example environment variable setup for server configuration export SPOTIFY_CLIENT_ID="your_client_id" export SPOTIFY_CLIENT_SECRET="your_client_secret" export SPOTIFY_REDIRECT_URI="http://localhost:8888/callback" export SPOTIFY_SCOPES="playlist-read-private user-read-private" # Command to start the server (example) # node server.js ``` -------------------------------- ### Playlists API Source: https://github.com/reesey275/spotify-dev-toolkit/blob/main/README.md Endpoints for retrieving user and featured playlists, with options for sorting and pagination. ```APIDOC ## GET /api/playlists ### Description Retrieves user playlists with sorting options. ### Method GET ### Endpoint /api/playlists ### Query Parameters - **sort** (string) - Optional - Sort by `name`, `date`, or `tracks` - **limit** (integer) - Optional - Number of results to return - **offset** (integer) - Optional - Pagination offset ### Response #### Success Response (200) - **playlists** (array) - An array of playlist objects. ### Response Example ```json { "playlists": [ { "id": "37i9dQZF1DXcBWIGoYBM5M", "name": "Chill Vibes", "owner": "Spotify", "trackCount": 100 } ] } ``` ``` ```APIDOC ## GET /api/playlist/:id ### Description Retrieves detailed information and tracks for a specific playlist. ### Method GET ### Endpoint /api/playlist/:id ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the playlist to retrieve. ### Response #### Success Response (200) - **playlist** (object) - A playlist object with detailed track information. ### Response Example ```json { "playlist": { "id": "37i9dQZF1DXcBWIGoYBM5M", "name": "Chill Vibes", "tracks": [ { "name": "Song Title 1", "artist": "Artist Name 1", "added_at": "2023-01-15T10:00:00Z", "duration_ms": 180000 } ] } } ``` ``` ```APIDOC ## GET /api/featured ### Description Retrieves a list of featured playlists. ### Method GET ### Endpoint /api/featured ### Query Parameters - **sort** (string) - Optional - Sort by `name`, `date`, or `tracks` - **limit** (integer) - Optional - Number of results to return - **offset** (integer) - Optional - Pagination offset ### Response #### Success Response (200) - **featuredPlaylists** (array) - An array of featured playlist objects. ### Response Example ```json { "featuredPlaylists": [ { "id": "37i9dQZF1DXcBWIGoYBM5M", "name": "Today's Top Hits", "owner": "Spotify", "trackCount": 50 } ] } ``` ``` -------------------------------- ### Search API Source: https://github.com/reesey275/spotify-dev-toolkit/blob/main/README.md Endpoint for searching playlists. ```APIDOC ## GET /api/search ### Description Searches for playlists. ### Method GET ### Endpoint /api/search ### Query Parameters - **q** (string) - Required - The search query - **sort** (string) - Optional - Sort by `name`, `date`, or `tracks` - **limit** (integer) - Optional - Number of results to return - **offset** (integer) - Optional - Pagination offset ### Response #### Success Response (200) - **searchResults** (array) - An array of playlist objects matching the search query. ### Response Example ```json { "searchResults": [ { "id": "37i9dQZF1DXcBWIGoYBM5M", "name": "Pop Rising", "owner": "Spotify", "trackCount": 75 } ] } ``` ``` -------------------------------- ### Spotify OAuth Frontend JavaScript Source: https://context7.com/reesey275/spotify-dev-toolkit/llms.txt Handles the frontend JavaScript logic for initiating the Spotify OAuth flow and checking the authentication status. It redirects the user to the login page and logs a success message upon successful authentication. ```javascript // Frontend JavaScript integration async function authenticateUser() { window.location.href = '/login'; } // Check authentication status on page load const urlParams = new URLSearchParams(window.location.search); if (urlParams.get('authenticated') === 'true') { console.log('User authenticated successfully'); // Can now access protected endpoints } ``` -------------------------------- ### List User Spotify Playlists (Bash) Source: https://context7.com/reesey275/spotify-dev-toolkit/llms.txt Displays all playlists owned by the authenticated user, including their track counts. This command requires Spotify API credentials and the redirect URI to be set. ```bash python export_spotify_playlist.py \ --list \ --username "your_username" \ --client-id "your_client_id" \ --client-secret "your_client_secret" \ --redirect-uri "http://localhost:8888/callback" ``` -------------------------------- ### Export Spotify Playlist to CSV (Bash) Source: https://context7.com/reesey275/spotify-dev-toolkit/llms.txt A Python command-line tool to export Spotify playlist data to CSV format. It requires playlist URL, output file name, and Spotify API credentials (client ID and secret). ```bash python export_spotify_playlist.py \ --playlist "https://open.spotify.com/playlist/37i9dQZF1DXcBWIGoYBM5M" \ -o "todays_top_hits.csv" \ --client-id "your_client_id" \ --client-secret "your_client_secret" ``` -------------------------------- ### Search Playlists API Request Source: https://context7.com/reesey275/spotify-dev-toolkit/llms.txt Searches for playlists across Spotify using a query string and an optional type filter (e.g., 'playlist'). Supports limiting the number of search results. Requires query parameters 'q', 'type', and 'limit'. ```bash curl "http://localhost:5500/api/search?q=rock&type=playlist&limit=20" ``` -------------------------------- ### Export Spotify Playlist using Python Source: https://github.com/reesey275/spotify-dev-toolkit/blob/main/README.md This Python script is part of the Spotify Developer Toolkit, designed to export Spotify playlists. The script likely takes playlist information and outputs it to various formats like CSV, HTML, or TXT. ```python export_spotify_playlist.py ``` -------------------------------- ### Node.js Spotify Token Management (JavaScript) Source: https://context7.com/reesey275/spotify-dev-toolkit/llms.txt This Node.js code snippet demonstrates how to manage Spotify API access tokens. It includes a function to retrieve a token, automatically refreshing it if it has expired, with a one-minute buffer. It utilizes 'express' and 'axios' for server functionality and API requests. ```javascript // server.js - Token management const express = require('express'); const app = express(); // Automatic token refresh with 1-minute buffer async function getSpotifyToken() { if (accessToken && tokenExpiry && Date.now() < tokenExpiry) { return accessToken; } const response = await axios.post('https://accounts.spotify.com/api/token', 'grant_type=client_credentials', { headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'Authorization': `Basic ${Buffer.from(`${SPOTIFY_CLIENT_ID}:${SPOTIFY_CLIENT_SECRET}`).toString('base64')}` } } ); accessToken = response.data.access_token; tokenExpiry = Date.now() + (response.data.expires_in * 1000) - 60000; return accessToken; } ``` -------------------------------- ### Playlist Export CSV Format (CSV) Source: https://context7.com/reesey275/spotify-dev-toolkit/llms.txt Defines the structure of the CSV file generated when exporting a Spotify playlist. It includes columns for track title, artists, album, duration, and Spotify links. ```csv title,artists,album,duration_ms,duration_mm_ss,added_at,spotify_url,spotify_uri Shape of You,Ed Sheeran,÷ (Deluxe),233713,3:53,2024-01-10T12:00:00Z,https://open.spotify.com/track/5Z9KJZvQzH6PFmb8SNkxuk,spotify:track:5Z9KJZvQzH6PFmb8SNkxuk ``` -------------------------------- ### Search Playlists Source: https://context7.com/reesey275/spotify-dev-toolkit/llms.txt Search for playlists across Spotify using keywords. Supports filtering by type (e.g., 'playlist') and limiting results. ```APIDOC ## GET /api/search ### Description Search for playlists across Spotify using keywords with type filtering. ### Method GET ### Endpoint /api/search #### Query Parameters - **q** (string) - Required - The search query keywords. - **type** (string) - Required - The type of Spotify content to search for (e.g., 'playlist'). - **limit** (integer) - Optional - Maximum number of items to return. ### Response #### Success Response (200) - **playlists** (object) - Search results for playlists. - **href** (string) - URL to the search results page. - **items** (array) - An array of playlist objects matching the search criteria. - **limit** (integer) - The maximum number of items returned in this response. - **next** (string) - URL for the next page of results, or null if none. - **offset** (integer) - The offset of the items. - **previous** (string) - URL for the previous page of results, or null if none. - **total** (integer) - The total number of results available. #### Response Example ```json { "playlists": { "href": "https://api.spotify.com/v1/search?query=rock...", "items": [ { "id": "37i9dQZF1DWXRqgorJj26U", "name": "Rock Classics", "description": "Rock legends & epic songs", "owner": { "display_name": "Spotify" }, "tracks": { "total": 150 }, "external_urls": { "spotify": "https://open.spotify.com/playlist/37i9dQZF1DWXRqgorJj26U" } } ], "limit": 20, "next": "https://api.spotify.com/v1/search?query=rock&offset=20...", "offset": 0, "previous": null, "total": 1000 } } ``` ``` -------------------------------- ### Client-Side Table Sorting (JavaScript) Source: https://github.com/reesey275/spotify-dev-toolkit/blob/main/demo outputs/test-output-playlist.html This JavaScript code enables dynamic sorting of table rows when a table header is clicked. It determines the sort type (numeric or alphabetical) based on the header's class or text content and rearranges the rows accordingly. It handles numeric sorting by parsing values and alphabetical sorting using localeCompare. ```javascript document.querySelectorAll('th').forEach(header => { header.addEventListener('click', () => { const table = header.closest('table'); const tbody = table.querySelector('tbody'); const rows = Array.from(tbody.querySelectorAll('tr')); const index = Array.from(header.parentNode.children).indexOf(header); const isNumeric = header.classList.contains('duration') || header.textContent.includes('Ms'); rows.sort((a, b) => { const aVal = a.children[index].textContent.trim(); const bVal = b.children[index].textContent.trim(); if (isNumeric) { return parseFloat(aVal.replace(':', '.')) - parseFloat(bVal.replace(':', '.')); } return aVal.localeCompare(bVal); }); rows.forEach(row => tbody.appendChild(row)); }); }); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.