I'm trying to create an Android application that contains a feature where you can search for Spotify users by name. When using Spotify, you can search for a user by their ID or by their name. However, currently, I see no way that the Spotify Web API supports searching users by name. If you have the User ID, you can access their profile using the Web API. But I was hoping there was a way that you could run a search for the User name and get their ID that way.
Spotify's Web API allows you to search for a "track" or "artist", where they will return all of the search results. So why can't you do the same with User names? Is there any way to make this work that I'm just not seeing?
I think this is an interesting question, since it regards user data of a huge community, so I will try to figure out.
First, you can clearly see that the Spotify Web API endpoint
search
has atype
parameter that admits only the following types:artist
,playlist
, andtrack
. Let's try it out to run from here (note: see thePromise.all
solution to fetch data I'm using here)NOTE Recent Spotify
search
APIs will require an access token to be specified in the request headers:All those objects are self defined, but one:
playlist
. In fact we can see from this response that we haveuser
objects like (example):Nice!, the
external_urls
are user profiles url, while thehref
are playlists url (that require authentication btw) so that we can first grab them from thisjson
response:At this point you will see a list of spotify
user
objects urls like (example url)So now we can fetch user profiles url (no auth required):
Get it out! At this point we can see
user
objects withdisplay_name
andfollowers
count like (example json):So, to recap, the starting point is
playlist
search type in the search api. Given that, you can get user profiles with no authentication. Assumed that you obtain valid oauth tokens you can fetch top charts to do further queries.