title: how to handle error Request was throttled in python
body: <pre><code>call = 0
  start_time = datetime.now()
  file1 = open(&quot;data.txt&quot;,&quot;r&quot;)
  for line in file1.readlines():
      if (datetime.now() - start_time).total_seconds() &gt; 1 or call &gt;= 90:
          # time.sleep(60 - (datetime.now() - start_time).total_seconds() + 60)
          time.sleep(10)
          start_time = datetime.now()
      line = line.strip()
      all_data = f&quot;api/{line}&quot;
      headers = {
      'accept': 'application/json',
      'X-CSRFToken': 'csrftoken',
      'Authorization': 'AuthToken'
      }
      try:
          r = requests.get(all_data, headers=headers)
          trading = r.json()
      except Exception as e:
          print(f'error with {line}')
      end_time = datetime.now()
      if trading:
          with open('/folder/'+line+'.json', 'w') as file_object:
              json.dump(trading, file_object)
          print(&quot;done with&quot;,line)
      call += 1
  </code></pre>
  <p>we need save api response on json file.</p>
  <p>I have handle api call in time limit but it gives still Request was throttled error. I have 11000 something endpoint data. <strong>Rate Limit</strong> is In additional to the limits associated with your pricing plan, there is a throttle of 100 calls per second and 1,000 calls per minute. Exceeding this rate limit will result in reponse errors until the limit resets.</p>
  <p>json file error response :</p>
  <pre><code>{
      &quot;detail&quot;: &quot;Request was throttled. Expected available in 1319 seconds.&quot;
  }
  </code></pre>