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?
The issue is threefold:
Thus, I have my applications wait rand(1,5)
seconds and if they are rate limited again, I wait 3600
seconds before retrying.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With