John
John

Reputation: 17

Exceeding Google Sheets API with GSpread

def printit():
  threading.Timer(10.0, printit).start()
  newIDS = wks.acell('A2').value
  inProgIDS = wks.acell('B2').value
  completedIDS = wks.acell('C2').value
  
  
  ticketData = {
            "newIDS" : newIDS,
            "inProgIDS" : inProgIDS,
            "completedIDS" : completedIDS,
  }
  
  with open('ids.json', 'w') as url_file:
    json.dump(ticketData, url_file)

 
printit()

I am pinging the Google Api with GSpread every 10 seconds to get some values from a 3 cells. It saids I have exceeded my quota, but when I go to the quota page it states the usage is 17%.

gspread.exceptions.APIError: {'code': 429, 'message': "Quota exceeded for quota metric 'Read requests' and limit 'Read requests per minute per user' of service 'sheets.googleapis.com' for consumer 'project_number:206671335281'.", 'status': 'RESOURCE_EXHAUSTED', 'details': [{'@type': 'type.googleapis.com/google.rpc.ErrorInfo', 'reason': 'RATE_LIMIT_EXCEEDED', 'domain': 'googleapis.com', 'metadata': {'quota_limit': 'ReadRequestsPerMinutePerUser', 'quota_metric': 'sheets.googleapis.com/read_requests', 'service': 'sheets.googleapis.com', 'consumer': 'projects/20}}]}

Upvotes: 0

Views: 554

Answers (1)

David Salomon
David Salomon

Reputation: 849

It's probable you're exceeding your quota. Make sure you're not over 60 requests per minute.

The workaround is to implement exponential backoff.

Take more time to make the requests or double check if the file you're reading has other data that require more requests

Upvotes: 0

Related Questions