title: Im trying to get data from an Api with 100 results limit but im getting an issue when using timestamps to go further
body: <p>I wanted to do a simple script that calculates the number of certain actions in the game .
  The game has an api that is limited to 100 results per request, that is why they have unix timestamps if you want to go further and keep searching in a loop,the issue is that i take all 100 timestamps from the results add them to a list and sort them to take the last one and use it in the next request until there are no more results, but using the code below
  1- The code doesn't exit
  2- After debugging the code the code changes the timestamp only once</p>
  <pre><code>import requests
  import json
  import time
  
  
  c = 0
  link = &quot;https://api.torn.com/user/&quot;
  key = &quot;secret_api_key&quot;
  Monarch_Engineering = {
          &quot;dummmyId&quot;:[0,0,0,0,0],# user id : success, fail, bad, good, number of revs payed
      }
  Monarch = {
          &quot;dummmyId&quot;:[0,0,0,0,0],# user id : success, fail, bad, good, number of revs payed
      }
  non_contract = {
          &quot;dummmyId&quot;:[0,0,0],# user id : success, fail, number of revs payed
      }
  
  def search(frm,tt,ky=key):
      parameter = {
  
          &quot;selections&quot; : &quot;revives&quot;,
          &quot;key&quot;        : ky,
          &quot;from&quot;       : frm,
          &quot;to&quot;         : tt
      }
      timestamp = True
      while True:
          with requests.get(link,params=parameter) as resp:
              respon = json.loads(resp.text)
          # Makes the get request and returns json
          # transforms json str to a dictionary
          if resp.status_code != 200 :
              print(&quot;Request Error : &quot;,resp.status_code, &quot;\nExiting ....&quot;)
          if &quot;error&quot; in respon.keys():
              print(respon['error']['error']+&quot; Error Code : &quot;, respon['error']['code'])
              q = input(&quot;Do you Want to continue Y/N : &quot;).lower()
              if q != &quot;y&quot;:
                  print(&quot;script exiting ......&quot;)
                  return
              # makes sure that it is a successful
              # wait for a user input here to confirm the issue also print the error code
          time.sleep(1)
          # to prevent getting banned 
          timestamp = bool(respon['revives'])
          if timestamp !=True :
              return
          print(parameter)# for debuging
          parameter['from'] = revive(respon)
          
  
  
  
  def revive(respond):
      global c
      global Monarch_Engineering
      global Monarch
      global non_contract
      ff = [] # timestamps list
      if &quot;revives&quot; not in respond.keys():
          print(&quot;error no revs found &quot;)
          return
      for key in respond[&quot;revives&quot;]:
          c+=1
          tkey = respond['revives'][key]
          uid = tkey['target_id']
          ff.append(tkey['timestamp'])
          # if in ME
          if tkey['target_faction'] == 7835 :
              if uid not in Monarch_Engineering:
                  Monarch_Engineering[uid]=[0,0,0,0,0]
              if &quot;hospitalized&quot; in tkey['target_hospital_reason'].lower() and tkey['chance'] &gt;= 50:
                  Monarch_Engineering[uid][3]+=1
                  if tkey['result'].lower() == &quot;success&quot;:
                      Monarch_Engineering[uid][0]+=1
                  else:
                      Monarch_Engineering[uid][1]+=1
              else:
                  Monarch_Engineering[uid][2]+=1
  
  
          elif tkey['target_faction'] == 8336 :
              if uid not in Monarch:
                  Monarch[uid]=[0,0,0,0,0]
              if &quot;hospitalized&quot; in tkey['target_hospital_reason'].lower() and tkey['chance'] &gt;= 40:
                  Monarch[uid][3]+=1
                  if tkey['result'].lower() == &quot;success&quot;:
                      Monarch[uid][0]+=1
                  else:
                      Monarch[uid][1]+=1
              else:
                  Monarch[uid][2]+=1
          
          
          else:
              if uid not in non_contract:
                  non_contract[uid]=[0,0,0]
              if tkey['result'].lower() == &quot;success&quot;:
                  non_contract[uid][0]+=1
              else:
                  non_contract[uid][1]+=1
      ff.sort()
      return ff[-1]
  
  
  search(1635163200, 1635768000)
  
  for i in Monarch_Engineering:
      print(&quot;user id :&quot;, i)
      print(&quot;The number of Success :&quot;, Monarch_Engineering[i][0])
      print(&quot;The number of Failed  :&quot;, Monarch_Engineering[i][1])
      print(&quot;The number of Bad     :&quot;, Monarch_Engineering[i][2])
      print(&quot;The number of Good    :&quot;, Monarch_Engineering[i][3])
  print(&quot;\nthe number of revs searched/done = &quot;,c)
      
      
  </code></pre>