I want to get all the repos from github using octokit.
So I use throttling
and paginateRest
and restEndpointMethods
plugins.
But no matter what is my search query it's return 1020 results max.
How I can get the all results?
const searchQuery = "stars:>1+language:JavaScript";
import { Octokit } from "@octokit/core";
import { throttling } from "@octokit/plugin-throttling";
import { paginateRest } from "@octokit/plugin-paginate-rest";
import { restEndpointMethods } from "@octokit/plugin-rest-endpoint-methods";
(async () => {
const MyOctokit = Octokit.plugin(
throttling,
paginateRest,
restEndpointMethods
);
const octokit = new MyOctokit({
auth: '..',
headers: {
Accept: "application/vnd.github.preview",
},
throttle: {
onRateLimit: (retryAfter, options, octokit) => {
octokit.log.warn(
`Request quota exhausted for request ${options.method} ${options.url}`
);
if (options.request.retryCount === 0) {
// only retries once
octokit.log.info(`Retrying after ${retryAfter} seconds!`);
return true;
}
},
onAbuseLimit: (retryAfter, options, octokit) => {
// does not retry, only logs a warning
octokit.log.warn(
`Abuse detected for request ${options.method} ${options.url}`
);
},
},
});
const results = await octokit.paginate(octokit.rest.search.repos, {
q: searchQuery,
});
console.log({ len: results.length }); // --> output 1020. should be much more.
})();
I'm not sure how you're getting 1020, but the docs state that "the GitHub Search API provides up to 1,000 results for each search."
This appears to be a hard limit set by Github.