jcabi-github
jcabi-github copied to clipboard
Pagination and Rate limit
Hi,
How can I control how many results I get at the same time? My call is
String twoDaysAgo = ZonedDateTime.now().minusDays(2).format( DateTimeFormatter.ISO_INSTANT );
enumMap.put(Issues.Qualifier.SINCE, now);
Iterable<Issue> issuesIterator = repo.issues().search(Issues.Sort.UPDATED, Search.Order.DESC, enumMap );
issuesIterator.iterator().forEachRemaining(i -> System.out.println(i.label()));
And then I'm getting the error:
{"message":"API rate limit exceeded for 122.XXX.XXX.XXX. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)","documentation_url":"https://developer.github.com/v3/#rate-limiting"}>
at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
at com.jcabi.http.response.RestResponse.assertStatus(RestResponse.java:111)
at com.jcabi.github.RtValuePagination$Items.fetch(RtValuePagination.java:193)
at com.jcabi.github.RtValuePagination$Items.hasNext(RtValuePagination.java:179)
at java.util.Iterator.forEachRemaining(Iterator.java:115)
- How can I specify the page size to be 100 ? (max authorised)
- How can I throttle my iteratable to respect the rate limiting? This should be done under the hood ideally?
@yegor256 please, pay attention to this issue
@simplesteph you may use LimitedIterable
from Cactoos:
new LimitedIterable<>(issues, 100).iterator().forEachRemaining(
i -> System.out.println(i.label())
);