code: def check_status(response):
      '''check the status of the response and if needed raise an APIException'''
      status = response.status_code
      if status < 300:
          return
      exception = {
          400: exceptions.BadQuery,
          401: exceptions.InvalidAPIKey,
          403: exceptions.NoPermission,
          404: exceptions.MissingResource,
          429: exceptions.TooManyRequests,
          500: exceptions.ServerError
      }.get(status, None)
  
      # differentiate between over quota and rate-limiting
      if status == 429 and 'quota' in response.text.lower():
          exception = exceptions.OverQuota
  
      if exception:
          raise exception(response.text)
  
      raise exceptions.APIException('%s: %s' % (status, response.text)f check_status(response):
      '''check the status of the response and if needed raise an APIException'''
      status = response.status_code
      if status < 300:
          return
      exception = {
          400: exceptions.BadQuery,
          401: exceptions.InvalidAPIKey,
          403: exceptions.NoPermission,
          404: exceptions.MissingResource,
          429: exceptions.TooManyRequests,
          500: exceptions.ServerError
      }.get(status, None)
  
      # differentiate between over quota and rate-limiting
      if status == 429 and 'quota' in response.text.lower():
          exception = exceptions.OverQuota
  
      if exception:
          raise exception(response.text)
  
      raise exceptions.APIException('%s: %s' % (status, response.text))
docs: check the status of the response and if needed raise an APIException