# Branches of a repository the connected access reaches.

> The repository's branches, its default branch first, then by name in plain ASCII order; `search` matches part of a name, ignoring ASCII case.
> https://koi.dog/docs/api/github/list-git-hub-branches/

`GET /api/v1/github/repos/{owner}/{repo}/branches` · Scope: `read`

Paged. Through the App, only a repository the installation on its owner's account reaches (else `404 not_found`), with a token of that installation that can read that one repository's contents and nothing else. With the legacy token only the workspace's owner, signed in, may read it: never an API key or a limited CLI sign-in, whatever its scopes (`403 not_allowed`). `409 github_access_required`, `503 github_unavailable`, `429 rate_limited` as for the accounts.

## Path parameters.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `owner` | `string` | yes | The account or organization that owns the repository, as GitHub names it. |
| `repo` | `string` | yes | The repository's name, without its owner. |

## Query parameters.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `limit` | `1–200` | no | Page size. Default `50`. |
| `order` | `enum` | no | Sort by creation time, then ID. `desc` newest, `asc` oldest. One of `asc`, `desc`. Default `asc`. |
| `cursor` | `string` | no | Previous page’s `nextCursor`. Keep filters and order. At least 1 character. |
| `search` | `string` | no | 1 to 100 characters. |

## Response.

200 OK · `data`: `object[]`. Pass `nextCursor` as `cursor` when `hasMore` is true.

## Request.

```sh
curl "https://api.koi.dog/api/v1/github/repos/$OWNER/$REPO/branches" \
    -H "Authorization: Bearer $KOIDOG_API_KEY"
```

```js
const res = await fetch(`https://api.koi.dog/api/v1/github/repos/${process.env.OWNER}/${process.env.REPO}/branches`, {
  headers: {
    Authorization: `Bearer ${process.env.KOIDOG_API_KEY}`,
  },
});
console.log(await res.json());
```

```python
import os

import requests

r = requests.get(
    f"https://api.koi.dog/api/v1/github/repos/{os.environ['OWNER']}/{os.environ['REPO']}/branches",
    headers={
        "Authorization": f"Bearer {os.environ['KOIDOG_API_KEY']}",
    },
)
r.raise_for_status()
print(r.json())
```

## Response example.

```json
{
  "data": [],
  "nextCursor": "string",
  "hasMore": false
}
```
