Skip to main content
// Download a full repository archive from the default branch
const archiveResp = await repo.getArchiveStream();
const archiveBytes = new Uint8Array(await archiveResp.arrayBuffer());
console.log(archiveBytes.length);

// Download from a specific branch, tag, or commit with filters
const filteredArchiveResp = await repo.getArchiveStream({
  ref: "main",
  includeGlobs: ["README.md", "src/**"],
  excludeGlobs: ["vendor/**"],
  maxBlobSize: 1024 * 1024, // 1 MiB
  archivePrefix: "repo/",
});
const filteredBytes = new Uint8Array(await filteredArchiveResp.arrayBuffer());
console.log(filteredBytes.length);

Options

ref
string
Branch name, tag, or commit SHA. Defaults to the default branch.
includeGlobs
string
Glob patterns for files to include in the archive.
excludeGlobs
string
Glob patterns for files to exclude from the archive.
maxBlobSize
number
Maximum blob size in bytes. When provided, files larger than this limit are excluded from the archive.
archivePrefix
string
Prefix to add to each entry in the tar archive (e.g., repo/).

Returns

Returns a streaming response containing a tar.gz archive.
  • TypeScript: Standard Fetch Response.
  • Python: Async response object with .aread() for bytes.
  • Go: *http.Response (remember to close Body).