Does Google+ API have any hourly rate limit?
api, google-plus, java
Solution
The issue is threefold:
- The rate limit is both per day (10,000) and per second (5).
- The error message is shared between the types.
- The time until the next window is not provided.
Thus, I have my applications wait `rand(1,5)` seconds and if they are rate limited again, I wait `3600` seconds before retrying.
Problem
I know there are quotas there: https://code.google.com/apis/console But these are daily quotas. And there I see 10,000 queries per day (Courtesy Limit). Actually my program makes 170-190 requests per hour after that receives such response from Google+ API: ``` { "code" : 403, "errors" : [ { "domain" : "usageLimits", "message" : "Rate Limit Exceeded", "reason" : "rateLimitExceeded" } ], "message" : "Rate Limit Exceeded" } ``` After 1 hour program does 170-190 again till get same error. But 190 requests per hour * 24 hours is far from 10,000. I am using method people.search and google-api-java-client library version 1.15.0-rc. Initialize Plus service like below: ``` HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport(); JsonFactory jsonFactory = new JacksonFactory(); GoogleCredential credential = new GoogleCredential.Builder().setTransport(httpTransport) .setJsonFactory(jsonFactory) .setServiceAccountId(EMAIL) .setServiceAccountScopes(Collections.singleton(PlusScopes.PLUS_LOGIN)) .setServiceAccountPrivateKeyFromP12File(KEY_FILE)) .build(); Plus plus = new Plus.Builder(httpTransport, jsonFactory, credential) .setApplicationName(APP_NAME).build(); ``` And use search method like this: ``` Plus.People.Search searchPeople = people.search(fullname); searchPeople.setMaxResults(50L); searchPeople.setFields("items(id),nextPageToken"); PeopleFeed peopleFeed = searchPeople.execute(); while (true) { if (peopleFeed.getItems().size() == 0) { break; } /* Save people info here */ if (peopleFeed.getNextPageToken() == null) { break; } try { Thread.sleep(500); } catch (InterruptedException e) { } searchPeople.setPageToken(peopleFeed.getNextPageToken()); peopleFeed = searchPeople.execute(); } ``` I tried to change sleep time to 1 sec or 2 sec - same behaviour. Tried to regenerate key file - no luck. Did I do something incorrect?