# GitHub Repository Tree

Returns the git tree of a repository at a ref: every entry with its path, mode, type and object sha. Set recursive to walk the whole tree in one request. Without a ref the repository default branch is used. GitHub caps how much of a tree it will return, and a recursive walk of a monorepo can exceed it: when that happens the response sets truncated=true and incomplete_results=true, and upstream_truncated=true when the cut-off came from GitHub rather than from our own response cap. Only the latter is ours to raise the cap for; an upstream truncation has no substitute on this route — narrow the range by asking for a specific path under the tree instead.

- **Documentation:** [https://scrappa.co/docs/github-api/github_repository_tree](https://scrappa.co/docs/github-api/github_repository_tree)
- **API group:** GitHub API
- **Endpoint:** `GET https://scrappa.co/api/github/repository/tree`

## Authentication

Send your Scrappa API key in the `X-API-KEY` request header. Paid endpoints also support accountless x402 payments when called without an API key.

## Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `owner` | string | Yes | Repository owner login or organization, e.g. laravel. |
| `repo` | string | Yes | Repository name without the owner, e.g. framework. |
| `ref` | string | No | Branch, tag or commit sha. Defaults to the repository default branch where GitHub allows it. |
| `recursive` | boolean | No | Walk the entire tree instead of one level. |

## Example request

```bash
#!/bin/bash

curl -X GET \
    -H "x-api-key: YOUR_API_KEY_HERE" \
    "https://scrappa.co/api/github/repository/tree?owner=laravel&repo=framework&recursive=1"
```

## Example response

```json
{
    "search_parameters": {
        "engine": "github_repository_tree",
        "owner": "laravel",
        "repo": "framework",
        "recursive": true
    },
    "tree": [
        {
            "path": "README.md",
            "mode": "100644",
            "type": "blob",
            "sha": "abc123"
        }
    ],
    "result_count": 1,
    "truncated": true,
    "upstream_truncated": true
}
```

## Errors

| Status | Error | Description |
| --- | --- | --- |
| 422 | Validation Error | A parameter failed validation. |
| 404 | Not Found | GitHub has no public resource at that address. For a repository this also covers a private or renamed repository, which is indistinguishable anonymously. |
| 503 | GitHub Upstream Unavailable | The upstream service is temporarily unavailable. Please retry shortly. |
| 500 | Parser Drift | GitHub returned a response shape this parser does not recognise. The incident has been reported; retrying will return the same result. |
| 406 | Not Acceptable Upstream | GitHub has no JSON representation for this route, or rejected the request headers. Never charged. |

## More Scrappa resources

- [API documentation](https://scrappa.co/docs)
- [Full LLM-readable API reference](https://scrappa.co/llms-full.txt)
- [OpenAPI specification](https://scrappa.co/docs/api.json)
- [Pricing](https://scrappa.co/pricing)
