# The files a pull request changes, in reading order, with their diffs.

> Reads GitHub now.
> https://koi.dog/docs/api/pull-requests/list-pull-request-files/

`GET /api/v1/pull-requests/{id}/files` · Scope: `read`

Each changed file with its unified diff (cut at 64 KB; null for a binary or very large file) and whether the founder marked it reviewed. `sort=reading` (the default) is the guided read: shared contracts and types first (schemas, protocol, `.d.ts`, API and route definitions, migrations), then the code that implements them, then its tests, then docs, then configuration and lock files, and generated files last; inside a group, files of the same directory stay together and larger changes come first. `group` and `why` say where each file landed. A mark holds while the file's diff stays the same: a push that changes the file clears it, a push that leaves it alone keeps it. `409 github_not_configured` without GitHub access.

## Path parameters.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | yes | The pull request's id. |

## Query parameters.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `sort` | `enum` | no | `reading` lists the files in the guided reading order (contracts, code, tests, docs, configuration, generated files); `path` lists them by path. One of `reading`, `path`. Default `reading`. |
| `limit` | `1–200` | no | Page size. Default `50`. |
| `cursor` | `string` | no | Previous page’s `nextCursor`. Keep filters and order. At least 1 character. |
| `order` | `enum` | no | Sort by creation time, then ID. `desc` newest, `asc` oldest. One of `asc`, `desc`. Default `asc`. |
| `createdAfter` | `string` | no | From this UTC timestamp, inclusive (e.g. `2027-01-01T00:00:00Z`). Uses run start, node pairing, move request, event or log time, otherwise creation. |
| `createdBefore` | `string` | no | Through this UTC timestamp, inclusive. See `createdAfter`. |

## Response.

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

## Request.

```sh
curl "https://api.koi.dog/api/v1/pull-requests/$ID/files" \
    -H "Authorization: Bearer $KOIDOG_API_KEY"
```

```js
const res = await fetch(`https://api.koi.dog/api/v1/pull-requests/${process.env.ID}/files`, {
  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/pull-requests/{os.environ['ID']}/files",
    headers={
        "Authorization": f"Bearer {os.environ['KOIDOG_API_KEY']}",
    },
)
r.raise_for_status()
print(r.json())
```

## Response example.

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