In [ ]:
import requests

In [ ]:
response = requests.get('http/api.spotify.com/v1/search?query=80s&type=playlist')

In [1]:
print(response.text)


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-1-9599ea856ea5> in <module>()
----> 1 print(response.text)

NameError: name 'response' is not defined

In [ ]:
data = response.json()

In [ ]:
type(data)

In [ ]:
data.keys()

In [2]:
playlist_response = request.get('http/api.spotify.com/v1/search?query=biggie&type=playlist')


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-2-fd6fc1a0b052> in <module>()
----> 1 response = request.get('http/api.spotify.com/v1/search?query=biggie&type=playlist')

NameError: name 'request' is not defined

In [ ]:
playlists_data = playlist_response.json()

In [ ]:
biggie_response = requests.get('https://api.spotify.com/v1/search?query=biggie&type=artist')
biggie_data = biggie_response.json()

In [ ]:
data.keys()

In [ ]:
type(data['artists'])

In [ ]:
data['artists'].keys()

In [ ]:
biggie_artists = data['artists']['items']

In [ ]:
for artist in biggie_artists:
    print(artist['name'], artist['popularity'], artist['id'])

In [3]:
#http://api.spotify.com/v1/artists/{id}/top-tracks 
#From https://developer.spotify.com/web-api/console/artists/

#Biggie the Kid
response = requests.get("https://api.spotify.com/v1/artists/1RpIWJHxLsDE8YfFcRaBKw/top-tracks?country=US")
data = response.json()
tracks = data['tracks']
for track in tracks:
   print(track['name'])


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-3-fd9a692d4110> in <module>()
      2 #From https://developer.spotify.com/web-api/console/artists/
      3 
----> 4 response = requests.get("/v1/artists/{id}/top-tracks")

NameError: name 'requests' is not defined

In [ ]:
#How explicit is Biggie the Kid?
response = requests.get("https://api.spotify.com/v1/artists/1RpIWJHxLsDE8YfFcRaBKw/top-tracks?country=US")
data = response.json()
tracks = data['tracks']
#Counting Problem!!
#PART ONE: Initial condition (a.ka. our start value)
track_count = 0 #I don't know of any tracks!!
explicit_count = 0
for track in tracks:
    #You can discover new things in here!
   print(track['name'], track['explicit'])
#Make track count one bigger every time through the loop
   track_count = 1 track_count + 1
#PART TWO: Test, and an increment
    if track['explicit']:
        explicit_count = explicit_count +1 
   print("I have found", track_count, "tracks, and" explicit_count, "are explicit" )
#PART THREE: Final use of our counting
print("Overall, I discovered", track_count, "tracks")
print("And", explicit_count, "we're explicit")
print("Which means", 100 * explicit_count / track_count, "percent were explicit")

In [ ]:


In [ ]:


In [ ]: