java - Does Google+ API have any hourly rate limit? -
i know there quotas there: https://code.google.com/apis/console these daily quotas. , there see 10,000 queries per day (courtesy limit). program makes 170-190 requests per hour after receives such response google+ api:
{ "code" : 403, "errors" : [ { "domain" : "usagelimits", "message" : "rate limit exceeded", "reason" : "ratelimitexceeded" } ], "message" : "rate limit exceeded" } after 1 hour program 170-190 again till same error. 190 requests per hour * 24 hours far 10,000.
i using method people.search , google-api-java-client library version 1.15.0-rc. initialize plus service 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 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 change sleep time 1 sec or 2 sec - same behaviour. tried regenerate key file - no luck.
did incorrect?
the issue threefold:
- the rate limit both per day (10,000) , per second (5).
- the error message shared between types.
- the time until next window not provided.
thus, have applications wait rand(1,5) seconds , if rate limited again, wait 3600 seconds before retrying.
Comments
Post a Comment