title: Python TypeError JSON parsing from api not working
body: <p>I'm pretty new to Python so forgive me here.</p>
  <p>I'm trying to call/print/log JSON from a GET request. I need to get the id's following this tree: items &gt; track &gt; artists &gt; id.</p>
  <p>Basically im trying to just get the ID's from each track on this JSON file/list. I keep getting errors no matter how I format them. Again im new so im not sure how to call it let also run it in a loop to get all the ID's as an array. I have done it with other JSON files in the past but this one is farther in and I get the error : <code>TypeError: list indices must be integers or slices, not str</code></p>
  <p>I figured out it works when you do it by adding the [0] like this:
  <code>artists = response[&quot;items&quot;][0][&quot;track&quot;][&quot;artists&quot;]</code>  BUT I want to loop it and get all of the Id's for each one and that option picks just one.</p>
  <p>here is the beginning of the json so you can see the layout.</p>
  <pre><code>
  {
    &quot;href&quot;: &quot;https://api.spotify.com/v1/me/tracks?offset=0&amp;limit=15&amp;market=US&quot;, 
    &quot;items&quot;: [
      {
        &quot;added_at&quot;: &quot;2021-12-15T22:26:25Z&quot;, 
        &quot;track&quot;: {
          &quot;album&quot;: {
            &quot;album_type&quot;: &quot;single&quot;, 
            &quot;artists&quot;: [
              {
                &quot;external_urls&quot;: {
                  &quot;spotify&quot;: &quot;https://open.spotify.com/artist/6MlPT0WxdWnrYcpXT8GZF8&quot;
                }, 
                &quot;href&quot;: &quot;https://api.spotify.com/v1/artists/6MlPT0WxdWnrYcpXT8GZF8&quot;, 
                &quot;id&quot;: &quot;6MlPT0WxdWnrYcpXT8GZF8&quot;, 
                &quot;name&quot;: &quot;PARKFORD&quot;, 
                &quot;type&quot;: &quot;artist&quot;, 
                &quot;uri&quot;: &quot;spotify:artist:6MlPT0WxdWnrYcpXT8GZF8&quot;
              }
            ], 
            &quot;external_urls&quot;: {
              &quot;spotify&quot;: &quot;https://open.spotify.com/album/4o2d8uBTyMfJeaJqSXn9tP&quot;
            }, 
            &quot;href&quot;: &quot;https://api.spotify.com/v1/albums/4o2d8uBTyMfJeaJqSXn9tP&quot;, 
            &quot;id&quot;: &quot;4o2d8uBTyMfJeaJqSXn9tP&quot;, 
            &quot;images&quot;: [
              {
                &quot;height&quot;: 640, 
                &quot;url&quot;: &quot;https://i.scdn.co/image/ab67616d0000b27332bcd9e1b2234c6cd6b2b2ec&quot;, 
                &quot;width&quot;: 640
              }, 
              {
                &quot;height&quot;: 300, 
                &quot;url&quot;: &quot;https://i.scdn.co/image/ab67616d00001e0232bcd9e1b2234c6cd6b2b2ec&quot;, 
                &quot;width&quot;: 300
              }, 
              {
                &quot;height&quot;: 64, 
                &quot;url&quot;: &quot;https://i.scdn.co/image/ab67616d0000485132bcd9e1b2234c6cd6b2b2ec&quot;, 
                &quot;width&quot;: 64
              }
            ], 
            &quot;name&quot;: &quot;There's Nothing in the Rain&quot;, 
            &quot;release_date&quot;: &quot;2021-11-25&quot;, 
            &quot;release_date_precision&quot;: &quot;day&quot;, 
            &quot;total_tracks&quot;: 1, 
            &quot;type&quot;: &quot;album&quot;, 
            &quot;uri&quot;: &quot;spotify:album:4o2d8uBTyMfJeaJqSXn9tP&quot;
          }, 
          &quot;artists&quot;: [
            {
              &quot;external_urls&quot;: {
                &quot;spotify&quot;: &quot;https://open.spotify.com/artist/6MlPT0WxdWnrYcpXT8GZF8&quot;
              }, 
              &quot;href&quot;: &quot;https://api.spotify.com/v1/artists/6MlPT0WxdWnrYcpXT8GZF8&quot;, 
              &quot;id&quot;: &quot;6MlPT0WxdWnrYcpXT8GZF8&quot;, 
              &quot;name&quot;: &quot;PARKFORD&quot;, 
              &quot;type&quot;: &quot;artist&quot;, 
              &quot;uri&quot;: &quot;spotify:artist:6MlPT0WxdWnrYcpXT8GZF8&quot;
  
  </code></pre>
  <p>here is the code I have written out</p>
  <pre><code> uri = MY_LIKED_SONGS
      headers = {
          &quot;Authorization&quot;: f'Bearer {tokens[&quot;access_token&quot;]}',
          &quot;Content-Type&quot;: &quot;application/json&quot;,
      }
      r = requests.get(uri, headers=headers)
      response = r.json()
      # return response
      artist_ids = {}
  
      data = json.dumps(response)
      for artist_ids in data[&quot;items&quot;][&quot;track&quot;]:
          logger.info(artist_ids[&quot;items&quot;][&quot;track&quot;][&quot;artists&quot;][&quot;id&quot;])
          print(artist_ids[&quot;_source&quot;][&quot;items&quot;][0][&quot;track&quot;][&quot;id&quot;])
  
      tracks = response[&quot;items&quot;][&quot;track&quot;][0][&quot;artists&quot;][&quot;id&quot;] 
  </code></pre>