Tutorial · Spotify

Java Step-by-step

How to scrape Spotify search results
with Java.

Extract search data from Spotify. Real code, real responses, real production patterns — paste it into your project and ship.

Overview

Learn how to scrape Spotify search results using Java. This comprehensive guide will walk you through the entire process, from setup to implementation.

What You'll Learn

  • • Setting up your development environment
  • • Installing the required HTTP client
  • • Authenticating with the ScrapeCreators API
  • • Making requests to Spotify
  • • Handling responses and errors
  • • Best practices for production use

What You'll Get

  • • Access to search results data
  • • JSON formatted responses
  • • Real-time data access
  • • Scalable solution
  • • Error handling patterns
  • • Performance optimization tips

Prerequisites

1. API Key

First, you'll need a ScrapeCreators API key to authenticate your requests.

Sign up at app.scrapecreators.com to get your free API key with 100 requests.

2. Development Environment

Make sure you have the following installed:

  • Java and its dependencies
  • • A code editor (VS Code, Sublime, etc.)
  • • Basic understanding of API requests
  • • Command line interface access

Step 1: Install HTTP Client

Apache HttpClient is a robust HTTP client for Java

maven
mvn dependency:add -DgroupId=org.apache.httpcomponents -DartifactId=httpclient -Dversion=4.5.13

Step 2: API Implementation

Now let's make a request to the Spotify API using Java. Replace YOUR_API_KEY with your actual API key.

Java
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.stream.Collectors;

public class Scraper {
    private static final String API_KEY = "YOUR_API_KEY";
    private static final String BASE_URL = "https://api.scrapecreators.com";
    private static final String ENDPOINT_PATH = "/v1/spotify/search";

    public static void main(String[] args) {
        try {
            String result = scrape();
            System.out.println("Response: " + result);
        } catch (Exception e) {
            System.err.println("Error: " + e.getMessage());
        }
    }

    public static String scrape() throws Exception {
        HttpClient client = HttpClient.newHttpClient();
        
        // Build query parameters
        Map<String, String> params = Map.of(
            "query", "my first million"
        );
        
        String queryString = params.entrySet().stream()
            .map(entry -> entry.getKey() + "=" + URLEncoder.encode(entry.getValue(), StandardCharsets.UTF_8))
            .collect(Collectors.joining("&"));
        
        String url = BASE_URL + ENDPOINT_PATH + "?" + queryString;
        
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create(url))
            .header("x-api-key", API_KEY)
            .header("Content-Type", "application/json")
            .GET()
            .build();
        
        HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
        
        if (response.statusCode() == 200) {
            return response.body();
        } else {
            throw new RuntimeException("HTTP " + response.statusCode() + ": " + response.body());
        }
    }
}

Step 3: Testing Your Code

API Parameters

This endpoint accepts the following parameters:

queryRequired(string)

Search query

Example: my first million

Run Your Code

Execute your script to test the API connection. You should see a JSON response with Spotify search results data.

✅ Success: You should receive a structured JSON response containing the requested data.

Expected Response

Here's an example of the JSON response you'll receive:

Sample Response
{
  "success": true,
  "credits_remaining": 49997232025,
  "albumsV2": [
    {
      "id": "3Pceq8de2pHC1rddG2G88l",
      "__typename": "Album",
      "artists": [
        {
          "profile": {
            "name": "The Antediluvian"
          },
          "uri": "spotify:artist:1expE9R1GqL3lGGh5HDH8t"
        }
      ],
      "coverArt": {
        "extractedColors": {
          "colorDark": {
            "hex": "#535353",
            "isFallback": true
          }
        },
        "sources": [
          {
            "height": 300,
            "url": "https://i.scdn.co/image/ab67616d00001e0230562d52a17a5892eb0958d7",
            "width": 300
          },
          {
            "height": 64,
            "url": "https://i.scdn.co/image/ab67616d0000485130562d52a17a5892eb0958d7",
            "width": 64
          },
          {
            "height": 640,
            "url": "https://i.scdn.co/image/ab67616d0000b27330562d52a17a5892eb0958d7",
            "width": 640
          }
        ]
      },
      "date": {
        "year": 2026
      },
      "isAlbumPreRelease": false,
      "name": "My First Million (Jesse Livermore Story / Stock Operator Soundtrack)",
      "playability": {
        "playable": true,
        "reason": "PLAYABLE"
      },
      "preReleaseEndDateTime": null,
      "type": "SINGLE",
      "uri": "spotify:album:3Pceq8de2pHC1rddG2G88l",
      "visualIdentity": {
        "squareCoverImage": {
          "__typename": "VisualIdentityImage",
          "extractedColorSet": {
            "encoreBaseSetTextColor": {
              "alpha": 255,
              "blue": 187,
              "green": 187,
              "red": 187
            },
            "highContrast": {
              "backgroundBase": {
                "alpha": 255,
                "blue": 83,
                "green": 83,
                "red": 83
              },
              "backgroundTintedBase": {
                "alpha": 255,
                "blue": 51,
                "green": 51,
                "red": 51
              },
              "textBase": {
                "alpha": 255,
                "blue": 255,
                "green": 255,
                "red": 255
              },
              "textBrightAccent": {
                "alpha": 255,
                "blue": 255,
                "green": 255,
                "red": 255
              },
              "textSubdued": {
                "alpha": 255,
                "blue": 205,
                "green": 205,
                "red": 205
              }
            },
            "higherContrast": {
              "backgroundBase": {
                "alpha": 255,
                "blue": 53,
                "green": 53,
                "red": 53
              },
              "backgroundTintedBase": {
                "alpha": 255,
                "blue": 86,
                "green": 86,
                "red": 86
              },
              "textBase": {
                "alpha": 255,
                "blue": 255,
                "green": 255,
                "red": 255
              },
              "textBrightAccent": {
                "alpha": 255,
                "blue": 96,
                "green": 215,
                "red": 30
              },
              "textSubdued": {
                "alpha": 255,
                "blue": 205,
                "green": 205,
                "red": 205
              }
            },
            "minContrast": {
              "backgroundBase": {
                "alpha": 255,
                "blue": 83,
                "green": 83,
                "red": 83
              },
              "backgroundTintedBase": {
                "alpha": 255,
                "blue": 51,
                "green": 51,
                "red": 51
              },
              "textBase": {
                "alpha": 255,
                "blue": 255,
                "green": 255,
                "red": 255
              },
              "textBrightAccent": {
                "alpha": 255,
                "blue": 255,
                "green": 255,
                "red": 255
              },
              "textSubdued": {
                "alpha": 255,
                "blue": 255,
                "green": 255,
                "red": 255
              }
            }
          }
        }
      }
    }
  ],
  "artists": [
    {
      "id": "1QsfhlGvu9tLL2PSmEr8TM",
      "__typename": "Artist",
      "onPlatformReputationTrait": {
        "verification": {
          "isVerified": true
        }
      },
      "profile": {
        "name": "Small Million"
      },
      "uri": "spotify:artist:1QsfhlGvu9tLL2PSmEr8TM",
      "visualIdentity": {
        "squareCoverImage": {
          "__typename": "VisualIdentityImage",
          "extractedColorSet": {
            "encoreBaseSetTextColor": {
              "alpha": 255,
              "blue": 209,
              "green": 183,
              "red": 191
            },
            "highContrast": {
              "backgroundBase": {
                "alpha": 255,
                "blue": 102,
                "green": 80,
                "red": 87
              },
              "backgroundTintedBase": {
                "alpha": 255,
                "blue": 68,
                "green": 47,
                "red": 55
              },
              "textBase": {
                "alpha": 255,
                "blue": 255,
                "green": 255,
                "red": 255
              },
              "textBrightAccent": {
                "alpha": 255,
                "blue": 255,
                "green": 255,
                "red": 255
              },
              "textSubdued": {
                "alpha": 255,
                "blue": 228,
                "green": 201,
                "red": 210
              }
            },
            "higherContrast": {
              "backgroundBase": {
                "alpha": 255,
                "blue": 71,
                "green": 50,
                "red": 57
              },
              "backgroundTintedBase": {
                "alpha": 255,
                "blue": 105,
                "green": 82,
                "red": 90
              },
              "textBase": {
                "alpha": 255,
                "blue": 255,
                "green": 255,
                "red": 255
              },
              "textBrightAccent": {
                "alpha": 255,
                "blue": 96,
                "green": 215,
                "red": 30
              },
              "textSubdued": {
                "alpha": 255,
                "blue": 228,
                "green": 201,
                "red": 210
              }
            },
            "minContrast": {
              "backgroundBase": {
                "alpha": 255,
                "blue": 136,
                "green": 112,
                "red": 120
              },
              "backgroundTintedBase": {
                "alpha": 255,
                "blue": 108,
                "green": 85,
                "red": 92
              },
              "textBase": {
                "alpha": 255,
                "blue": 255,
                "green": 255,
                "red": 255
              },
              "textBrightAccent": {
                "alpha": 255,
                "blue": 255,
                "green": 255,
                "red": 255
              },
              "textSubdued": {
                "alpha": 255,
                "blue": 255,
                "green": 255,
                "red": 255
              }
            }
          }
        }
      },
      "visuals": {
        "avatarImage": {
          "extractedColors": {
            "colorDark": {
              "hex": "#787088",
              "isFallback": false
            }
          },
          "sources": [
            {
              "height": 640,
              "url": "https://i.scdn.co/image/ab6761610000e5eb58f2728543287fcbd8de3e4c",
              "width": 640
            },
            {
              "height": 160,
              "url": "https://i.scdn.co/image/ab6761610000f17858f2728543287fcbd8de3e4c",
              "width": 160
            },
            {
              "height": 320,
              "url": "https://i.scdn.co/image/ab6761610000517458f2728543287fcbd8de3e4c",
              "width": 320
            }
          ]
        }
      }
    }
  ],
  "audiobooks": [
    {
      "id": "3CuDAyUZ9XSAXKAYmk7jEu",
      "__typename": "Audiobook",
      "accessInfo": {
        "accessExplanation": {
          "__typename": "EngagementAccessExplanation"
        },
        "isUserMemberOfAtLeastOneGroup": false,
        "signifier": {
          "text": ""
        }
      },
      "authorsV2": [
        {
          "name": "Steven Bartlett",
          "uri": "spotify:author:3McnkRBnDLs8VUFMjilc2N"
        }
      ],
      "coverArt": {
        "extractedColors": {
          "colorDark": {
            "hex": "#404040",
            "isFallback": false
          }
        },
        "sources": [
          {
            "height": 64,
            "url": "https://i.scdn.co/image/ab6766630000703b2f6a96457fa76c06b435fd50",
            "width": 64
          },
          {
            "height": 300,
            "url": "https://i.scdn.co/image/ab6766630000db5b2f6a96457fa76c06b435fd50",
            "width": 300
          },
          {
            "height": 640,
            "url": "https://i.scdn.co/image/ab676663000022a82f6a96457fa76c06b435fd50",
            "width": 640
          }
        ]
      },
      "description": "Author(s): Steven Bartlett\nNarrator(s): Steven Bartlett\n\nA galvanizing playbook for success from Steven Bartlett, one of the world’s most exciting entrepreneurs and the host of the No. 1 podcast The Diary of a CEO\"This is a must-read for anyone dreaming of doing something audacious.\" Jay Shetty\"Valuable lessons about the importance of following a different and unconventional path to power.” Robert GreeneAt the very heart of all the success and failure I've been exposed to - both my own entrepreneurial journey and through the thousands of interviews I’ve conducted on my chart-topping podcast - are a set of principles that ensure excellence.These fundamental laws underpinned my meteoric rise, and they will fuel yours too, whether you want to build something great or become someone great. The laws are rooted in psychology and behavioral science, in my own experiences, and those of the world's most successful entrepreneurs, entertainers, artists, writers, and athletes, who I’ve interviewed on my podcast.These laws will stand the test of time and will help anyone master their life and unleash their potential, no matter the field.They are the secret sauce to success.",
      "audiobookDuration": {
        "totalMilliseconds": 24291148
      },
      "isPreRelease": false,
      "mediaType": "AUDIO",
      "name": "The Diary of a CEO: The 33 Laws of Business and Life",
      "preReleaseEndDateTime": {
        "isoString": "2025-11-11T08:00:00Z"
      },
      "publishDate": {
        "isoString": "2023-08-29T00:00:00Z",
        "precision": "MINUTE"
      },
      "topics": [],
      "uri": "spotify:show:3CuDAyUZ9XSAXKAYmk7jEu",
      "visualIdentity": {
        "squareCoverImage": {
          "__typename": "VisualIdentityImage",
          "extractedColorSet": {
            "encoreBaseSetTextColor": {
              "alpha": 255,
              "blue": 187,
              "green": 187,
              "red": 187
            },
            "highContrast": {
              "backgroundBase": {
                "alpha": 255,
                "blue": 64,
                "green": 64,
                "red": 64
              },
              "backgroundTintedBase": {
                "alpha": 255,
                "blue": 94,
                "green": 94,
                "red": 94
              },
              "textBase": {
                "alpha": 255,
                "blue": 255,
                "green": 255,
                "red": 255
              },
              "textBrightAccent": {
                "alpha": 255,
                "blue": 255,
                "green": 255,
                "red": 255
              },
              "textSubdued": {
                "alpha": 255,
                "blue": 205,
                "green": 205,
                "red": 205
              }
            },
            "higherContrast": {
              "backgroundBase": {
                "alpha": 255,
                "blue": 53,
                "green": 53,
                "red": 53
              },
              "backgroundTintedBase": {
                "alpha": 255,
                "blue": 86,
                "green": 86,
                "red": 86
              },
              "textBase": {
                "alpha": 255,
                "blue": 255,
                "green": 255,
                "red": 255
              },
              "textBrightAccent": {
                "alpha": 255,
                "blue": 96,
                "green": 215,
                "red": 30
              },
              "textSubdued": {
                "alpha": 255,
                "blue": 205,
                "green": 205,
                "red": 205
              }
            },
            "minContrast": {
              "backgroundBase": {
                "alpha": 255,
                "blue": 64,
                "green": 64,
                "red": 64
              },
              "backgroundTintedBase": {
                "alpha": 255,
                "blue": 94,
                "green": 94,
                "red": 94
              },
              "textBase": {
                "alpha": 255,
                "blue": 255,
                "green": 255,
                "red": 255
              },
              "textBrightAccent": {
                "alpha": 255,
                "blue": 255,
                "green": 255,
                "red": 255
              },
              "textSubdued": {
                "alpha": 255,
                "blue": 255,
                "green": 255,
                "red": 255
              }
            }
          }
        }
      }
    }
  ],
  "episodes": [
    {
      "id": "3rvl30aWNqZbWi9dnolG3a",
      "__typename": "Episode",
      "contentRating": {
        "label": "NONE"
      },
      "coverArt": {
        "extractedColors": {
          "colorDark": {
            "hex": "#484848",
            "isFallback": false
          }
        },
        "sources": [
          {
            "height": 64,
            "url": "https://i.scdn.co/image/ab6765630000f68d35af1b9c3ee719329f85f229",
            "width": 64
          },
          {
            "height": 300,
            "url": "https://i.scdn.co/image/ab67656300005f1f35af1b9c3ee719329f85f229",
            "width": 300
          },
          {
            "height": 640,
            "url": "https://i.scdn.co/image/ab6765630000ba8a35af1b9c3ee719329f85f229",
            "width": 640
          }
        ]
      },
      "description": "Get our Wealth Guide (35+ insights from top investors): https://clickhubspot.com/fvif  Episode 828: Shaan Puri ( https://x.com/ShaanVP ) and Sam Parr ( https://x.com/theSamParr ) talk to billionaire Joe Liemandt ( https://x.com/jliemandt ) about the experiment he’s put $1,000,000,000 of his own money into. — Show Notes:  (0:00) Joe, the total man? (08:09) fighting bill gates for talent (13:14) intensity (16:18) choosing hard over easy (19:00) how to be a magnet (21:34) high standards (23:29) being persuasive  (29:23) simplicity: 3 ines, 3 words  (34:41) is 2x faster really better? (36:23) making kids run a 5k (38:45) why be public now (41:01) why put $1b into the lowest roi thing? (50:03) buying SaaS companies (51:06) cloning Warren Buffett's brain (53:00) changing your brain lift (57:19) is AI going to make everyone dumb?  — Links: • Alpha School - https://alpha.school/  • 10 to 25: The Science of Motivating Young People - https://a.co/d/048Cfexh  — Check Out Sam's Stuff: • Hampton (joinhampton.com): My community for founders. Average member does $25m/year. Many of the guests are members. Get after it...apply: http://joinhampton.com/mfm — Check Out Shaan's Stuff: • Shaan's weekly email - https://www.shaanpuri.com  • Visit https://www.somewhere.com/mfm to hire worldwide talent like Shaan and get $500 off for being an MFM listener. Hire developers, assistants, marketing pros, sales teams and more for 80% less than US equivalents. • Mercury - Need a bank for your company? Go check out Mercury (mercury.com). Shaan uses it for all of his companies! Mercury is a financial technology company, not an FDIC-insured bank. Banking services provided by Choice Financial Group, Column, N.A., and Evolve Bank & Trust, Members FDIC • I run all my newsletters on Beehiiv and you should too + we're giving away $10k to our favorite newsletter, check it out: beehiiv.com/mfm-challenge My First Million is a HubSpot Original Podcast // Brought to you by HubSpot Media // Production by Arie Desormeaux // Editing by Ezra Bakker Trupiano / ",
      "duration": {
        "totalMilliseconds": 3903344
      },
      "gatedEntityRelations": [],
      "mediaTypes": [
        "VIDEO",
        "AUDIO"
      ],
      "name": "The 50 richest families in America are betting on this trend",
      "playability": {
        "reason": "PLAYABLE"
      },
      "playedState": {
        "playPositionMilliseconds": 0,
        "state": "NOT_STARTED"
      },
      "podcastV2": {
        "__typename": "PodcastResponseWrapper",
        "data": {
          "__typename": "Podcast",
          "coverArt": {
            "sources": [
              {
                "height": 64,
                "url": "https://i.scdn.co/image/ab6765630000f68d35af1b9c3ee719329f85f229",
                "width": 64
              },
              {
                "height": 300,
                "url": "https://i.scdn.co/image/ab67656300005f1f35af1b9c3ee719329f85f229",
                "width": 300
              },
              {
                "height": 640,
                "url": "https://i.scdn.co/image/ab6765630000ba8a35af1b9c3ee719329f85f229",
                "width": 640
              }
            ]
          },
          "mediaType": "MIXED",
          "name": "My First Million",
          "publisher": {
            "name": "Hubspot"
          },
          "uri": "spotify:show:3mliji9352UAk3XnWElnDV"
        }
      },
      "releaseDate": {
        "isoString": "2026-05-27T08:59:00Z",
        "precision": "MINUTE"
      },
      "restrictions": {
        "paywallContent": false
      },
      "uri": "spotify:episode:3rvl30aWNqZbWi9dnolG3a",
      "videoPreviewThumbnail": {
        "__typename": "VideoThumbnailImage",
        "imagePreview": {
          "__typename": "ImageV2",
          "sources": [
            {
              "maxHeight": 720,
              "maxWidth": 1280,
              "url": "https://image-cdn-fa.spotifycdn.com/image/ab6772ab000030aeae7253d400b6cde5defd1197"
            },
            {
              "maxHeight": 360,
              "maxWidth": 640,
              "url": "https://image-cdn-fa.spotifycdn.com/image/ab6772ab0000e0e7ae7253d400b6cde5defd1197"
            }
          ]
        }
      },
      "visualIdentity": {
        "squareCoverImage": {
          "__typename": "VisualIdentityImage",
          "extractedColorSet": {
            "encoreBaseSetTextColor": {
              "alpha": 255,
              "blue": 187,
              "green": 187,
              "red": 187
            },
            "highContrast": {
              "backgroundBase": {
                "alpha": 255,
                "blue": 72,
                "green": 72,
                "red": 72
              },
              "backgroundTintedBase": {
                "alpha": 255,
                "blue": 33,
                "green": 33,
                "red": 33
              },
              "textBase": {
                "alpha": 255,
                "blue": 255,
                "green": 255,
                "red": 255
              },
              "textBrightAccent": {
                "alpha": 255,
                "blue": 255,
                "green": 255,
                "red": 255
              },
              "textSubdued": {
                "alpha": 255,
                "blue": 205,
                "green": 205,
                "red": 205
              }
            },
            "higherContrast": {
              "backgroundBase": {
                "alpha": 255,
                "blue": 53,
                "green": 53,
                "red": 53
              },
              "backgroundTintedBase": {
                "alpha": 255,
                "blue": 86,
                "green": 86,
                "red": 86
              },
              "textBase": {
                "alpha": 255,
                "blue": 255,
                "green": 255,
                "red": 255
              },
              "textBrightAccent": {
                "alpha": 255,
                "blue": 96,
                "green": 215,
                "red": 30
              },
              "textSubdued": {
                "alpha": 255,
                "blue": 205,
                "green": 205,
                "red": 205
              }
            },
            "minContrast": {
              "backgroundBase": {
                "alpha": 255,
                "blue": 72,
                "green": 72,
                "red": 72
              },
              "backgroundTintedBase": {
                "alpha": 255,
                "blue": 33,
                "green": 33,
                "red": 33
              },
              "textBase": {
                "alpha": 255,
                "blue": 255,
                "green": 255,
                "red": 255
              },
              "textBrightAccent": {
                "alpha": 255,
                "blue": 255,
                "green": 255,
                "red": 255
              },
              "textSubdued": {
                "alpha": 255,
                "blue": 255,
                "green": 255,
                "red": 255
              }
            }
          }
        }
      }
    }
  ],
  "genres": [
    {
      "id": "0JQ5IMCbQBLABracA7Zrmn",
      "__typename": "Genre",
      "image": {
        "extractedColors": {
          "colorDark": {
            "hex": "#104848",
            "isFallback": false
          }
        },
        "sources": [
          {
            "height": 274,
            "url": "https://t.scdn.co/images/728ed47fc1674feb95f7ac20236eb6d7.jpeg",
            "width": 274
          }
        ]
      },
      "name": "Inside the AI Revolution",
      "uri": "spotify:genre:0JQ5IMCbQBLABracA7Zrmn"
    }
  ],
  "playlists": [
    {
      "id": "2GEFdJC5hCdUFpU1xxFUug",
      "__typename": "Playlist",
      "attributes": [],
      "description": "",
      "format": "",
      "images": [
        {
          "extractedColors": {
            "colorDark": {
              "hex": "#767676",
              "isFallback": false
            }
          },
          "sources": [
            {
              "height": null,
              "url": "https://image-cdn-ak.spotifycdn.com/image/ab67706c0000d72c24c483f6c267f53f8625404d",
              "width": null
            }
          ]
        }
      ],
      "name": "Start Here | My First Million",
      "ownerV2": {
        "__typename": "UserResponseWrapper",
        "data": {
          "__typename": "User",
          "avatar": {
            "sources": [
              {
                "height": 64,
                "url": "https://i.scdn.co/image/ab67757000003b829da4040165ac26081197ade4",
                "width": 64
              },
              {
                "height": 300,
                "url": "https://i.scdn.co/image/ab6775700000ee859da4040165ac26081197ade4",
                "width": 300
              }
            ]
          },
          "name": "HubSpot Podcast Network",
          "uri": "spotify:user:31i2jq7ljcu7ob5pk6w2flztsoo4",
          "username": "31i2jq7ljcu7ob5pk6w2flztsoo4"
        }
      },
      "uri": "spotify:playlist:2GEFdJC5hCdUFpU1xxFUug",
      "visualIdentity": {
        "squareCoverImage": {
          "__typename": "VisualIdentityImage",
          "extractedColorSet": {
            "encoreBaseSetTextColor": {
              "alpha": 255,
              "blue": 192,
              "green": 192,
              "red": 192
            },
            "highContrast": {
              "backgroundBase": {
                "alpha": 255,
                "blue": 83,
                "green": 83,
                "red": 83
              },
              "backgroundTintedBase": {
                "alpha": 255,
                "blue": 51,
                "green": 51,
                "red": 51
              },
              "textBase": {
                "alpha": 255,
                "blue": 255,
                "green": 255,
                "red": 255
              },
              "textBrightAccent": {
                "alpha": 255,
                "blue": 255,
                "green": 255,
                "red": 255
              },
              "textSubdued": {
                "alpha": 255,
                "blue": 205,
                "green": 205,
                "red": 205
              }
            },
            "higherContrast": {
              "backgroundBase": {
                "alpha": 255,
                "blue": 53,
                "green": 53,
                "red": 53
              },
              "backgroundTintedBase": {
                "alpha": 255,
                "blue": 86,
                "green": 86,
                "red": 86
              },
              "textBase": {
                "alpha": 255,
                "blue": 255,
                "green": 255,
                "red": 255
              },
              "textBrightAccent": {
                "alpha": 255,
                "blue": 96,
                "green": 215,
                "red": 30
              },
              "textSubdued": {
                "alpha": 255,
                "blue": 205,
                "green": 205,
                "red": 205
              }
            },
            "minContrast": {
              "backgroundBase": {
                "alpha": 255,
                "blue": 153,
                "green": 153,
                "red": 153
              },
              "backgroundTintedBase": {
                "alpha": 255,
                "blue": 128,
                "green": 128,
                "red": 128
              },
              "textBase": {
                "alpha": 255,
                "blue": 255,
                "green": 255,
                "red": 255
              },
              "textBrightAccent": {
                "alpha": 255,
                "blue": 255,
                "green": 255,
                "red": 255
              },
              "textSubdued": {
                "alpha": 255,
                "blue": 255,
                "green": 255,
                "red": 255
              }
            }
          }
        }
      }
    }
  ],
  "podcasts": [
    {
      "id": "3mliji9352UAk3XnWElnDV",
      "__typename": "Podcast",
      "coverArt": {
        "extractedColors": {
          "colorDark": {
            "hex": "#484848",
            "isFallback": false
          }
        },
        "sources": [
          {
            "height": 64,
            "url": "https://i.scdn.co/image/ab6765630000f68d35af1b9c3ee719329f85f229",
            "width": 64
          },
          {
            "height": 300,
            "url": "https://i.scdn.co/image/ab67656300005f1f35af1b9c3ee719329f85f229",
            "width": 300
          },
          {
            "height": 640,
            "url": "https://i.scdn.co/image/ab6765630000ba8a35af1b9c3ee719329f85f229",
            "width": 640
          }
        ]
      },
      "mediaType": "MIXED",
      "name": "My First Million",
      "publisher": {
        "name": "Hubspot"
      },
      "topics": [
        {
          "__typename": "PodcastTopic",
          "title": "Business",
          "uri": "spotify:genre:0JQ5DAqbMKFK0EBNV8Wn6R"
        }
      ],
      "uri": "spotify:show:3mliji9352UAk3XnWElnDV",
      "visualIdentity": {
        "squareCoverImage": {
          "__typename": "VisualIdentityImage",
          "extractedColorSet": {
            "encoreBaseSetTextColor": {
              "alpha": 255,
              "blue": 187,
              "green": 187,
              "red": 187
            },
            "highContrast": {
              "backgroundBase": {
                "alpha": 255,
                "blue": 72,
                "green": 72,
                "red": 72
              },
              "backgroundTintedBase": {
                "alpha": 255,
                "blue": 33,
                "green": 33,
                "red": 33
              },
              "textBase": {
                "alpha": 255,
                "blue": 255,
                "green": 255,
                "red": 255
              },
              "textBrightAccent": {
                "alpha": 255,
                "blue": 255,
                "green": 255,
                "red": 255
              },
              "textSubdued": {
                "alpha": 255,
                "blue": 205,
                "green": 205,
                "red": 205
              }
            },
            "higherContrast": {
              "backgroundBase": {
                "alpha": 255,
                "blue": 53,
                "green": 53,
                "red": 53
              },
              "backgroundTintedBase": {
                "alpha": 255,
                "blue": 86,
                "green": 86,
                "red": 86
              },
              "textBase": {
                "alpha": 255,
                "blue": 255,
                "green": 255,
                "red": 255
              },
              "textBrightAccent": {
                "alpha": 255,
                "blue": 96,
                "green": 215,
                "red": 30
              },
              "textSubdued": {
                "alpha": 255,
                "blue": 205,
                "green": 205,
                "red": 205
              }
            },
            "minContrast": {
              "backgroundBase": {
                "alpha": 255,
                "blue": 72,
                "green": 72,
                "red": 72
              },
              "backgroundTintedBase": {
                "alpha": 255,
                "blue": 33,
                "green": 33,
                "red": 33
              },
              "textBase": {
                "alpha": 255,
                "blue": 255,
                "green": 255,
                "red": 255
              },
              "textBrightAccent": {
                "alpha": 255,
                "blue": 255,
                "green": 255,
                "red": 255
              },
              "textSubdued": {
                "alpha": 255,
                "blue": 255,
                "green": 255,
                "red": 255
              }
            }
          }
        }
      }
    }
  ],
  "topResultsV2": [
    {
      "id": "3mliji9352UAk3XnWElnDV",
      "__typename": "Podcast",
      "coverArt": {
        "extractedColors": {
          "colorDark": {
            "hex": "#484848",
            "isFallback": false
          }
        },
        "sources": [
          {
            "height": 64,
            "url": "https://i.scdn.co/image/ab6765630000f68d35af1b9c3ee719329f85f229",
            "width": 64
          },
          {
            "height": 300,
            "url": "https://i.scdn.co/image/ab67656300005f1f35af1b9c3ee719329f85f229",
            "width": 300
          },
          {
            "height": 640,
            "url": "https://i.scdn.co/image/ab6765630000ba8a35af1b9c3ee719329f85f229",
            "width": 640
          }
        ]
      },
      "mediaType": "MIXED",
      "name": "My First Million",
      "publisher": {
        "name": "Hubspot"
      },
      "topics": [
        {
          "__typename": "PodcastTopic",
          "title": "Business",
          "uri": "spotify:genre:0JQ5DAqbMKFK0EBNV8Wn6R"
        }
      ],
      "uri": "spotify:show:3mliji9352UAk3XnWElnDV",
      "visualIdentity": {
        "squareCoverImage": {
          "__typename": "VisualIdentityImage",
          "extractedColorSet": {
            "encoreBaseSetTextColor": {
              "alpha": 255,
              "blue": 187,
              "green": 187,
              "red": 187
            },
            "highContrast": {
              "backgroundBase": {
                "alpha": 255,
                "blue": 72,
                "green": 72,
                "red": 72
              },
              "backgroundTintedBase": {
                "alpha": 255,
                "blue": 33,
                "green": 33,
                "red": 33
              },
              "textBase": {
                "alpha": 255,
                "blue": 255,
                "green": 255,
                "red": 255
              },
              "textBrightAccent": {
                "alpha": 255,
                "blue": 255,
                "green": 255,
                "red": 255
              },
              "textSubdued": {
                "alpha": 255,
                "blue": 205,
                "green": 205,
                "red": 205
              }
            },
            "higherContrast": {
              "backgroundBase": {
                "alpha": 255,
                "blue": 53,
                "green": 53,
                "red": 53
              },
              "backgroundTintedBase": {
                "alpha": 255,
                "blue": 86,
                "green": 86,
                "red": 86
              },
              "textBase": {
                "alpha": 255,
                "blue": 255,
                "green": 255,
                "red": 255
              },
              "textBrightAccent": {
                "alpha": 255,
                "blue": 96,
                "green": 215,
                "red": 30
              },
              "textSubdued": {
                "alpha": 255,
                "blue": 205,
                "green": 205,
                "red": 205
              }
            },
            "minContrast": {
              "backgroundBase": {
                "alpha": 255,
                "blue": 72,
                "green": 72,
                "red": 72
              },
              "backgroundTintedBase": {
                "alpha": 255,
                "blue": 33,
                "green": 33,
                "red": 33
              },
              "textBase": {
                "alpha": 255,
                "blue": 255,
                "green": 255,
                "red": 255
              },
              "textBrightAccent": {
                "alpha": 255,
                "blue": 255,
                "green": 255,
                "red": 255
              },
              "textSubdued": {
                "alpha": 255,
                "blue": 255,
                "green": 255,
                "red": 255
              }
            }
          }
        }
      }
    }
  ],
  "tracksV2": [
    {
      "__typename": "Track",
      "albumOfTrack": {
        "coverArt": {
          "extractedColors": {
            "colorDark": {
              "hex": "#C0591A",
              "isFallback": false
            }
          },
          "sources": [
            {
              "height": 300,
              "url": "https://i.scdn.co/image/ab67616d00001e0288c0b52eb38719ef4de33126",
              "width": 300
            },
            {
              "height": 64,
              "url": "https://i.scdn.co/image/ab67616d0000485188c0b52eb38719ef4de33126",
              "width": 64
            },
            {
              "height": 640,
              "url": "https://i.scdn.co/image/ab67616d0000b27388c0b52eb38719ef4de33126",
              "width": 640
            }
          ]
        },
        "id": "0if4nypvSlgICcSKq8Xmm8",
        "name": "Spurs & Spokes / Bull > Matador - EP",
        "uri": "spotify:album:0if4nypvSlgICcSKq8Xmm8",
        "visualIdentity": {
          "squareCoverImage": {
            "__typename": "VisualIdentityImage",
            "extractedColorSet": {
              "encoreBaseSetTextColor": {
                "alpha": 255,
                "blue": 113,
                "green": 165,
                "red": 255
              },
              "highContrast": {
                "backgroundBase": {
                  "alpha": 255,
                  "blue": 0,
                  "green": 47,
                  "red": 146
                },
                "backgroundTintedBase": {
                  "alpha": 255,
                  "blue": 0,
                  "green": 6,
                  "red": 97
                },
                "textBase": {
                  "alpha": 255,
                  "blue": 255,
                  "green": 255,
                  "red": 255
                },
                "textBrightAccent": {
                  "alpha": 255,
                  "blue": 255,
                  "green": 255,
                  "red": 255
                },
                "textSubdued": {
                  "alpha": 255,
                  "blue": 155,
                  "green": 192,
                  "red": 255
                }
              },
              "higherContrast": {
                "backgroundBase": {
                  "alpha": 255,
                  "blue": 0,
                  "green": 7,
                  "red": 101
                },
                "backgroundTintedBase": {
                  "alpha": 255,
                  "blue": 41,
                  "green": 54,
                  "red": 145
                },
                "textBase": {
                  "alpha": 255,
                  "blue": 255,
                  "green": 255,
                  "red": 255
                },
                "textBrightAccent": {
                  "alpha": 255,
                  "blue": 96,
                  "green": 215,
                  "red": 30
                },
                "textSubdued": {
                  "alpha": 255,
                  "blue": 155,
                  "green": 192,
                  "red": 255
                }
              },
              "minContrast": {
                "backgroundBase": {
                  "alpha": 255,
                  "blue": 32,
                  "green": 112,
                  "red": 240
                },
                "backgroundTintedBase": {
                  "alpha": 255,
                  "blue": 0,
                  "green": 85,
                  "red": 210
                },
                "textBase": {
                  "alpha": 255,
                  "blue": 255,
                  "green": 255,
                  "red": 255
                },
                "textBrightAccent": {
                  "alpha": 255,
                  "blue": 255,
                  "green": 255,
                  "red": 255
                },
                "textSubdued": {
                  "alpha": 255,
                  "blue": 255,
                  "green": 255,
                  "red": 255
                }
              }
            }
          }
        }
      },
      "artists": [
        {
          "profile": {
            "name": "Fake Problems"
          },
          "uri": "spotify:artist:3w2meNoSt1JmZaw6QZD35l"
        }
      ],
      "associationsV3": {
        "audioAssociations": {
          "totalCount": 0
        },
        "videoAssociations": {
          "totalCount": 0
        }
      },
      "contentRating": {
        "label": "NONE"
      },
      "duration": {
        "totalMilliseconds": 162840
      },
      "id": "1QlYhKt1pomveBX7W3MbqL",
      "trackMediaType": "AUDIO",
      "name": "My First Million",
      "playability": {
        "playable": true,
        "reason": "PLAYABLE"
      },
      "uri": "spotify:track:1QlYhKt1pomveBX7W3MbqL",
      "visualIdentity": {
        "sixteenByNineCoverImage": null
      }
    }
  ],
  "users": []
}

Verify Response Structure

Check that your response includes the expected fields:

  • success(boolean)
  • credits_remaining(number)
  • albumsV2(object)
  • artists(object)
  • audiobooks(object)
  • ... and 7 more fields

Best Practices

1

Error Handling

Implement comprehensive error handling and retry logic for failed requests. Log errors properly for debugging.

2

Caching

Cache responses when possible to reduce API calls and improve performance. Consider data freshness requirements.

3

Security

Never expose your API key in client-side code. Use environment variables and secure key management practices.

Performance Tips

Batch Requests

When scraping multiple search results, consider batching requests to maximize throughput while staying within rate limits.

Async Processing

Use asynchronous processing in Java to handle multiple requests concurrently and improve overall performance.

Common Use Cases

Market Research

Analyze Spotify search results to understand market trends, competitor analysis, and audience insights.

Content Analytics

Track performance metrics, engagement rates, and content trends across Spotify search results.

Lead Generation

Identify potential customers and business opportunities throughSpotify data analysis.

Troubleshooting

Common Errors

401 Unauthorized

Check your API key is correct and properly formatted in the x-api-key header.

402 Payment Required

You ran out of credits and need to buy more.

404 Not Found

The resource might not exist or be private.

500 Server Error

Temporary server issue. Implement retry logic with exponential backoff.

Frequently Asked Questions

How much does it cost to scrape Spotify search results?

ScrapeCreators offers 100 free API calls to get started. After that, pricing starts at $10 for 5k requests with volume discounts available.

Is it legal to scrape Spotify data?

Scraping publicly available data is fair game, and we only collect public data. So anything that you can see in an incognito browser is what we collect.

How fast can I scrape Spotify search results?

There is no rate limit! So you can scrape as fast as you want!

What data format does the API return?

All API responses are returned in JSON format, making it easy to integrate with any programming language or application.

Can I use this with other Java frameworks?

Yes! This tutorial focuses on core Java HTTP concepts that work with any framework. The API calls remain the same regardless of your specific Java setup.

How do I handle large datasets?

For large datasets, implement pagination, use streaming responses where available, and consider storing data in a database for efficient querying.

Related Tutorials

Ready to ship?

Get the API key. Run the code.

100 free API calls. No credit card. Same endpoint, same response shape.

Same endpoint, different language

Pick another stack.