title: Asynchronous JSON Requests in Python
body: <p>I'm using an API for doing HTTP requests that return JSON. The calling of the api, however, depends on a start and an end page to be indicated, such as this:</p>
  
  <pre><code>def API_request(URL):
      while(True):
          try:
              Response = requests.get(URL)
              Data = Response.json()
              return(Data['data'])
          except Exception as APIError:
              print(APIError)
              continue
          break
  def build_orglist(start_page, end_page):
      APILink = ("http://sc-api.com/?api_source=live&amp;system=organizations&amp;action="
                 "all_organizations&amp;source=rsi&amp;start_page={0}&amp;end_page={1}&amp;items_"
                 "per_page=500&amp;sort_method=&amp;sort_direction=ascending&amp;expedite=1&amp;f"
                 "ormat=json".format(start_page, end_page))
      return(API_request(APILink))
  </code></pre>
  
  <p>The only way to know if you're not longer at an existing page is when the JSON will be null, like <a href="http://sc-api.com/?api_source=live&amp;start_date=&amp;end_date=&amp;system=organizations&amp;action=all_organizations&amp;source=rsi&amp;target_id=&amp;start_page=99999&amp;end_page=99999&amp;items_per_page=255&amp;sort_method=&amp;sort_direction=ascending&amp;expedite=1&amp;location=redirect&amp;format=json" rel="nofollow">this</a>.</p>
  
  <p>If I wanted to do multiple <code>build_orglist</code> going over every single page asynchronously until I reach the end (Null JSON) how could I do so?</p>