---
title: "Requests and pagination"
description: "Pages, raw requests, rate limits and URLs."
canonical_url: "https://forges.link/reference/requests"
---
# Requests and pagination

> Pages, raw requests, rate limits and URLs.

See [Page through results](https://forges.link/guides/pagination) for a walkthrough.

## Pagination

### `Page`

One page of a listing: its `items`, and the `cursor` to pass back for the next page. The cursor is absent on the
last page.

**type parameters:** `T`

| Member | Type | Description |
| --- | --- | --- |
| `items` | `T[]` |  |
| `total?` | `number` | The forge's reported total for the whole listing, when it reports one. Absent when the forge reports no total, so an absent value is unknown and not zero. |
| `rateLimit?` | [`RateLimit`](https://forges.link/reference/requests#ratelimit) | From the response headers of the request behind this page. |
| `cursor?` | [`Cursor`](https://forges.link/reference/requests#cursor) | Absent when the listing is exhausted. |
| `etag?` | `string` | Validator of the first page, where the forge supports conditional requests. Pass it back as `cursor: { etag }` to read the first page again. Absent on later pages, and on listings that read more than one endpoint. |
| `notModified?` | `boolean` | True when the forge reported no change since `cursor.etag`. The page then has no items and no `cursor`. |
| `throttled?` | `boolean` | True when the provider sent no request, because the forge asked to wait longer between reads of this feed. The page has no items and a `feed_throttled` warning; read it again later, or pass `force: true`. |
| `nextPollAt?` | `Date` | The earliest time the forge allows the first page to be read again, as GitHub sets with `X-Poll-Interval`. Until then, a read of the first page returns a `throttled` page unless it passes `force: true`. |
| `warnings?` | [`ForgeWarning[]`](https://forges.link/reference/requests#forgewarning) | The non-fatal problems that came up while reading the page. |

### `BaseOptions`

Options accepted by every operation that sends requests; the other options types extend it.

| Member | Type | Description |
| --- | --- | --- |
| `signal?` | `AbortSignal` | Aborts the operation's requests, and the operation rejects with the signal's reason. Writes the forge has already received are not undone. |

### `PageOptions`

Options for listings that take no filters: releases, installations, labels.

**extends:** [`BaseOptions`](https://forges.link/reference/requests#baseoptions)

| Member | Type | Description |
| --- | --- | --- |
| `perPage?` | `number` | How many items to ask for. The forge may return fewer. |
| `cursor?` | [`Cursor`](https://forges.link/reference/requests#cursor) | Resume after the page that returned this cursor. |
| `signal?` | `AbortSignal` | Aborts the operation's requests, and the operation rejects with the signal's reason. Writes the forge has already received are not undone. Inherited from [`BaseOptions`](https://forges.link/reference/requests#baseoptions). |

### `ListOptions`

Options for listings that can start from a point in time: events, comments, reactions.

**extends:** [`PageOptions`](https://forges.link/reference/requests#pageoptions)

| Member | Type | Description |
| --- | --- | --- |
| `since?` | `Date` | Only items updated at or after this time. |
| `perPage?` | `number` | How many items to ask for. The forge may return fewer. Inherited from [`PageOptions`](https://forges.link/reference/requests#pageoptions). |
| `cursor?` | [`Cursor`](https://forges.link/reference/requests#cursor) | Resume after the page that returned this cursor. Inherited from [`PageOptions`](https://forges.link/reference/requests#pageoptions). |
| `signal?` | `AbortSignal` | Aborts the operation's requests, and the operation rejects with the signal's reason. Writes the forge has already received are not undone. Inherited from [`BaseOptions`](https://forges.link/reference/requests#baseoptions). |

### `Cursor`

Opaque-ish resumption token. Fields are optional because forges differ in
what they support; callers should persist the whole object and hand it back.

| Member | Type | Description |
| --- | --- | --- |
| `nextUrl?` | `string` | Absolute URL of the next page, from a `Link` header or the body, on the requested origin. |
| `etag?` | `string` | The `etag` of a first page, sent as `If-None-Match` when the cursor has neither `nextUrl` nor `token`. |
| `token?` | `string` | Opaque forge-native cursor, for example a GraphQL `endCursor`. |

### `ForgeListing`

A listing: iterate it to read every item, or call `page()` to read one page.

**Example**

```ts
const first = await provider.threads.comments(ref, { perPage: 20 }).page()
const next = first.cursor && await provider.threads.comments(ref, { perPage: 20, cursor: first.cursor }).page()
```

**type parameters:** `T`

**extends:** `ForgeIterable<T>`

| Member | Type | Description |
| --- | --- | --- |
| `page()` | `() => Promise<Page<T>>` | Reads one page: the first, or the one after the `cursor` the listing was called with. |
| `warnings` | [`ForgeWarning[]`](https://forges.link/reference/requests#forgewarning) | The non-fatal warnings collected so far. Read it during or after iteration. Inherited from `ForgeIterable`. |

### `ForgeIterable`

An async iterable that also collects non-fatal warnings as it runs. Read
`warnings` during or after iteration.

**type parameters:** `T`

**extends:** `AsyncIterable<T>`

| Member | Type | Description |
| --- | --- | --- |
| `warnings` | [`ForgeWarning[]`](https://forges.link/reference/requests#forgewarning) | The non-fatal warnings collected so far. Read it during or after iteration. |

### `ForgeWarning`

A non-fatal problem encountered while producing a result.

| Member | Type | Description |
| --- | --- | --- |
| `code` | [`ForgeWarningCode`](https://forges.link/reference/requests#forgewarningcode) | Stable machine-readable code. |
| `message` | `string` | A description of the problem, for a person. |
| `subject?` | `string` | Key or URI of the item the warning concerns, when it concerns one. |

### `ForgeWarningCode`

The warning codes providers emit; providers may add codes in a minor release.

**one of:**

- `'account_not_found'`
- `'account_unreadable'`
- `'checks_unreadable'`
- `'collaborators_unreachable'`
- `'commits_truncated'`
- `'discussion_unresolved'`
- `'feed_throttled'`
- `'files_approximate'`
- `'filter_unsupported'`
- `'index_possibly_stale'`
- `'insufficient_scope'`
- `'kind_unsupported'`
- `'notifications_failed'`
- `'record_unreachable'`
- `'recursive_unsupported'`
- `'search_failed'`
- `'search_incomplete'`
- `'sort_unsupported'`
- `'state_record_unreachable'`
- `'thread_unreadable'`
- `'thread_unresolved'`
- `'tree_truncated'`
- `(string & {})`

### `RateLimit`

Request budget the forge reported on the response, where it reports one.

| Member | Type | Description |
| --- | --- | --- |
| `limit?` | `number` | The size of the request budget. |
| `remaining?` | `number` | The number of requests left in the budget. |
| `resetAt?` | `Date` | When `remaining` resets. |
| `resource?` | `string` | The name of the budget, where the forge has several and names them, such as GitHub's `core`, `search` or `graphql`, or GitLab's `throttle_authenticated_api`. |

## Raw requests

### `ForgeRequest`

`provider.request()`: sends a request with the provider's credentials, for endpoints that the model does not cover.

### `ForgeRequestOptions`

Options for `provider.request()`.

**extends:** [`BaseOptions`](https://forges.link/reference/requests#baseoptions)

| Member | Type | Description |
| --- | --- | --- |
| `query?` | [`RequestOptions['query']`](https://forges.link/contributing/provider-kit#requestoptions) | Query parameters. Parameters that are `undefined` are left out. |
| `body?` | `unknown` | Native fetch bodies and strings are sent as-is; other values are sent as JSON. |
| `headers?` | `Record<string, string>` | Headers to send. They add to the provider's default headers. |
| `mutates?` | `boolean` | Caller-declared mutation. Defaults to `false` for GET/HEAD/OPTIONS, otherwise `true`. |
| `signal?` | `AbortSignal` | Aborts the operation's requests, and the operation rejects with the signal's reason. Writes the forge has already received are not undone. Inherited from [`BaseOptions`](https://forges.link/reference/requests#baseoptions). |

### `ForgeRawRequestOptions`

`request()` with `raw`, for endpoints that respond with bytes rather than JSON.

**extends:** [`ForgeRequestOptions`](https://forges.link/reference/requests#forgerequestoptions)

| Member | Type | Description |
| --- | --- | --- |
| `raw` | `true` |  |
| `query?` | [`RequestOptions['query']`](https://forges.link/contributing/provider-kit#requestoptions) | Query parameters. Parameters that are `undefined` are left out. Inherited from [`ForgeRequestOptions`](https://forges.link/reference/requests#forgerequestoptions). |
| `body?` | `unknown` | Native fetch bodies and strings are sent as-is; other values are sent as JSON. Inherited from [`ForgeRequestOptions`](https://forges.link/reference/requests#forgerequestoptions). |
| `headers?` | `Record<string, string>` | Headers to send. They add to the provider's default headers. Inherited from [`ForgeRequestOptions`](https://forges.link/reference/requests#forgerequestoptions). |
| `mutates?` | `boolean` | Caller-declared mutation. Defaults to `false` for GET/HEAD/OPTIONS, otherwise `true`. Inherited from [`ForgeRequestOptions`](https://forges.link/reference/requests#forgerequestoptions). |
| `signal?` | `AbortSignal` | Aborts the operation's requests, and the operation rejects with the signal's reason. Writes the forge has already received are not undone. Inherited from [`BaseOptions`](https://forges.link/reference/requests#baseoptions). |

### `ForgeResponse`

The result of `provider.request()`.

**type parameters:** `T`

| Member | Type | Description |
| --- | --- | --- |
| `status` | `number` |  |
| `data` | `T` | The parsed JSON body, or the text of a body that is not JSON. |
| `headers` | `Headers` |  |
| `rateLimit?` | [`RateLimit`](https://forges.link/reference/requests#ratelimit) | The rate limit that the response headers report, when there is one. |

### `RawResponse`

A response whose body is read as it arrives rather than parsed.

| Member | Type | Description |
| --- | --- | --- |
| `status` | `number` |  |
| `headers` | `Headers` |  |
| `body` | `ReadableStream<Uint8Array>` | The body, read as it arrives. |

### `FetchLike`

The subset of `fetch` that forges needs, so a test or a runtime without a global `fetch` can supply its own.

**type:** `(input: string, init?: RequestInit) => Promise<Response>`

These exports are documented elsewhere: [`EventFeedOptions`](https://forges.link/reference/data-model#eventfeedoptions), [`RepoSection`](https://forges.link/reference/providers#reposection), [`UrlTarget`](https://forges.link/reference/providers#urltarget), [`ParsedForgeUrl`](https://forges.link/reference/providers#parsedforgeurl), [`ReferenceOptions`](https://forges.link/reference/providers#referenceoptions), [`ParseReferencesOptions`](https://forges.link/reference/providers#parsereferencesoptions), [`ParsedReference`](https://forges.link/reference/providers#parsedreference).


## Sitemap

See the full [sitemap](https://forges.link/sitemap.md) for all pages.
