0
votes

It is possible to search by name for an album in the Spotify catalog using the Spotify Web API.

However, if the album name is a common word or phrase, the search response may contain thousands of results. I can't see a way to narrow the search by artist name.

Here is an example: searching for album Country by artist Giant Panda Guerilla Dub Squad.

The API request is:

http://ws.spotify.com/search/1/album?q=country

The response is:

<?xml version="1.0" encoding="UTF-8"?>
<albums xmlns="http://www.spotify.com/ns/music/1" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">
  <opensearch:Query role="request" startPage="1" searchTerms="country" />
  <opensearch:totalResults>11861</opensearch:totalResults>
  <opensearch:startIndex>0</opensearch:startIndex>
  <opensearch:itemsPerPage>100</opensearch:itemsPerPage>
  <album href="spotify:album:1Wcnyz2zYWLIPZ1K63RXdW">
    <name>How Country Feels</name>
    <artist href="spotify:artist:56x8mYvS3cyDGAi8N2FxbB">
      <name>Randy Houser</name>
    </artist>
    <id type="upc">886443789852</id>
    <popularity>0.73964</popularity>
    <availability>
      <territories>CA US</territories>
    </availability>
  </album>
  ...more albums...
</albums>

There are 11861 results, and the results are paged, with 100 albums per page. A request can be made to get the next page, but if the album I'm looking for is on the last page I will have to make 118 separate requests to the API before I find it.

Is there a better way?

1

1 Answers

2
votes

You can use the advanced search query language to help, especially if you know the artist in advance. For example:

http://ws.spotify.com/search/1/album?q=artist:Giant Panda Guerilla Dub Squad

...will limit the search to albums by that artist.

http://ws.spotify.com/search/1/album?q=artist:Giant Panda Guerilla Dub Squad Country

...will return only the album you want.

The full advanced search reference is currently unavailable in the chaos that was the new Spotify redesign, but you can find it in the Wayback machine here.