Welcome to our Spotify API Module! In this lesson, you will walk through necessary functional steps when working with the API, including:
1. Making a call to the server, searching Spotify's database for a particular artist: Adele.
2. Making a call to the server for 'Adele'-specific information from Spotify's database.
3. Parsing the data the server sends back to you for information of interest.
You will explore this process through a narrative. Click 'Next' to begin the lesson!
Congratulations! You are now a concert manager, and your first duty is to find an artist that is seemingly popular today. You've heard 'Adele' is pretty popular.
Determine the specific artist you want to perform. Search the database for the artist name, then locate the artist's unique ID.
var request = new XMLHttpRequest(); var URL = "https://api.spotify.com/v1/search?type=artist&q=adele"; request.open( "GET", URL, false ); request.send(); var jsonObject = JSON.parse(request.response);
What is the ID of the artist?
After sorting through the database of artists, you've located the correct artist. Call the artist to negotiate the contract and get addition information about her. To do this, fill out the URL below.
Go to the Spotify Endpoint Reference and determine the URL that is used to locate an artist!
Use artist ID 4dpARuHxo51G3z768sgnrY. (To learn more about artist IDs click here).
var request = new XMLHttpRequest(); var URL = "https://api.spotify.com/"; request.open( "GET", URL, false ); request.send(); var jsonObject = JSON.parse(request.response);
Great! The contract has been finalized. You need to decorate the set, and decide you will place the artist's album cover over the drumset.
var stage = true; var followers = jsonObject['images']['url'];
You also need to make sure the artist shows up. Read through the contract (JSON Object on the left) and find the artist's name and follow-up.
var stage = true; var artist = ;
Now that we have our artist, let's get the fans! Find the artist's popularity in their contract to find out the capacity of our concert.
var stage = true; var artist = jsonObject['name']; var popularity = ;