git-repo-loader is a lightweight library to fetch and stream GitHub repository content efficiently while handling rate limits.
- Fetches entire repository content, including file contents
- Supports streaming large repositories to prevent memory issues
- Respects
.gitignorefiles (optional) - Handles GitHub API rate limits automatically
- Supports multiple output formats:
json,string,buffer
npm install git-repo-loaderor
yarn add git-repo-loaderimport { GitHubRepoLoader } from "git-repo-loader";
const fetcher = new GitHubRepoLoader("your_github_token", {
concurrency: 50,
intervalMs: 3600000, // 1 hour
requestsPerInterval: 5000, // 5000 for authenticated requests, 60 for non-authenticated
});
(async () => {
const content = await fetcher.fetchRepoContent(
"owner",
"repo",
"main",
true, // Decode base64 content
true, // Ignore .gitignore files
"json" // Output format
);
console.log(content);
})();import { GitHubRepoLoader } from "git-repo-loader";
const fetcher = new GitHubRepoLoader("your_github_token", {
concurrency: 50,
intervalMs: 3600000,
requestsPerInterval: 5000,
});
(async () => {
for await (const [chunk] of fetcher.fetchRepoContentStream(
"owner",
"repo",
"main",
false,
true,
"string"
)) {
console.log(chunk);
}
})();Creates a new instance with GitHub authentication.
Fetches the entire repo content and returns it in the specified format.
Returns an async generator to stream repo content.
json: Returns an array of{ path, content }objects.string: Returns a formatted string.buffer: Returns aBuffer.
MIT License © Hitesh Agrawal