title: Get top 100 artists by genre Spotify API
body: <p>I'm doing a university project on Data Analysis, in particular, I'm trying to analyze the behavior of listeners on Spotify before and during the pandemic.</p>
  <p>So far I downloaded the top 200 weekly and grouped it by states with a simple script, you can finde the data here: <a href="https://spotifycharts.com/regional" rel="nofollow noreferrer">https://spotifycharts.com/regional</a></p>
  <p>I also managed to use those top 200 to retrieve each song and extract features, release date ecc... using the Spotify API.</p>
  <p>I read this article: <a href="https://blog.chartmetric.com/covid-19-effect-on-the-global-music-business-part-1-genre/" rel="nofollow noreferrer">Spotify genre trends during pandemic</a> which is pretty interesting. I would like to emulate what they're doing in the article. For example, they're able to retrieve the top 100 artist by genre.</p>
  <p>I've been looking around the Spotify API and Spotify available datasets, but I can't find a solution to achieve my goal.</p>
  <p><strong>Is there a way to retrieve the top 100 artist by genre in a given period?</strong></p>
  <p>This is the code I used to download the top 200 weekly, but it's no use for my goal:</p>
  <pre><code>import requests
  import os
  import time
  path = os.getcwd()
  states = ['br','it','gb','de','us','fr','es']
  
  for state in states:
      dir_path = os.path.join(path, state)
      os.mkdir(dir_path)
      for week in weeks:
          csv_url = 'https://spotifycharts.com/regional/'+state+'/weekly/'+week+'/download'
          req = requests.get(csv_url)
          #print(req.status_code)
          time.sleep(0.5)
          if req.status_code == 200:
              url_content = req.content
              csv = ''+state+'_'+week+'.csv'
              csv_path = os.path.join(dir_path, csv)
              csv_file = open(csv_path, 'wb')
  
              csv_file.write(url_content)
              csv_file.close()
          else:
              print('error with the following file:'+str(csv_url))
  </code></pre>
  <p>Where <code>weeks</code> is a list of strings containing the filename of the file to be downloaded in the request (previously generated with another code, omitting it for sake of clarity), for example:</p>
  <pre><code>2016-12-23--2016-12-30
  2016-12-30--2017-01-06
  2017-01-06--2017-01-13
  2017-01-13--2017-01-20
  2017-01-20--2017-01-27
  2017-01-27--2017-02-03
  2017-02-03--2017-02-10
  2017-02-10--2017-02-17
  </code></pre>