I am trying to get the top ten tracks for an artist, but I don't know how to get Spotify id for that particular artist? this is the end point.
GET /v1/artists/{id}/top-tracks
The premise is this, i should be able to type an artist name, and I should get the JSON data for the top ten tracks.
function test() {
var query = $('#searchArtist').val();
console.log(query);
$.ajax({
url: 'https://api.spotify.com/v1/artists/' + query + '/top-tracks?country=IN',
success: function(response) {
console.log(response)
}
})
}
$('#search').on('click', test);
Am I supposed to first authorize? Because I searched the document and fetching the top ten tracks data doesn't require authorization.
Also, to let you know. There is no backend environment here, as mentioned in the docs, it is not required for simple data fetch.