> ## Documentation Index
> Fetch the complete documentation index at: https://code.storage/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# getArchiveStream()

> Download a repository archive as a streaming tar.gz response.

<CodeGroup>
  ```typescript TypeScript theme={null} theme={"theme":{"light":"github-light","dark":"min-dark"}}
  // 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);
  ```

  ```python Python theme={null} theme={"theme":{"light":"github-light","dark":"min-dark"}}
  # Download a full repository archive from the default branch
  archive_response = await repo.get_archive_stream()
  archive_bytes = await archive_response.aread()
  print(len(archive_bytes))

  # Download from a specific branch, tag, or commit with filters
  filtered_archive_response = await repo.get_archive_stream(
      ref="main",
      include_globs=["README.md", "src/**"],
      exclude_globs=["vendor/**"],
      max_blob_size=1024 * 1024,  # 1 MiB
      archive_prefix="repo/",
  )
  filtered_archive_bytes = await filtered_archive_response.aread()
  print(len(filtered_archive_bytes))
  ```

  ```go Go theme={null} theme={"theme":{"light":"github-light","dark":"min-dark"}}
  // Download a filtered archive
  resp, err := repo.ArchiveStream(context.Background(), storage.ArchiveOptions{
  	Ref:           "main",
  	IncludeGlobs:  []string{"README.md", "src/**"},
  	ExcludeGlobs:  []string{"vendor/**"},
  	MaxBlobSize:   1024 * 1024, // 1 MiB
  	ArchivePrefix: "repo/",
  })
  defer resp.Body.Close()
  archiveBytes, err := io.ReadAll(resp.Body)
  fmt.Println(len(archiveBytes))
  ```
</CodeGroup>

## Options

<ParamField path="ref" type="string">
  Branch name, tag, or commit SHA. Defaults to the default branch.
</ParamField>

<ParamField path="includeGlobs" type="string">
  Glob patterns for files to include in the archive.
</ParamField>

<ParamField path="excludeGlobs" type="string">
  Glob patterns for files to exclude from the archive.
</ParamField>

<ParamField path="maxBlobSize" type="number">
  Maximum blob size in bytes. When provided, files larger than this limit are excluded from the
  archive.
</ParamField>

<ParamField path="archivePrefix" type="string">
  Prefix to add to each entry in the tar archive (e.g., `repo/`).
</ParamField>

## 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`).
