Python Forum

Full Version: Get Spotify Artist URI (Python beginner)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi everyone, I am working on a final project for my master's program. Confused

One of the tasks is to get the Spotify artist URI of each artist(name), listed in a different dataset ('data'). And afterwards I have to add the URI of each artist to the original dataset.

I have been trying something, but I keep getting error messages. Sad
Is there anyone that might be able to help this Python dummy out? Huh

This is my code:
import requests
import json
 
# Setting headers 
headers = {
    'Accept': 'application/json',
    'Content-Type': 'application/json',
    'Authorization': 'Bearer BQDXxeeEiSPLfjhRS_IclrK5HsvL7-VD-EGWGQXUTzGw4DZjGPJKfvnAENy9hAtGplHgW7yngchunypC_1EV_b2CKz_qW6AOoh9fp0yG0ckyCArxAGSqa8aMzW4BHeLiBbD8L7HObUS7zX_XK-PGAvrQF_sUFMpIgpMtcsRi',
}

 
for name in data:
  response = requests.get('	https://api.spotify.com/v1/artists/{id}', headers=headers) # Making request
  json_data = json.loads(response.text) # Converting response into Python data structure
print(json_data)