---
title: "Providers"
description: "Create providers and combine them in a registry."
canonical_url: "https://forges.link/reference/providers"
---
# Providers

> Create providers and combine them in a registry.

Each forge has a factory such as `github()`, which creates a provider. Pass providers to `createForges()` to combine them.

## Options and authentication

### `ForgeOptionsBase`

Options that every provider accepts.

| Member | Type | Default | Description |
| --- | --- | --- | --- |
| `baseUrl?` | `string` |  | API base URL. Defaults to the forge's public instance. |
| `instance?` | `string` |  | Host used in refs and keys. Defaults to the host of `baseUrl`, with API subdomains mapped to the public host. |
| `fetch?` | [`FetchLike`](https://forges.link/reference/requests#fetchlike) |  | A `fetch` to use instead of the global one, for tests and for runtimes without one. |
| `timeout?` | `number` | `30000` | Request timeout in milliseconds. |
| `webhookSecret?` | `string` |  | Shared secret used to verify inbound webhook deliveries. |
| `userAgent?` | `string` |  | The `user-agent` header. Defaults to `forges`, except in a browser, which sends its own. Setting it in a browser can trigger a CORS preflight that some forges reject. |
| `instanceVersion?` | `string` |  | Version of the forge instance, when the caller already knows it. Gates version-dependent capabilities without the network call `refreshCapabilities()` makes. |
| `readOnly?` | `boolean` |  | Every write, including a mutating `request()`, rejects with `ReadOnlyError` and reports `false`. |
| `onRetry?` | [`FetcherOptions['onRetry']`](https://forges.link/contributing/provider-kit#fetcheroptions) |  | Called before a request is retried after a rate limit that names a wait of at most a minute, with the wait in milliseconds. |
| `onRateLimit?` | [`FetcherOptions['onRateLimit']`](https://forges.link/contributing/provider-kit#fetcheroptions) |  | Called with the rate limit of every API response that reports one, so that you can follow the budget without reading `page.rateLimit`. `rateLimit.resource` names the budget where the forge has several. |

### `TokenAuth`

A bearer or personal access token.

| Member | Type | Description |
| --- | --- | --- |
| `type` | `'token'` |  |
| `token` | `string \| (() => string \| Promise<string>)` | Personal access token or OAuth access token. A function is called before every request, so a refreshed token applies without a new provider. |

### `BasicAuth`

HTTP Basic credentials, for example a Bitbucket app password or Atlassian API token.

| Member | Type | Description |
| --- | --- | --- |
| `type` | `'basic'` |  |
| `username` | `string` |  |
| `password` | `string` | The password, app password or API token. |

### `AppAuth`

App credentials. Omit `installationId` to act as the app itself.

| Member | Type | Description |
| --- | --- | --- |
| `type` | `'app'` |  |
| `appId` | `string \| number` |  |
| `privateKey` | `string` | PEM private key: RSA (PKCS#1 or PKCS#8) on GitHub, Ed25519 PKCS#8 on Cursor Origin. |
| `installationId?` | `string \| number` | The installation to act as. Omit it to act as the app itself. |

### `AnonymousAuth`

No credentials: public reads only. Every write, notifications and subscriptions are unsupported.

| Member | Type |
| --- | --- |
| `type` | `'anonymous'` |

### `AuthKind`

The credential types that a provider can accept.

**one of:**

- `'token'`
- `'basic'`
- `'app'`
- `'app_password'`
- `'oauth'`
- `'anonymous'`

## GitHub

### `GitHubTokenKind`

What a GitHub token can call:

- `classic`: a personal access token (classic) or an OAuth app token;
- `fine-grained`: a fine-grained personal access token;
- `app-user`: a GitHub App user access token;
- `installation`: a GitHub App installation access token, such as the `GITHUB_TOKEN` of a workflow.

**one of:**

- `'classic'`
- `'fine-grained'`
- `'app-user'`
- `'installation'`

### `GitHubTokenAuth`

A GitHub token.

**extends:** [`TokenAuth`](https://forges.link/reference/providers#tokenauth)

| Member | Type | Description |
| --- | --- | --- |
| `kind?` | [`GitHubTokenKind`](https://forges.link/reference/providers#githubtokenkind) | What kind of token `token` is. Read from the prefix of a string `token` when omitted. |
| `type` | `'token'` | Inherited from [`TokenAuth`](https://forges.link/reference/providers#tokenauth). |
| `token` | `string \| (() => string \| Promise<string>)` | Personal access token or OAuth access token. A function is called before every request, so a refreshed token applies without a new provider. Inherited from [`TokenAuth`](https://forges.link/reference/providers#tokenauth). |

### `GitHubAuth`

The credentials GitHub accepts: a token, a GitHub App, or none for anonymous reads.

**one of:**

- [`GitHubTokenAuth`](https://forges.link/reference/providers#githubtokenauth)
- [`AppAuth`](https://forges.link/reference/providers#appauth)
- [`AnonymousAuth`](https://forges.link/reference/providers#anonymousauth)

### `GitHubOptions`

Options for `github()`.

**extends:** [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase)

| Member | Type | Default | Description |
| --- | --- | --- | --- |
| `auth?` | [`GitHubAuth`](https://forges.link/reference/providers#githubauth) | `{ type: 'anonymous' }` | How to authenticate. Without credentials, only public reads work. |
| `baseUrl?` | `string` |  | API base URL. Defaults to the forge's public instance. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `instance?` | `string` |  | Host used in refs and keys. Defaults to the host of `baseUrl`, with API subdomains mapped to the public host. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `fetch?` | [`FetchLike`](https://forges.link/reference/requests#fetchlike) |  | A `fetch` to use instead of the global one, for tests and for runtimes without one. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `timeout?` | `number` | `30000` | Request timeout in milliseconds. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `webhookSecret?` | `string` |  | Shared secret used to verify inbound webhook deliveries. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `userAgent?` | `string` |  | The `user-agent` header. Defaults to `forges`, except in a browser, which sends its own. Setting it in a browser can trigger a CORS preflight that some forges reject. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `instanceVersion?` | `string` |  | Version of the forge instance, when the caller already knows it. Gates version-dependent capabilities without the network call `refreshCapabilities()` makes. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `readOnly?` | `boolean` |  | Every write, including a mutating `request()`, rejects with `ReadOnlyError` and reports `false`. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `onRetry?` | [`FetcherOptions['onRetry']`](https://forges.link/contributing/provider-kit#fetcheroptions) |  | Called before a request is retried after a rate limit that names a wait of at most a minute, with the wait in milliseconds. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `onRateLimit?` | [`FetcherOptions['onRateLimit']`](https://forges.link/contributing/provider-kit#fetcheroptions) |  | Called with the rate limit of every API response that reports one, so that you can follow the budget without reading `page.rateLimit`. `rateLimit.resource` names the budget where the forge has several. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |

### `TypedGraphQLDocument`

A GraphQL document that carries the types of its result and variables, such as a `TypedDocumentString`
from GraphQL Code Generator with `documentMode: 'string'`.

**type parameters:** `TResult, TVariables`

| Member | Type | Description |
| --- | --- | --- |
| `valueOf()` | `() => string` | The text of the document. |
| `__apiType()?` | `(variables: TVariables) => TResult` | Carries the types; it has no value at runtime. |

### `GitHubGraphQL`

`provider.graphql()`: the result type comes from a [`TypedGraphQLDocument`](https://forges.link/reference/providers#typedgraphqldocument), or from the type argument of a plain string.

### `GitHubProvider`

A provider that `github()` creates: every [`ForgeProvider`](https://forges.link/reference/provider) member, and GitHub's GraphQL API.

**extends:** [`ForgeProvider<true>`](https://forges.link/reference/provider)

| Member | Type | Description |
| --- | --- | --- |
| `graphql` | [`GitHubGraphQL`](https://forges.link/reference/providers#githubgraphql) | Runs a GraphQL query or mutation against the provider's GitHub API and returns its `data`. A read-only provider runs queries and rejects mutations with `ReadOnlyError`. Variables are required when the document is typed and declares a required variable. |
| `request` | [`ForgeRequest`](https://forges.link/reference/requests#forgerequest) | Requests endpoints relative to `baseUrl` or absolute HTTP(S) URLs. Other origins omit default headers and provider credentials; explicit headers apply. Inherited from [`ForgeProvider`](https://forges.link/reference/provider). |
| `forge` | [`ForgeKind`](https://forges.link/reference/data-model#forgekind) | The forge this provider sends requests to; matches `forge` on every ref it returns. Inherited from [`ForgeProvider`](https://forges.link/reference/provider). |
| `instance` | [`ForgeInstance`](https://forges.link/reference/data-model#forgeinstance) | Inherited from [`ForgeProvider`](https://forges.link/reference/provider). |
| `baseUrl` | `string` | Inherited from [`ForgeProvider`](https://forges.link/reference/provider). |
| `authKind` | [`AuthKind`](https://forges.link/reference/providers#authkind) | The `auth.type` the provider was created with; `'anonymous'` when it sends no credentials. Inherited from [`ForgeProvider`](https://forges.link/reference/provider). |
| `capabilities` | [`ForgeCapabilities`](https://forges.link/reference/provider#forgecapabilities) | Static, no-network capabilities until `refreshCapabilities()` resolves. Inherited from [`ForgeProvider`](https://forges.link/reference/provider). |
| `refreshCapabilities()` | [`() => Promise<ForgeCapabilities>`](https://forges.link/reference/provider#forgecapabilities) | Re-derives capabilities from the instance version. The version is read once per provider (GHES `/meta`, GitLab, Forgejo and Gitea `/version`). Updates `capabilities` and returns it. Inherited from [`ForgeProvider`](https://forges.link/reference/provider). |
| `rateLimits()` | [`() => RateLimit[]`](https://forges.link/reference/requests#ratelimit) | The request budgets of the latest responses, one per `resource`, read without sending a request. GitHub keeps a budget per resource, such as `core`, `search` and `graphql`; other forges report one budget with no `resource`. Empty until a response reports a budget. A budget whose `resetAt` has passed is left out. Inherited from [`ForgeProvider`](https://forges.link/reference/provider). |
| `normaliseMarkdown()` | `(body: string) => string` | Rewrites Markdown into the dialect the forge renders; returns it unchanged where the forge renders CommonMark. Inherited from [`ForgeProvider`](https://forges.link/reference/provider). |
| `repos` | [`ReposApi`](https://forges.link/reference/repositories#providerrepos) | Inherited from [`ForgeProvider`](https://forges.link/reference/provider). |
| `notifications` | [`NotificationsApi`](https://forges.link/reference/notifications#providernotifications) | Inherited from [`ForgeProvider`](https://forges.link/reference/provider). |
| `sources` | [`SourcesApi`](https://forges.link/reference/notifications#providersources) | Inherited from [`ForgeProvider`](https://forges.link/reference/provider). |
| `threads` | [`ThreadsApi`](https://forges.link/reference/threads#providerthreads) | Inherited from [`ForgeProvider`](https://forges.link/reference/provider). |
| `webhooks` | [`WebhooksApi`](https://forges.link/reference/notifications#providerwebhooks) | Inherited from [`ForgeProvider`](https://forges.link/reference/provider). |
| `installations` | [`InstallationsApi`](https://forges.link/reference/repositories#providerinstallations) | Inherited from [`ForgeProvider`](https://forges.link/reference/provider). |
| `releases` | [`ReleasesApi`](https://forges.link/reference/repositories#providerreleases) | Inherited from [`ForgeProvider`](https://forges.link/reference/provider). |
| `contents` | [`ContentsApi`](https://forges.link/reference/repositories#providercontents) | Inherited from [`ForgeProvider`](https://forges.link/reference/provider). |
| `commits` | [`CommitsApi`](https://forges.link/reference/repositories#providercommits) | Inherited from [`ForgeProvider`](https://forges.link/reference/provider). |
| `checks` | [`ChecksApi`](https://forges.link/reference/notifications#providerchecks) | Inherited from [`ForgeProvider`](https://forges.link/reference/provider). |
| `ci` | [`CiApi`](https://forges.link/reference/notifications#providerci) | Inherited from [`ForgeProvider`](https://forges.link/reference/provider). |
| `users` | [`UsersApi`](https://forges.link/reference/repositories#providerusers) | Inherited from [`ForgeProvider`](https://forges.link/reference/provider). |
| `search` | [`SearchApi`](https://forges.link/reference/repositories#providersearch) | Inherited from [`ForgeProvider`](https://forges.link/reference/provider). |
| `securityAlerts` | [`SecurityAlertsApi`](https://forges.link/reference/notifications#providersecurityalerts) | Inherited from [`ForgeProvider`](https://forges.link/reference/provider). |
| `orgs` | [`OrgsApi`](https://forges.link/reference/repositories#providerorgs) | Inherited from [`ForgeProvider`](https://forges.link/reference/provider). |
| `can()` | `(verb: ForgeVerb, kind?: ThreadKind \| SecurityAlertKind) => boolean` | Whether `verb` is supported, for `kind` where support differs by kind, including version gates. Every verb is always present and rejects with `UnsupportedOperationError` when this is `false`: the capability is the question, the method is the action. Inherited from [`ForgeProvider`](https://forges.link/reference/provider). |
| `support()` | `(verb: ForgeVerb, kind?: ThreadKind \| SecurityAlertKind) => Support` | How well `verb` is supported: `true`, `'emulated'`, `'not_applicable'` or `false`, for `kind` where support differs by kind. `can()` is `true` for every level but `false` and `'not_applicable'`. Without `kind`, a per-kind verb reports its strongest level across kinds. Inherited from [`ForgeProvider`](https://forges.link/reference/provider). |
| `urlFor()` | [`(target: { repo: RepoRef, section?: undefined }) => HasWeb extends true ? string : string \| undefined`](https://forges.link/reference/data-model#reporef) | The web page for `target`, built without a request; `undefined` when the forge has no such page. A file target's `at` defaults to the repository's default branch. Inherited from [`ForgeProvider`](https://forges.link/reference/provider). |
| `webOrigin` | `HasWeb extends true ? string : string \| undefined` | The canonical origin of the forge's website for this instance, such as `https://github.com` (without any deployment path), or `undefined` when the forge has no website. Useful for resolving root-relative links and for building a content security policy. Inherited from [`ForgeProvider`](https://forges.link/reference/provider). |
| `scopesFor()` | `(verb: ForgeVerb) => VerbScopes` | Token scopes or app permissions `verb` needs on this forge, as data for a consent screen or a 403 explanation. Nothing in the library reads it, and an unmapped verb returns `{}`. Inherited from [`ForgeProvider`](https://forges.link/reference/provider). |
| `parseUrl()` | [`(url: string \| URL) => ParsedForgeUrl \| undefined`](https://forges.link/reference/providers#parsedforgeurl) | Reads a web URL, clone URL or npm `repository` value (`git+https://`, `github:owner/name`) on this provider's instance into refs; `undefined` for anything else. Inherited from [`ForgeProvider`](https://forges.link/reference/provider). |
| `referenceFor()` | `(ref: ThreadRef \| CommitRef, options?: ReferenceOptions) => string \| undefined` | How to mention `ref` in Markdown on this forge (`#42`, `!42`, `acme/widgets#42`, `acme/widgets@abc1234`), short when written in `from`; the page URL where the forge has no reference syntax. Inherited from [`ForgeProvider`](https://forges.link/reference/provider). |
| `parseReferences()` | `(text: string, options: ParseReferencesOptions) => ParsedReference[]` | The references to threads and commits in `text`, as `referenceFor()` writes them and people type them (`#42`, `!42`, `GH-42`, `acme/widgets#42`, `acme/widgets@abc1234` or a bare sha), with their offsets, in order. `#42` reads as an issue where issues and pull requests share numbers; `threads.get()` returns the thread with its kind. A bare sha has 7 to 40 hex characters, with a letter and a digit. Text inside a URL is skipped, but code spans are not, so leave them out of `text`. Empty when `from` is on another instance, or the forge has no reference syntax. Inherited from [`ForgeProvider`](https://forges.link/reference/provider). |

### `github()`

Creates a GitHub provider for github.com or a GitHub Enterprise Server instance.

```ts
function github(options?: GitHubOptions): GitHubProvider & { readonly forge: "github"; }
```

| Parameter | Type |
| --- | --- |
| `options?` | [`GitHubOptions`](https://forges.link/reference/providers#githuboptions) |

**Returns:** [`GitHubProvider & { readonly forge: "github"; }`](https://forges.link/reference/providers#githubprovider)

## GitLab

### `GitLabAuth`

Personal, project, group or OAuth access token.

**one of:**

- [`TokenAuth`](https://forges.link/reference/providers#tokenauth)
- [`AnonymousAuth`](https://forges.link/reference/providers#anonymousauth)

### `GitLabOptions`

Options for `gitlab()`.

**extends:** [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase)

| Member | Type | Default | Description |
| --- | --- | --- | --- |
| `auth?` | [`GitLabAuth`](https://forges.link/reference/providers#gitlabauth) | `{ type: 'anonymous' }` | How to authenticate. Without credentials, only public reads work. |
| `baseUrl?` | `string` |  | Instance root, for example `https://gitlab.com`. |
| `instance?` | `string` |  | Host used in refs and keys. Defaults to the host of `baseUrl`, with API subdomains mapped to the public host. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `fetch?` | [`FetchLike`](https://forges.link/reference/requests#fetchlike) |  | A `fetch` to use instead of the global one, for tests and for runtimes without one. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `timeout?` | `number` | `30000` | Request timeout in milliseconds. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `webhookSecret?` | `string` |  | Shared secret used to verify inbound webhook deliveries. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `userAgent?` | `string` |  | The `user-agent` header. Defaults to `forges`, except in a browser, which sends its own. Setting it in a browser can trigger a CORS preflight that some forges reject. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `instanceVersion?` | `string` |  | Version of the forge instance, when the caller already knows it. Gates version-dependent capabilities without the network call `refreshCapabilities()` makes. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `readOnly?` | `boolean` |  | Every write, including a mutating `request()`, rejects with `ReadOnlyError` and reports `false`. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `onRetry?` | [`FetcherOptions['onRetry']`](https://forges.link/contributing/provider-kit#fetcheroptions) |  | Called before a request is retried after a rate limit that names a wait of at most a minute, with the wait in milliseconds. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `onRateLimit?` | [`FetcherOptions['onRateLimit']`](https://forges.link/contributing/provider-kit#fetcheroptions) |  | Called with the rate limit of every API response that reports one, so that you can follow the budget without reading `page.rateLimit`. `rateLimit.resource` names the budget where the forge has several. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |

### `gitlab()`

Creates a GitLab provider for gitlab.com or a self-managed instance.

```ts
function gitlab(options?: GitLabOptions): ForgeProvider<true> & { readonly forge: "gitlab"; }
```

| Parameter | Type |
| --- | --- |
| `options?` | [`GitLabOptions`](https://forges.link/reference/providers#gitlaboptions) |

**Returns:** [`ForgeProvider<true> & { readonly forge: "gitlab"; }`](https://forges.link/reference/provider)

## Bitbucket

### `BitbucketAuth`

Bitbucket Cloud credentials.

- `token`: an OAuth access token or a repository, project or workspace
access token, sent as a bearer token.
- `basic`: an Atlassian account email and API token.

**one of:**

- [`TokenAuth`](https://forges.link/reference/providers#tokenauth)
- [`BasicAuth`](https://forges.link/reference/providers#basicauth)
- [`AnonymousAuth`](https://forges.link/reference/providers#anonymousauth)

### `BitbucketOptions`

Options for `bitbucket()`.

**extends:** [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase)

| Member | Type | Default | Description |
| --- | --- | --- | --- |
| `auth?` | [`BitbucketAuth`](https://forges.link/reference/providers#bitbucketauth) | `{ type: 'anonymous' }` | How to authenticate. Without credentials, only public reads work. |
| `baseUrl?` | `string` | `https://api.bitbucket.org/2.0` | API base. |
| `instance?` | `string` |  | Host used in refs and keys. Defaults to the host of `baseUrl`, with API subdomains mapped to the public host. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `fetch?` | [`FetchLike`](https://forges.link/reference/requests#fetchlike) |  | A `fetch` to use instead of the global one, for tests and for runtimes without one. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `timeout?` | `number` | `30000` | Request timeout in milliseconds. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `webhookSecret?` | `string` |  | Shared secret used to verify inbound webhook deliveries. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `userAgent?` | `string` |  | The `user-agent` header. Defaults to `forges`, except in a browser, which sends its own. Setting it in a browser can trigger a CORS preflight that some forges reject. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `instanceVersion?` | `string` |  | Version of the forge instance, when the caller already knows it. Gates version-dependent capabilities without the network call `refreshCapabilities()` makes. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `readOnly?` | `boolean` |  | Every write, including a mutating `request()`, rejects with `ReadOnlyError` and reports `false`. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `onRetry?` | [`FetcherOptions['onRetry']`](https://forges.link/contributing/provider-kit#fetcheroptions) |  | Called before a request is retried after a rate limit that names a wait of at most a minute, with the wait in milliseconds. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `onRateLimit?` | [`FetcherOptions['onRateLimit']`](https://forges.link/contributing/provider-kit#fetcheroptions) |  | Called with the rate limit of every API response that reports one, so that you can follow the budget without reading `page.rateLimit`. `rateLimit.resource` names the budget where the forge has several. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |

### `bitbucket()`

Creates a Bitbucket Cloud provider.

```ts
function bitbucket(options?: BitbucketOptions): ForgeProvider<true> & { readonly forge: "bitbucket"; }
```

| Parameter | Type |
| --- | --- |
| `options?` | [`BitbucketOptions`](https://forges.link/reference/providers#bitbucketoptions) |

**Returns:** [`ForgeProvider<true> & { readonly forge: "bitbucket"; }`](https://forges.link/reference/provider)

## Forgejo

### `ForgejoAuth`

Forgejo and Gitea have no app-installation credential, so only tokens are accepted.

**one of:**

- [`TokenAuth`](https://forges.link/reference/providers#tokenauth)
- [`AnonymousAuth`](https://forges.link/reference/providers#anonymousauth)

### `ForgejoOptions`

Options for `forgejo()`.

**extends:** [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase)

| Member | Type | Default | Description |
| --- | --- | --- | --- |
| `auth?` | [`ForgejoAuth`](https://forges.link/reference/providers#forgejoauth) | `{ type: 'anonymous' }` | How to authenticate. Without credentials, only public reads work. |
| `baseUrl?` | `string` |  | Instance root, for example `https://codeberg.org`. |
| `instance?` | `string` |  | Host used in refs and keys. Defaults to the host of `baseUrl`, with API subdomains mapped to the public host. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `fetch?` | [`FetchLike`](https://forges.link/reference/requests#fetchlike) |  | A `fetch` to use instead of the global one, for tests and for runtimes without one. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `timeout?` | `number` | `30000` | Request timeout in milliseconds. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `webhookSecret?` | `string` |  | Shared secret used to verify inbound webhook deliveries. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `userAgent?` | `string` |  | The `user-agent` header. Defaults to `forges`, except in a browser, which sends its own. Setting it in a browser can trigger a CORS preflight that some forges reject. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `instanceVersion?` | `string` |  | Version of the forge instance, when the caller already knows it. Gates version-dependent capabilities without the network call `refreshCapabilities()` makes. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `readOnly?` | `boolean` |  | Every write, including a mutating `request()`, rejects with `ReadOnlyError` and reports `false`. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `onRetry?` | [`FetcherOptions['onRetry']`](https://forges.link/contributing/provider-kit#fetcheroptions) |  | Called before a request is retried after a rate limit that names a wait of at most a minute, with the wait in milliseconds. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `onRateLimit?` | [`FetcherOptions['onRateLimit']`](https://forges.link/contributing/provider-kit#fetcheroptions) |  | Called with the rate limit of every API response that reports one, so that you can follow the budget without reading `page.rateLimit`. `rateLimit.resource` names the budget where the forge has several. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |

### `forgejo()`

Creates a Forgejo provider for Codeberg or any self-hosted Forgejo instance.

```ts
function forgejo(options?: ForgejoOptions): ForgeProvider<true> & { readonly forge: "forgejo"; }
```

| Parameter | Type |
| --- | --- |
| `options?` | [`ForgejoOptions`](https://forges.link/reference/providers#forgejooptions) |

**Returns:** [`ForgeProvider<true> & { readonly forge: "forgejo"; }`](https://forges.link/reference/provider)

## Gitea

### `GiteaOptions`

Options for `gitea()`, the same as for `forgejo()`.

**type:** [`ForgejoOptions`](https://forges.link/reference/providers#forgejooptions)

### `gitea()`

Creates a Gitea provider for gitea.com or any self-hosted Gitea instance.

```ts
function gitea(options?: ForgejoOptions): ForgeProvider<true> & { readonly forge: "gitea"; }
```

| Parameter | Type |
| --- | --- |
| `options?` | [`ForgejoOptions`](https://forges.link/reference/providers#forgejooptions) |

**Returns:** [`ForgeProvider<true> & { readonly forge: "gitea"; }`](https://forges.link/reference/provider)

## Gitee

### `GiteeAuth`

A personal access token or OAuth access token, sent as `Authorization: token`.

**one of:**

- [`TokenAuth`](https://forges.link/reference/providers#tokenauth)
- [`AnonymousAuth`](https://forges.link/reference/providers#anonymousauth)

### `GiteeOptions`

Options for `gitee()`.

**extends:** [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase)

| Member | Type | Default | Description |
| --- | --- | --- | --- |
| `auth?` | [`GiteeAuth`](https://forges.link/reference/providers#giteeauth) | `{ type: 'anonymous' }` | How to authenticate. Without credentials, only public reads work. |
| `baseUrl?` | `string` | `https://gitee.com` | Instance root. `/api/v5` is appended. |
| `instance?` | `string` |  | Host used in refs and keys. Defaults to the host of `baseUrl`, with API subdomains mapped to the public host. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `fetch?` | [`FetchLike`](https://forges.link/reference/requests#fetchlike) |  | A `fetch` to use instead of the global one, for tests and for runtimes without one. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `timeout?` | `number` | `30000` | Request timeout in milliseconds. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `webhookSecret?` | `string` |  | Shared secret used to verify inbound webhook deliveries. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `userAgent?` | `string` |  | The `user-agent` header. Defaults to `forges`, except in a browser, which sends its own. Setting it in a browser can trigger a CORS preflight that some forges reject. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `instanceVersion?` | `string` |  | Version of the forge instance, when the caller already knows it. Gates version-dependent capabilities without the network call `refreshCapabilities()` makes. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `readOnly?` | `boolean` |  | Every write, including a mutating `request()`, rejects with `ReadOnlyError` and reports `false`. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `onRetry?` | [`FetcherOptions['onRetry']`](https://forges.link/contributing/provider-kit#fetcheroptions) |  | Called before a request is retried after a rate limit that names a wait of at most a minute, with the wait in milliseconds. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `onRateLimit?` | [`FetcherOptions['onRateLimit']`](https://forges.link/contributing/provider-kit#fetcheroptions) |  | Called with the rate limit of every API response that reports one, so that you can follow the budget without reading `page.rateLimit`. `rateLimit.resource` names the budget where the forge has several. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |

### `gitee()`

Creates a Gitee provider for gitee.com. The enterprise edition (`e.gitee.com`) is not covered.

```ts
function gitee(options?: GiteeOptions): ForgeProvider<true> & { readonly forge: "gitee"; }
```

| Parameter | Type |
| --- | --- |
| `options?` | [`GiteeOptions`](https://forges.link/reference/providers#giteeoptions) |

**Returns:** [`ForgeProvider<true> & { readonly forge: "gitee"; }`](https://forges.link/reference/provider)

## Azure DevOps

### `AZURE_DEVOPS_API_VERSION`

The REST API version sent with every request; preview endpoints set their own.

**type:** `"7.1"`

### `AzureDevOpsAuth`

A personal access token (sent as basic auth with an empty user name), or explicit basic credentials.

**one of:**

- [`TokenAuth`](https://forges.link/reference/providers#tokenauth)
- [`BasicAuth`](https://forges.link/reference/providers#basicauth)
- [`AnonymousAuth`](https://forges.link/reference/providers#anonymousauth)

### `AzureDevOpsOptions`

Options for `azureDevOps()`.

**extends:** [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase)

| Member | Type | Default | Description |
| --- | --- | --- | --- |
| `auth?` | [`AzureDevOpsAuth`](https://forges.link/reference/providers#azuredevopsauth) | `{ type: 'anonymous' }` | How to authenticate. Without credentials, only public reads work. |
| `organization` | `string` |  | The organization (or Azure DevOps Server collection) that `repos.list()` lists. |
| `baseUrl?` | `string` | `https://dev.azure.com` | For Azure DevOps Server, the server root, for example `https://tfs.example.com/tfs`. |
| `issueType?` | `string` | `Issue` | Work item type `threads.create({ kind: 'issue' })` creates, read back as `thread.issueType`. Scrum projects use `Impediment` or `Product Backlog Item`. |
| `webhookSecret?` | `string` |  | `username:password` the service hook subscription sends as basic auth. |
| `instance?` | `string` |  | Host used in refs and keys. Defaults to the host of `baseUrl`, with API subdomains mapped to the public host. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `fetch?` | [`FetchLike`](https://forges.link/reference/requests#fetchlike) |  | A `fetch` to use instead of the global one, for tests and for runtimes without one. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `timeout?` | `number` | `30000` | Request timeout in milliseconds. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `userAgent?` | `string` |  | The `user-agent` header. Defaults to `forges`, except in a browser, which sends its own. Setting it in a browser can trigger a CORS preflight that some forges reject. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `instanceVersion?` | `string` |  | Version of the forge instance, when the caller already knows it. Gates version-dependent capabilities without the network call `refreshCapabilities()` makes. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `readOnly?` | `boolean` |  | Every write, including a mutating `request()`, rejects with `ReadOnlyError` and reports `false`. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `onRetry?` | [`FetcherOptions['onRetry']`](https://forges.link/contributing/provider-kit#fetcheroptions) |  | Called before a request is retried after a rate limit that names a wait of at most a minute, with the wait in milliseconds. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `onRateLimit?` | [`FetcherOptions['onRateLimit']`](https://forges.link/contributing/provider-kit#fetcheroptions) |  | Called with the rate limit of every API response that reports one, so that you can follow the budget without reading `page.rateLimit`. `rateLimit.resource` names the budget where the forge has several. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |

### `azureDevOps()`

Creates an Azure DevOps provider for one organization on dev.azure.com, or a collection on Azure DevOps Server.

```ts
function azureDevOps(options: AzureDevOpsOptions): ForgeProvider<true> & { readonly forge: "azure-devops"; }
```

| Parameter | Type |
| --- | --- |
| `options` | [`AzureDevOpsOptions`](https://forges.link/reference/providers#azuredevopsoptions) |

**Returns:** [`ForgeProvider<true> & { readonly forge: "azure-devops"; }`](https://forges.link/reference/provider)

## Cursor Origin

### `CursorOriginAuth`

A user access token (what the Origin CLI sends, for example
`CURSOR_AUTH_TOKEN`), or an Origin App: its id and Ed25519 PKCS#8 private
key, optionally scoped to one installation. Personal Cursor API keys are
not Origin bearer tokens.

**one of:**

- [`TokenAuth`](https://forges.link/reference/providers#tokenauth)
- [`AppAuth`](https://forges.link/reference/providers#appauth)

### `ORIGIN_API_VERSION`

The Origin API version this provider was built against. See `docs/content/4.providers/cursor-origin.md`.

**type:** `"v1alpha1"`

### `CursorOriginOptions`

Options for `cursorOrigin()`.

**extends:** [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase)

| Member | Type | Default | Description |
| --- | --- | --- | --- |
| `auth?` | `CursorOriginAuth \| AnonymousAuth` |  | Token or app credentials. Cursor Origin's API has no anonymous access, so without `auth` the provider only verifies and translates webhook deliveries. |
| `baseUrl?` | `string` | `https://api.cursor.com` | API root. `/v1/origin` is appended. |
| `instance?` | `string` |  | Host used in refs and keys. Defaults to the host of `baseUrl`, with API subdomains mapped to the public host. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `fetch?` | [`FetchLike`](https://forges.link/reference/requests#fetchlike) |  | A `fetch` to use instead of the global one, for tests and for runtimes without one. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `timeout?` | `number` | `30000` | Request timeout in milliseconds. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `webhookSecret?` | `string` |  | Shared secret used to verify inbound webhook deliveries. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `userAgent?` | `string` |  | The `user-agent` header. Defaults to `forges`, except in a browser, which sends its own. Setting it in a browser can trigger a CORS preflight that some forges reject. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `instanceVersion?` | `string` |  | Version of the forge instance, when the caller already knows it. Gates version-dependent capabilities without the network call `refreshCapabilities()` makes. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `readOnly?` | `boolean` |  | Every write, including a mutating `request()`, rejects with `ReadOnlyError` and reports `false`. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `onRetry?` | [`FetcherOptions['onRetry']`](https://forges.link/contributing/provider-kit#fetcheroptions) |  | Called before a request is retried after a rate limit that names a wait of at most a minute, with the wait in milliseconds. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `onRateLimit?` | [`FetcherOptions['onRateLimit']`](https://forges.link/contributing/provider-kit#fetcheroptions) |  | Called with the rate limit of every API response that reports one, so that you can follow the budget without reading `page.rateLimit`. `rateLimit.resource` names the budget where the forge has several. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |

### `cursorOrigin()`

Creates a Cursor Origin provider. Experimental: built against the
`v1alpha1` API, which Cursor publishes as Early Beta.

```ts
function cursorOrigin(options?: CursorOriginOptions): ForgeProvider<boolean> & { readonly forge: "cursor-origin"; }
```

| Parameter | Type |
| --- | --- |
| `options?` | [`CursorOriginOptions`](https://forges.link/reference/providers#cursororiginoptions) |

**Returns:** [`ForgeProvider<boolean> & { readonly forge: "cursor-origin"; }`](https://forges.link/reference/provider)

## Pushin.eu

### `PushinAuth`

A personal access token created in Settings (`pun_pat_…`), sent as `Authorization: Bearer`.

**one of:**

- [`TokenAuth`](https://forges.link/reference/providers#tokenauth)
- [`AnonymousAuth`](https://forges.link/reference/providers#anonymousauth)

### `PushinOptions`

Options for `pushin()`.

**extends:** [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase)

| Member | Type | Default | Description |
| --- | --- | --- | --- |
| `auth?` | [`PushinAuth`](https://forges.link/reference/providers#pushinauth) | `{ type: 'anonymous' }` | How to authenticate. Without credentials, only public reads work. |
| `baseUrl?` | `string` | `https://pushin.eu` | Instance root. `/api/v1` is appended. |
| `instance?` | `string` |  | Host used in refs and keys. Defaults to the host of `baseUrl`, with API subdomains mapped to the public host. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `fetch?` | [`FetchLike`](https://forges.link/reference/requests#fetchlike) |  | A `fetch` to use instead of the global one, for tests and for runtimes without one. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `timeout?` | `number` | `30000` | Request timeout in milliseconds. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `webhookSecret?` | `string` |  | Shared secret used to verify inbound webhook deliveries. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `userAgent?` | `string` |  | The `user-agent` header. Defaults to `forges`, except in a browser, which sends its own. Setting it in a browser can trigger a CORS preflight that some forges reject. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `instanceVersion?` | `string` |  | Version of the forge instance, when the caller already knows it. Gates version-dependent capabilities without the network call `refreshCapabilities()` makes. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `readOnly?` | `boolean` |  | Every write, including a mutating `request()`, rejects with `ReadOnlyError` and reports `false`. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `onRetry?` | [`FetcherOptions['onRetry']`](https://forges.link/contributing/provider-kit#fetcheroptions) |  | Called before a request is retried after a rate limit that names a wait of at most a minute, with the wait in milliseconds. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `onRateLimit?` | [`FetcherOptions['onRateLimit']`](https://forges.link/contributing/provider-kit#fetcheroptions) |  | Called with the rate limit of every API response that reports one, so that you can follow the budget without reading `page.rateLimit`. `rateLimit.resource` names the budget where the forge has several. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |

### `pushin()`

Creates a Pushin.eu provider.

```ts
function pushin(options?: PushinOptions): ForgeProvider<true> & { readonly forge: "pushin"; }
```

| Parameter | Type |
| --- | --- |
| `options?` | [`PushinOptions`](https://forges.link/reference/providers#pushinoptions) |

**Returns:** [`ForgeProvider<true> & { readonly forge: "pushin"; }`](https://forges.link/reference/provider)

## Tangled

### `TangledAuth`

Credentials for writing records. Reads are public and need none.

- `app_password` creates a session on the account's PDS.
- `oauth` takes a `fetch` from an atproto OAuth client that already signs
requests (DPoP) for `pds`.

**one of:**

- [`AnonymousAuth`](https://forges.link/reference/providers#anonymousauth)
- `{ type: 'app_password', identifier: string, password: string, pds?: string }`
- [`{ type: 'oauth', did: string, pds: string, fetch: FetchLike }`](https://forges.link/reference/requests#fetchlike)

### `TangledOptions`

Options for `tangled()`.

**extends:** [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase)

| Member | Type | Default | Description |
| --- | --- | --- | --- |
| `auth?` | [`TangledAuth`](https://forges.link/reference/providers#tangledauth) |  | An app password session, an OAuth client that signs requests, or none for anonymous reads. |
| `baseUrl?` | `string` | `https://tangled.org` | Appview web root, used for links and as the `instance`. |
| `apiUrl?` | `string` |  | Base for `request()`: a Bobbin-compatible XRPC index, whose mirror serves the git reads. Defaults to `https://api.tangled.org`, Tangled's public instance. |
| `plcUrl?` | `string` |  | PLC directory for `did:plc` resolution. Defaults to the public directory, which is community infrastructure. |
| `handleResolverUrl?` | `string` |  | Service for `com.atproto.identity.resolveHandle`, so a `RepoRef.owner` can be a handle. Defaults to `https://public.api.bsky.app`. |
| `jetstreamUrl?` | `string` |  | Jetstream `subscribe` endpoint. |
| `webSocket?` | [`WebSocketFactory`](https://forges.link/reference/providers#websocketfactory) |  | Defaults to the global `WebSocket`. |
| `notificationsUrl?` | `string` |  | Base URL of a service implementing the experimental `org.tangled.temp.notification.*` lexicons (Tangled's deliberi). Its service DID is derived as `did:web:<host>`. Requires `auth`. The lexicons live in Tangled's `temp` namespace and may change or disappear. |
| `sshHosts?` | `Record<string, string>` |  | Maps a knot host to the host that accepts git over SSH for it. `knot1.tangled.sh` maps to `tangled.org` by default. |
| `instance?` | `string` |  | Host used in refs and keys. Defaults to the host of `baseUrl`, with API subdomains mapped to the public host. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `fetch?` | [`FetchLike`](https://forges.link/reference/requests#fetchlike) |  | A `fetch` to use instead of the global one, for tests and for runtimes without one. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `timeout?` | `number` | `30000` | Request timeout in milliseconds. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `webhookSecret?` | `string` |  | Shared secret used to verify inbound webhook deliveries. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `userAgent?` | `string` |  | The `user-agent` header. Defaults to `forges`, except in a browser, which sends its own. Setting it in a browser can trigger a CORS preflight that some forges reject. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `instanceVersion?` | `string` |  | Version of the forge instance, when the caller already knows it. Gates version-dependent capabilities without the network call `refreshCapabilities()` makes. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `readOnly?` | `boolean` |  | Every write, including a mutating `request()`, rejects with `ReadOnlyError` and reports `false`. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `onRetry?` | [`FetcherOptions['onRetry']`](https://forges.link/contributing/provider-kit#fetcheroptions) |  | Called before a request is retried after a rate limit that names a wait of at most a minute, with the wait in milliseconds. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `onRateLimit?` | [`FetcherOptions['onRateLimit']`](https://forges.link/contributing/provider-kit#fetcheroptions) |  | Called with the rate limit of every API response that reports one, so that you can follow the budget without reading `page.rateLimit`. `rateLimit.resource` names the budget where the forge has several. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |

### `tangled()`

Creates a Tangled provider. Records are read from the index; pushes arrive through Jetstream.

```ts
function tangled(options?: TangledOptions): ForgeProvider<true> & { readonly forge: "tangled"; }
```

| Parameter | Type |
| --- | --- |
| `options?` | [`TangledOptions`](https://forges.link/reference/providers#tangledoptions) |

**Returns:** [`ForgeProvider<true> & { readonly forge: "tangled"; }`](https://forges.link/reference/provider)

### `WebSocketLike`

The subset of the WHATWG `WebSocket` the stream uses.

| Member | Type | Description |
| --- | --- | --- |
| `addEventListener()` | `(type: 'open' \| 'message' \| 'error' \| 'close', listener: (event: { data?: unknown, code?: number, reason?: string }) => void) => void` | Registers a listener for a socket event. |
| `close()` | `(code?: number, reason?: string) => void` | Closes the socket, optionally with a close code and reason. |

### `WebSocketFactory`

Opens a WebSocket for a URL, such as `url => new WebSocket(url)`.

**type:** [`(url: string) => WebSocketLike`](https://forges.link/reference/providers#websocketlike)

## Cloudflare Artifacts

### `CloudflareArtifactsAuth`

A Cloudflare API token with **Artifacts** > **Read**, sent as `Authorization: Bearer`.

**type:** [`TokenAuth`](https://forges.link/reference/providers#tokenauth)

### `CloudflareArtifactsOptions`

Options for `cloudflareArtifacts()`.

**extends:** [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase)

| Member | Type | Default | Description |
| --- | --- | --- | --- |
| `auth` | [`CloudflareArtifactsAuth`](https://forges.link/reference/providers#cloudflareartifactsauth) |  | How to authenticate. Artifacts has no anonymous reads. |
| `accountId` | `string` |  | The account that holds the namespaces. Its Git host is the instance of every ref. |
| `baseUrl?` | `string` | `https://api.cloudflare.com` | The Cloudflare API root. `/client/v4` is appended. |
| `instance?` | `string` |  | Host used in refs and keys. Defaults to the host of `baseUrl`, with API subdomains mapped to the public host. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `fetch?` | [`FetchLike`](https://forges.link/reference/requests#fetchlike) |  | A `fetch` to use instead of the global one, for tests and for runtimes without one. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `timeout?` | `number` | `30000` | Request timeout in milliseconds. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `webhookSecret?` | `string` |  | Shared secret used to verify inbound webhook deliveries. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `userAgent?` | `string` |  | The `user-agent` header. Defaults to `forges`, except in a browser, which sends its own. Setting it in a browser can trigger a CORS preflight that some forges reject. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `instanceVersion?` | `string` |  | Version of the forge instance, when the caller already knows it. Gates version-dependent capabilities without the network call `refreshCapabilities()` makes. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `readOnly?` | `boolean` |  | Every write, including a mutating `request()`, rejects with `ReadOnlyError` and reports `false`. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `onRetry?` | [`FetcherOptions['onRetry']`](https://forges.link/contributing/provider-kit#fetcheroptions) |  | Called before a request is retried after a rate limit that names a wait of at most a minute, with the wait in milliseconds. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `onRateLimit?` | [`FetcherOptions['onRateLimit']`](https://forges.link/contributing/provider-kit#fetcheroptions) |  | Called with the rate limit of every API response that reports one, so that you can follow the budget without reading `page.rateLimit`. `rateLimit.resource` names the budget where the forge has several. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |

### `cloudflareArtifacts()`

Creates a Cloudflare Artifacts provider for one account. A ref's instance is the
account's Git host, `<accountId>.artifacts.cloudflare.net`, and its owner a namespace.

```ts
function cloudflareArtifacts(options: CloudflareArtifactsOptions): ForgeProvider<false> & { readonly forge: "cloudflare-artifacts"; }
```

| Parameter | Type |
| --- | --- |
| `options` | [`CloudflareArtifactsOptions`](https://forges.link/reference/providers#cloudflareartifactsoptions) |

**Returns:** [`ForgeProvider<false> & { readonly forge: "cloudflare-artifacts"; }`](https://forges.link/reference/provider)

## Sourcehut

### `SourcehutAuth`

A Sourcehut personal access token or OAuth bearer token, sent as `Authorization: Bearer`.

**type:** [`TokenAuth`](https://forges.link/reference/providers#tokenauth)

### `SourcehutOptions`

Options for `sourcehut()`.

**extends:** [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase)

| Member | Type | Default | Description |
| --- | --- | --- | --- |
| `auth` | [`SourcehutAuth`](https://forges.link/reference/providers#sourcehutauth) |  | How to authenticate. Every Sourcehut service refuses reads without a token. |
| `baseUrl?` | `string` | `https://sr.ht` | Instance root; each service is a subdomain of its host (`sr.ht` gives `meta.sr.ht`, `git.sr.ht`, `todo.sr.ht`, `lists.sr.ht`, `builds.sr.ht`). `request()` takes an absolute URL and sends it to the service it names. |
| `webhookPublicKey?` | `string` |  | Base64 ed25519 public key used to verify inbound webhook deliveries. Defaults to the public key of `sr.ht`; set it for a self-hosted instance. |
| `instance?` | `string` |  | Host used in refs and keys. Defaults to the host of `baseUrl`, with API subdomains mapped to the public host. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `fetch?` | [`FetchLike`](https://forges.link/reference/requests#fetchlike) |  | A `fetch` to use instead of the global one, for tests and for runtimes without one. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `timeout?` | `number` | `30000` | Request timeout in milliseconds. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `webhookSecret?` | `string` |  | Shared secret used to verify inbound webhook deliveries. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `userAgent?` | `string` |  | The `user-agent` header. Defaults to `forges`, except in a browser, which sends its own. Setting it in a browser can trigger a CORS preflight that some forges reject. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `instanceVersion?` | `string` |  | Version of the forge instance, when the caller already knows it. Gates version-dependent capabilities without the network call `refreshCapabilities()` makes. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `readOnly?` | `boolean` |  | Every write, including a mutating `request()`, rejects with `ReadOnlyError` and reports `false`. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `onRetry?` | [`FetcherOptions['onRetry']`](https://forges.link/contributing/provider-kit#fetcheroptions) |  | Called before a request is retried after a rate limit that names a wait of at most a minute, with the wait in milliseconds. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `onRateLimit?` | [`FetcherOptions['onRateLimit']`](https://forges.link/contributing/provider-kit#fetcheroptions) |  | Called with the rate limit of every API response that reports one, so that you can follow the budget without reading `page.rateLimit`. `rateLimit.resource` names the budget where the forge has several. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |

### `sourcehut()`

Creates a Sourcehut provider. Sourcehut cannot write, so `readOnly` is always
set: it reports `subscriptions.set` unsupported, which no write is declared to
do, and it cannot be turned off.

```ts
function sourcehut(options: SourcehutOptions): ForgeProvider<true> & { readonly forge: "sourcehut"; }
```

| Parameter | Type |
| --- | --- |
| `options` | [`SourcehutOptions`](https://forges.link/reference/providers#sourcehutoptions) |

**Returns:** [`ForgeProvider<true> & { readonly forge: "sourcehut"; }`](https://forges.link/reference/provider)

## Entire

### `EntireAuth`

A bearer token for an Entire account, such as the one `entire auth token` prints. Login tokens
expire, so pass `token` as a function to read a fresh one for every request.

**type:** [`TokenAuth`](https://forges.link/reference/providers#tokenauth)

### `EntireOptions`

Options for `entire()`.

**extends:** [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase)

| Member | Type | Default | Description |
| --- | --- | --- | --- |
| `auth` | [`EntireAuth`](https://forges.link/reference/providers#entireauth) |  |  |
| `baseUrl?` | `string` | `https://us.console.entire.io` | Control plane root. `/api/v1` is appended. Requests about a project go to the processing cell that the control plane names for it. |
| `instance?` | `string` |  | Host used in refs and keys. Defaults to the host of `baseUrl`, with API subdomains mapped to the public host. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `fetch?` | [`FetchLike`](https://forges.link/reference/requests#fetchlike) |  | A `fetch` to use instead of the global one, for tests and for runtimes without one. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `timeout?` | `number` | `30000` | Request timeout in milliseconds. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `webhookSecret?` | `string` |  | Shared secret used to verify inbound webhook deliveries. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `userAgent?` | `string` |  | The `user-agent` header. Defaults to `forges`, except in a browser, which sends its own. Setting it in a browser can trigger a CORS preflight that some forges reject. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `instanceVersion?` | `string` |  | Version of the forge instance, when the caller already knows it. Gates version-dependent capabilities without the network call `refreshCapabilities()` makes. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `readOnly?` | `boolean` |  | Every write, including a mutating `request()`, rejects with `ReadOnlyError` and reports `false`. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `onRetry?` | [`FetcherOptions['onRetry']`](https://forges.link/contributing/provider-kit#fetcheroptions) |  | Called before a request is retried after a rate limit that names a wait of at most a minute, with the wait in milliseconds. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `onRateLimit?` | [`FetcherOptions['onRateLimit']`](https://forges.link/contributing/provider-kit#fetcheroptions) |  | Called with the rate limit of every API response that reports one, so that you can follow the budget without reading `page.rateLimit`. `rateLimit.resource` names the budget where the forge has several. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |

### `entire()`

Creates an Entire provider for the repositories Entire hosts, which live under `et/`.

```ts
function entire(options: EntireOptions): ForgeProvider<true> & { readonly forge: "entire"; }
```

| Parameter | Type |
| --- | --- |
| `options` | [`EntireOptions`](https://forges.link/reference/providers#entireoptions) |

**Returns:** [`ForgeProvider<true> & { readonly forge: "entire"; }`](https://forges.link/reference/provider)

## GitBucket

### `GitBucketAuth`

The credentials GitBucket accepts: a personal access token, or none for anonymous reads.

**one of:**

- [`TokenAuth`](https://forges.link/reference/providers#tokenauth)
- [`AnonymousAuth`](https://forges.link/reference/providers#anonymousauth)

### `GitBucketOptions`

Options for `gitbucket()`.

**extends:** [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase)

| Member | Type | Default | Description |
| --- | --- | --- | --- |
| `auth?` | [`GitBucketAuth`](https://forges.link/reference/providers#gitbucketauth) | `{ type: 'anonymous' }` | How to authenticate. Without credentials, only public reads work. |
| `baseUrl` | `string` |  | The root of your GitBucket server, such as `https://gitbucket.example.com`. `/api/v3` is appended. |
| `instance?` | `string` |  | Host used in refs and keys. Defaults to the host of `baseUrl`, with API subdomains mapped to the public host. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `fetch?` | [`FetchLike`](https://forges.link/reference/requests#fetchlike) |  | A `fetch` to use instead of the global one, for tests and for runtimes without one. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `timeout?` | `number` | `30000` | Request timeout in milliseconds. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `webhookSecret?` | `string` |  | Shared secret used to verify inbound webhook deliveries. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `userAgent?` | `string` |  | The `user-agent` header. Defaults to `forges`, except in a browser, which sends its own. Setting it in a browser can trigger a CORS preflight that some forges reject. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `instanceVersion?` | `string` |  | Version of the forge instance, when the caller already knows it. Gates version-dependent capabilities without the network call `refreshCapabilities()` makes. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `readOnly?` | `boolean` |  | Every write, including a mutating `request()`, rejects with `ReadOnlyError` and reports `false`. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `onRetry?` | [`FetcherOptions['onRetry']`](https://forges.link/contributing/provider-kit#fetcheroptions) |  | Called before a request is retried after a rate limit that names a wait of at most a minute, with the wait in milliseconds. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `onRateLimit?` | [`FetcherOptions['onRateLimit']`](https://forges.link/contributing/provider-kit#fetcheroptions) |  | Called with the rate limit of every API response that reports one, so that you can follow the budget without reading `page.rateLimit`. `rateLimit.resource` names the budget where the forge has several. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |

### `gitbucket()`

Creates a GitBucket provider for a self-hosted GitBucket server, through the part of GitHub's REST API that it serves.

```ts
function gitbucket(options: GitBucketOptions): ForgeProvider<true> & { readonly forge: "gitbucket"; }
```

| Parameter | Type |
| --- | --- |
| `options` | [`GitBucketOptions`](https://forges.link/reference/providers#gitbucketoptions) |

**Returns:** [`ForgeProvider<true> & { readonly forge: "gitbucket"; }`](https://forges.link/reference/provider)

## GitCafe

### `GitCafeAuth`

A personal access token created under Settings → Tokens (`gct_…`), sent as `Authorization: Bearer`.

**one of:**

- [`TokenAuth`](https://forges.link/reference/providers#tokenauth)
- [`AnonymousAuth`](https://forges.link/reference/providers#anonymousauth)

### `GitCafeOptions`

Options for `gitcafe()`.

**extends:** [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase)

| Member | Type | Default | Description |
| --- | --- | --- | --- |
| `auth?` | [`GitCafeAuth`](https://forges.link/reference/providers#gitcafeauth) | `{ type: 'anonymous' }` | How to authenticate. Without credentials, only public reads work. |
| `baseUrl?` | `string` | `https://git.cafe` | Instance root. `/api` is appended. |
| `instance?` | `string` |  | Host used in refs and keys. Defaults to the host of `baseUrl`, with API subdomains mapped to the public host. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `fetch?` | [`FetchLike`](https://forges.link/reference/requests#fetchlike) |  | A `fetch` to use instead of the global one, for tests and for runtimes without one. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `timeout?` | `number` | `30000` | Request timeout in milliseconds. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `webhookSecret?` | `string` |  | Shared secret used to verify inbound webhook deliveries. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `userAgent?` | `string` |  | The `user-agent` header. Defaults to `forges`, except in a browser, which sends its own. Setting it in a browser can trigger a CORS preflight that some forges reject. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `instanceVersion?` | `string` |  | Version of the forge instance, when the caller already knows it. Gates version-dependent capabilities without the network call `refreshCapabilities()` makes. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `readOnly?` | `boolean` |  | Every write, including a mutating `request()`, rejects with `ReadOnlyError` and reports `false`. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `onRetry?` | [`FetcherOptions['onRetry']`](https://forges.link/contributing/provider-kit#fetcheroptions) |  | Called before a request is retried after a rate limit that names a wait of at most a minute, with the wait in milliseconds. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `onRateLimit?` | [`FetcherOptions['onRateLimit']`](https://forges.link/contributing/provider-kit#fetcheroptions) |  | Called with the rate limit of every API response that reports one, so that you can follow the budget without reading `page.rateLimit`. `rateLimit.resource` names the budget where the forge has several. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |

### `gitcafe()`

Creates a GitCafe provider.

```ts
function gitcafe(options?: GitCafeOptions): ForgeProvider<true> & { readonly forge: "gitcafe"; }
```

| Parameter | Type |
| --- | --- |
| `options?` | [`GitCafeOptions`](https://forges.link/reference/providers#gitcafeoptions) |

**Returns:** [`ForgeProvider<true> & { readonly forge: "gitcafe"; }`](https://forges.link/reference/provider)

## Upstream

### `UpstreamAuth`

The credentials Upstream accepts: a personal access token (`upt_…`), or none for public reads.

**one of:**

- [`TokenAuth`](https://forges.link/reference/providers#tokenauth)
- [`AnonymousAuth`](https://forges.link/reference/providers#anonymousauth)

### `UpstreamOptions`

Options for `upstream()`.

**extends:** [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase)

| Member | Type | Default | Description |
| --- | --- | --- | --- |
| `auth?` | [`UpstreamAuth`](https://forges.link/reference/providers#upstreamauth) | `{ type: 'anonymous' }` | How to authenticate. Without credentials, only public reads work. |
| `baseUrl?` | `string` | `'https://upstream.codes'` | The root of the Upstream instance. `/api/v3` is appended. |
| `instance?` | `string` |  | Host used in refs and keys. Defaults to the host of `baseUrl`, with API subdomains mapped to the public host. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `fetch?` | [`FetchLike`](https://forges.link/reference/requests#fetchlike) |  | A `fetch` to use instead of the global one, for tests and for runtimes without one. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `timeout?` | `number` | `30000` | Request timeout in milliseconds. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `webhookSecret?` | `string` |  | Shared secret used to verify inbound webhook deliveries. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `userAgent?` | `string` |  | The `user-agent` header. Defaults to `forges`, except in a browser, which sends its own. Setting it in a browser can trigger a CORS preflight that some forges reject. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `instanceVersion?` | `string` |  | Version of the forge instance, when the caller already knows it. Gates version-dependent capabilities without the network call `refreshCapabilities()` makes. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `readOnly?` | `boolean` |  | Every write, including a mutating `request()`, rejects with `ReadOnlyError` and reports `false`. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `onRetry?` | [`FetcherOptions['onRetry']`](https://forges.link/contributing/provider-kit#fetcheroptions) |  | Called before a request is retried after a rate limit that names a wait of at most a minute, with the wait in milliseconds. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |
| `onRateLimit?` | [`FetcherOptions['onRateLimit']`](https://forges.link/contributing/provider-kit#fetcheroptions) |  | Called with the rate limit of every API response that reports one, so that you can follow the budget without reading `page.rateLimit`. `rateLimit.resource` names the budget where the forge has several. Inherited from [`ForgeOptionsBase`](https://forges.link/reference/providers#forgeoptionsbase). |

### `upstream()`

Creates an Upstream provider, for upstream.codes by default, through the GitHub REST API it serves at `/api/v3`.

```ts
function upstream(options?: UpstreamOptions): ForgeProvider<true> & { readonly forge: "upstream"; }
```

| Parameter | Type |
| --- | --- |
| `options?` | [`UpstreamOptions`](https://forges.link/reference/providers#upstreamoptions) |

**Returns:** [`ForgeProvider<true> & { readonly forge: "upstream"; }`](https://forges.link/reference/provider)

## Forges registry

A registry routes each ref to the provider it belongs to.

### `createForges()`

Combines providers into a registry.

**Example**

```ts
import { createForges, github, gitlab, UnknownForgeError } from 'forges'

const forges = createForges([
  github({ auth: { type: 'token', token: process.env.GITHUB_TOKEN! } }),
  gitlab(),
])

const ref = { forge: 'github', instance: 'github.com', owner: 'danielroe', name: 'forges' } as const
const provider = forges.for(ref)
if (!provider) {
  throw new UnknownForgeError(`No provider registered for ${ref.forge} on ${ref.instance}`, ref)
}
const repo = await provider.repos.get(ref)
```

```ts
function createForges<const T extends readonly ForgeProvider[]>(providers: T): Forges<RegisteredKinds<T>>
```

| Parameter | Type | Description |
| --- | --- | --- |
| `providers` | `T` | Providers such as `github()` creates. |

**Returns:** [`Forges<RegisteredKinds<T>>`](https://forges.link/reference/providers)

### `ProviderFactoryFunction`

The function `defineForgeProvider()` returns. Options are optional when every option is.

**type parameters:** `TOptions, HasWeb extends boolean = boolean, Forge extends ForgeKind = ForgeKind, TProvider extends ForgeProvider<HasWeb> = ForgeProvider<HasWeb>`

**type:** `Record<never, never> extends TOptions ? (options?: TOptions) => TProvider & { readonly forge: Forge } : (options: TOptions) => TProvider & { readonly forge: Forge }`

## Registry methods

### `providers`

**type:** [`ForgeProvider[]`](https://forges.link/reference/provider)

### `get()`

First provider for `forge`, optionally narrowed to a single instance host. Typed as present for a forge in `Kind`.

**Overload 1 of 2**

```ts
get(forge: Kind): ForgeProvider
```

| Parameter | Type |
| --- | --- |
| `forge` | `Kind` |

**Returns:** [`ForgeProvider`](https://forges.link/reference/provider)

**Overload 2 of 2**

```ts
get(forge: ForgeKind, instance?: ForgeInstance): ForgeProvider | undefined
```

| Parameter | Type |
| --- | --- |
| `forge` | [`ForgeKind`](https://forges.link/reference/data-model#forgekind) |
| `instance?` | [`ForgeInstance`](https://forges.link/reference/data-model#forgeinstance) |

**Returns:** [`ForgeProvider | undefined`](https://forges.link/reference/provider)

### `all()`

Every provider for a forge.

```ts
all(forge: ForgeKind): ForgeProvider[]
```

| Parameter | Type |
| --- | --- |
| `forge` | [`ForgeKind`](https://forges.link/reference/data-model#forgekind) |

**Returns:** [`ForgeProvider[]`](https://forges.link/reference/provider)

### `for()`

The provider a ref belongs to, by `forge` and `instance`.

```ts
for(ref: ForgeOrigin): ForgeProvider | undefined
```

| Parameter | Type |
| --- | --- |
| `ref` | [`ForgeOrigin`](https://forges.link/reference/data-model#forgeorigin) |

**Returns:** [`ForgeProvider | undefined`](https://forges.link/reference/provider)

### `forUrl()`

The provider whose instance serves `url`.

```ts
forUrl(url: string | URL): ForgeProvider | undefined
```

| Parameter | Type |
| --- | --- |
| `url` | `string \| URL` |

**Returns:** [`ForgeProvider | undefined`](https://forges.link/reference/provider)

### `parseUrl()`

Reads a web URL, clone URL or npm `repository` value on any registered instance.

```ts
parseUrl(url: string | URL): (ParsedForgeUrl & { provider: ForgeProvider }) | undefined
```

| Parameter | Type |
| --- | --- |
| `url` | `string \| URL` |

**Returns:** `(ParsedForgeUrl & { provider: ForgeProvider }) | undefined`

### `parseReferences()`

The references in `text`, read by the provider of `options.from`; empty when none is registered.

```ts
parseReferences(text: string, options: ParseReferencesOptions): ParsedReference[]
```

| Parameter | Type |
| --- | --- |
| `text` | `string` |
| `options` | [`ParseReferencesOptions`](https://forges.link/reference/providers#parsereferencesoptions) |

**Returns:** [`ParsedReference[]`](https://forges.link/reference/providers#parsedreference)

### `notifications.list()`

Lists the notifications of every provider, provider by provider.

```ts
notifications.list(options?: Omit<NotificationListOptions, 'cursor'>): ForgeIterable<Notification>
```

| Parameter | Type |
| --- | --- |
| `options?` | [`Omit<NotificationListOptions, 'cursor'>`](https://forges.link/reference/data-model#notificationlistoptions) |

**Returns:** [`ForgeIterable<Notification>`](https://forges.link/reference/data-model#notification)

### `threads.getMany()`

Reads threads from several forges at once: groups the refs by the provider each belongs to, batches each group
with that provider's `threads.getMany()`, and returns the results in input order. A ref whose origin is not
registered becomes a per-item warning.

```ts
threads.getMany(refs: ThreadRef[], options?: BaseOptions): Promise<GetManyResult[]>
```

| Parameter | Type |
| --- | --- |
| `refs` | [`ThreadRef[]`](https://forges.link/reference/data-model#threadref) |
| `options?` | [`BaseOptions`](https://forges.link/reference/requests#baseoptions) |

**Returns:** [`Promise<GetManyResult[]>`](https://forges.link/reference/data-model#getmanyresult)

### `search.threads()`

Searches issues and pull requests on every provider that supports search.

```ts
search.threads(query?: Omit<ThreadSearchQuery, 'cursor' | 'sort'> & { sort?: 'created' | 'updated' }): ForgeIterable<Thread>
```

| Parameter | Type |
| --- | --- |
| `query?` | [`Omit<ThreadSearchQuery, 'cursor' \| 'sort'> & { sort?: 'created' \| 'updated' }`](https://forges.link/reference/data-model#threadsearchquery) |

**Returns:** [`ForgeIterable<Thread>`](https://forges.link/reference/data-model#thread)

### `search.repos()`

Searches repositories on every provider that supports search.

```ts
search.repos(query?: Omit<RepoSearchQuery, 'cursor' | 'sort'> & { sort?: 'created' | 'updated' }): ForgeIterable<Repo>
```

| Parameter | Type |
| --- | --- |
| `query?` | [`Omit<RepoSearchQuery, 'cursor' \| 'sort'> & { sort?: 'created' \| 'updated' }`](https://forges.link/reference/data-model#reposearchquery) |

**Returns:** [`ForgeIterable<Repo>`](https://forges.link/reference/data-model#repo)

## Create from the environment

Import from `forges/env`. The variable names are listed under [Environment variables](https://forges.link/reference/environment-variables).

### `EnvProvider`

One set of variables that `providersFromEnv()` reads, and the provider it created from them.

| Member | Type | Description |
| --- | --- | --- |
| `forge` | `string` |  |
| `suffix` | `string` | The part after the field, for example `WORK` in `FORGES_GITHUB_TOKEN_WORK`. Empty for the unsuffixed set. |
| `provider?` | [`ForgeProvider`](https://forges.link/reference/provider) | The provider to pass to `createForges()`. Missing when the set was skipped. |
| `skipped?` | `string` | Why the set was skipped, when it was. Never contains a credential. |
| `demoRepo?` |  | `DEMO_REPO`: a repository to show, as `owner/name`. GitLab owners may contain slashes. |

### `FromEnvOptions`

Options for `providersFromEnv()` and `forgesFromEnv()`.

| Member | Type | Description |
| --- | --- | --- |
| `fetch?` | [`FetchLike`](https://forges.link/reference/requests#fetchlike) | Passed to every provider, for tests and runtimes without a global `fetch`. |

### `providersFromEnv()`

Reads provider sets from `FORGES_<KIND>_<FIELD>[_<SUFFIX>]` variables. A
suffix starts another instance of the same forge.

```ts
function providersFromEnv(env: Record<string, string | undefined>, options: FromEnvOptions = {}): EnvProvider[]
```

| Parameter | Type | Description |
| --- | --- | --- |
| `env` | `Record<string, string \| undefined>` | The variables to read, such as `process.env`. |
| `options?` | [`FromEnvOptions`](https://forges.link/reference/providers#fromenvoptions) | Options that every provider is created with. Defaults to `{}`. |

**Returns:** [`EnvProvider[]`](https://forges.link/reference/providers#envprovider)

### `forgesFromEnv()`

Builds `Forges` from environment variables; see [`providersFromEnv`](https://forges.link/reference/providers#providersfromenv).

**Example**

```ts
import { forgesFromEnv } from 'forges/env'

// FORGES_GITHUB_TOKEN=... FORGES_GITLAB_TOKEN=...
const forges = forgesFromEnv(process.env)
```

```ts
function forgesFromEnv(env: Record<string, string | undefined>, options: FromEnvOptions = {}): Forges
```

| Parameter | Type | Description |
| --- | --- | --- |
| `env` | `Record<string, string \| undefined>` | The variables to read, such as `process.env`. |
| `options?` | [`FromEnvOptions`](https://forges.link/reference/providers#fromenvoptions) | Options that every provider is created with. Defaults to `{}`. |

**Returns:** [`Forges`](https://forges.link/reference/providers)

## Web links without a client

Import from `forges/web`. Each factory takes the `baseUrl` and `instance` of its provider and reads and builds web URLs and references, with no API client. See [Links without a client](https://forges.link/guides/bundling#links-without-a-client).

### `RepoSection`

A repository's section, for linking to the section itself rather than one entry in it.

**one of:**

- `'issues'`
- `'pullRequests'`
- `'compare'`
- `'releases'`
- `'stargazers'`
- `'forks'`
- `'watchers'`

### `UrlTarget`

Something with a web page. A revision (`at`, `base` or `head`) is a branch,
tag or commit sha; Azure DevOps takes a tag as its full ref, `refs/tags/NAME`.
A file's `at` is optional and defaults to the repository's default branch.

**one of:**

- [`{ repo: RepoRef }`](https://forges.link/reference/data-model#reporef)
- `{ repo: RepoRef, section: RepoSection }`
- [`{ thread: ThreadRef }`](https://forges.link/reference/data-model#threadref)
- [`{ comment: CommentRef }`](https://forges.link/reference/data-model#commentref)
- [`{ release: ReleaseRef }`](https://forges.link/reference/data-model#releaseref)
- [`{ file: { repo: RepoRef, path: string, at?: string, line?: number } }`](https://forges.link/reference/data-model#reporef)
- [`{ raw: { repo: RepoRef, path: string, at?: string } }`](https://forges.link/reference/data-model#reporef)
- [`{ commit: { repo: RepoRef, sha: string } }`](https://forges.link/reference/data-model#reporef)
- [`{ compare: { repo: RepoRef, base: string, head: string } }`](https://forges.link/reference/data-model#reporef)

### `ParsedForgeUrl`

What a forge web URL points at. `repo` is always set; the rest when the URL is that specific.

| Member | Type | Description |
| --- | --- | --- |
| `repo` | [`RepoRef`](https://forges.link/reference/data-model#reporef) |  |
| `thread?` | [`ThreadRef`](https://forges.link/reference/data-model#threadref) |  |
| `comment?` | [`CommentRef`](https://forges.link/reference/data-model#commentref) |  |
| `commit?` | [`CommitRef`](https://forges.link/reference/data-model#commitref) |  |
| `release?` | [`ReleaseRef`](https://forges.link/reference/data-model#releaseref) |  |
| `tag?` | `string` | The tag of a tag page that is not a release page, such as GitLab's `-/tags/{tag}`. |
| `compare?` |  | The revisions of a page that compares two, such as `compare/{base}...{head}` or `compare/{base}..{head}`. |
| `file?` |  | A file page: the repository-relative `path`, the revision `at` and the first selected `line`. `at` is unset when the URL leaves the revision to the default branch. An unencoded `/` in a branch name reads as the start of `path`. Forges that address files and folders alike, such as Forgejo, Bitbucket and Azure DevOps, also set this for a folder. |

### `ReferenceOptions`

Options for `provider.referenceFor()`.

| Member | Type | Description |
| --- | --- | --- |
| `from?` | [`RepoRef`](https://forges.link/reference/data-model#reporef) | Repository the reference is written in; a reference within it is the short form. |
| `expand?` | `boolean` | Request the reference expanded to its title, where the forge supports it (GitLab's `+` suffix). |

### `ParseReferencesOptions`

Options for `provider.parseReferences()`.

| Member | Type | Description |
| --- | --- | --- |
| `from` | [`RepoRef`](https://forges.link/reference/data-model#reporef) | Repository the text is written in, which a short reference such as `#42` points into. |

### `ParsedReference`

A reference that `parseReferences()` found in text.

| Member | Type | Description |
| --- | --- | --- |
| `start` | `number` | The offset of the reference's first character. |
| `end` | `number` | The offset just past the reference. |
| `ref` | `ThreadRef \| CommitRef` | The thread or commit it refers to. A commit `sha` is as written, so it can be abbreviated. |

### `WebOptions`

Where a forge's instance is, as a provider's options give it.

| Member | Type | Description |
| --- | --- | --- |
| `baseUrl?` | `string` | API base URL. Defaults to the forge's public instance. |
| `instance?` | `string` | Host used in refs and keys. Defaults to the host of `baseUrl`, with API subdomains mapped to the public host. |

### `ForgeWeb`

The web pages and references of one forge instance, without an API client.

**type parameters:** `Forge extends ForgeKind = ForgeKind`

| Member | Type | Description |
| --- | --- | --- |
| `forge` | `Forge` |  |
| `instance` | [`ForgeInstance`](https://forges.link/reference/data-model#forgeinstance) |  |
| `webOrigin` | `string` | The origin of the forge's website, such as `https://github.com`. |
| `urlFor()` | [`(target: { repo: RepoRef, section?: undefined }) => string`](https://forges.link/reference/data-model#reporef) | The web page for `target`; `undefined` when the forge has no such page. |
| `parseUrl()` | [`(url: string \| URL) => ParsedForgeUrl \| undefined`](https://forges.link/reference/providers#parsedforgeurl) | Reads a web URL, clone URL or npm `repository` value on this instance into refs; `undefined` for anything else. |
| `referenceFor()` | `(ref: ThreadRef \| CommitRef, options?: ReferenceOptions) => string \| undefined` | How to mention `ref` in Markdown on this forge, short when written in `from`; the page URL where the forge has no reference syntax. |
| `parseReferences()` | `(text: string, options: ParseReferencesOptions) => ParsedReference[]` | The references to threads and commits in `text`, with their offsets, in order. |

### `RoutedForge`

What `createForges()` routes between.

| Member | Type | Description |
| --- | --- | --- |
| `forge` | [`ForgeKind`](https://forges.link/reference/data-model#forgekind) |  |
| `instance` | [`ForgeInstance`](https://forges.link/reference/data-model#forgeinstance) |  |
| `parseUrl()` | [`(url: string \| URL) => ParsedForgeUrl \| undefined`](https://forges.link/reference/providers#parsedforgeurl) | Reads a web URL, clone URL or npm `repository` value on this instance into refs; `undefined` for anything else. |
| `parseReferences()` | `(text: string, options: ParseReferencesOptions) => ParsedReference[]` | The references to threads and commits in `text`, with their offsets, in order. |

### `WebForges`

A registry of forges that routes each ref, URL or text to the forge it belongs to.

**type parameters:** `T extends RoutedForge = ForgeWeb`

| Member | Type | Description |
| --- | --- | --- |
| `providers` | `T[]` |  |
| `get()` | `(forge: ForgeKind, instance?: ForgeInstance) => T \| undefined` | The first forge of kind `forge`, optionally on one instance. |
| `all()` | [`(forge: ForgeKind) => T[]`](https://forges.link/reference/data-model#forgekind) | Every instance of a forge. |
| `for()` | [`(ref: ForgeOrigin) => T \| undefined`](https://forges.link/reference/data-model#forgeorigin) | The forge a ref belongs to, by `forge` and `instance`. |
| `forUrl()` | `(url: string \| URL) => T \| undefined` | The forge whose instance serves `url`. |
| `parseUrl()` | [`(url: string \| URL) => (ParsedForgeUrl & { provider: T }) \| undefined`](https://forges.link/reference/providers#parsedforgeurl) | Reads a web URL, clone URL or npm `repository` value on any registered instance. |
| `parseReferences()` | `(text: string, options: ParseReferencesOptions) => ParsedReference[]` | The references in `text`, read by the forge of `options.from`; empty when none is registered. |

### `azureDevOps()`

The web links of Azure DevOps Services, or an Azure DevOps Server collection.

```ts
function azureDevOps(options?: WebOptions): ForgeWeb<"azure-devops">
```

| Parameter | Type |
| --- | --- |
| `options?` | [`WebOptions`](https://forges.link/reference/providers#weboptions) |

**Returns:** [`ForgeWeb<"azure-devops">`](https://forges.link/reference/providers#forgeweb)

### `bitbucket()`

The web links of Bitbucket Cloud.

```ts
function bitbucket(options?: WebOptions): ForgeWeb<"bitbucket">
```

| Parameter | Type |
| --- | --- |
| `options?` | [`WebOptions`](https://forges.link/reference/providers#weboptions) |

**Returns:** [`ForgeWeb<"bitbucket">`](https://forges.link/reference/providers#forgeweb)

### `entire()`

The web links of Entire.

```ts
function entire(options?: WebOptions): ForgeWeb<"entire">
```

| Parameter | Type |
| --- | --- |
| `options?` | [`WebOptions`](https://forges.link/reference/providers#weboptions) |

**Returns:** [`ForgeWeb<"entire">`](https://forges.link/reference/providers#forgeweb)

### `forgejo()`

The web links of Codeberg or another Forgejo instance.

```ts
function forgejo(options?: WebOptions): ForgeWeb<"forgejo">
```

| Parameter | Type |
| --- | --- |
| `options?` | [`WebOptions`](https://forges.link/reference/providers#weboptions) |

**Returns:** [`ForgeWeb<"forgejo">`](https://forges.link/reference/providers#forgeweb)

### `gitbucket()`

The web links of a GitBucket server, which has no public instance, so pass its `baseUrl`.

```ts
function gitbucket(options: WebOptions & { baseUrl: string; }): ForgeWeb<"gitbucket">
```

| Parameter | Type |
| --- | --- |
| `options` | [`WebOptions & { baseUrl: string; }`](https://forges.link/reference/providers#weboptions) |

**Returns:** [`ForgeWeb<"gitbucket">`](https://forges.link/reference/providers#forgeweb)

### `gitcafe()`

The web links of GitCafe.

```ts
function gitcafe(options?: WebOptions): ForgeWeb<"gitcafe">
```

| Parameter | Type |
| --- | --- |
| `options?` | [`WebOptions`](https://forges.link/reference/providers#weboptions) |

**Returns:** [`ForgeWeb<"gitcafe">`](https://forges.link/reference/providers#forgeweb)

### `gitea()`

The web links of gitea.com or another Gitea instance.

```ts
function gitea(options?: WebOptions): ForgeWeb<"gitea">
```

| Parameter | Type |
| --- | --- |
| `options?` | [`WebOptions`](https://forges.link/reference/providers#weboptions) |

**Returns:** [`ForgeWeb<"gitea">`](https://forges.link/reference/providers#forgeweb)

### `gitee()`

The web links of Gitee.

```ts
function gitee(options?: WebOptions): ForgeWeb<"gitee">
```

| Parameter | Type |
| --- | --- |
| `options?` | [`WebOptions`](https://forges.link/reference/providers#weboptions) |

**Returns:** [`ForgeWeb<"gitee">`](https://forges.link/reference/providers#forgeweb)

### `github()`

The web links of github.com or a GitHub Enterprise instance.

```ts
function github(options?: WebOptions): ForgeWeb<"github">
```

| Parameter | Type |
| --- | --- |
| `options?` | [`WebOptions`](https://forges.link/reference/providers#weboptions) |

**Returns:** [`ForgeWeb<"github">`](https://forges.link/reference/providers#forgeweb)

### `gitlab()`

The web links of gitlab.com or a self-managed GitLab instance.

```ts
function gitlab(options?: WebOptions): ForgeWeb<"gitlab">
```

| Parameter | Type |
| --- | --- |
| `options?` | [`WebOptions`](https://forges.link/reference/providers#weboptions) |

**Returns:** [`ForgeWeb<"gitlab">`](https://forges.link/reference/providers#forgeweb)

### `pushin()`

The web links of Pushin.eu.

```ts
function pushin(options?: WebOptions): ForgeWeb<"pushin">
```

| Parameter | Type |
| --- | --- |
| `options?` | [`WebOptions`](https://forges.link/reference/providers#weboptions) |

**Returns:** [`ForgeWeb<"pushin">`](https://forges.link/reference/providers#forgeweb)

### `sourcehut()`

The web links of sr.ht or another Sourcehut instance.

```ts
function sourcehut(options?: WebOptions): ForgeWeb<"sourcehut">
```

| Parameter | Type |
| --- | --- |
| `options?` | [`WebOptions`](https://forges.link/reference/providers#weboptions) |

**Returns:** [`ForgeWeb<"sourcehut">`](https://forges.link/reference/providers#forgeweb)

### `tangled()`

The web links of Tangled.

```ts
function tangled(options?: WebOptions): ForgeWeb<"tangled">
```

| Parameter | Type |
| --- | --- |
| `options?` | [`WebOptions`](https://forges.link/reference/providers#weboptions) |

**Returns:** [`ForgeWeb<"tangled">`](https://forges.link/reference/providers#forgeweb)

### `upstream()`

The web links of upstream.codes.

```ts
function upstream(options?: WebOptions): ForgeWeb<"upstream">
```

| Parameter | Type |
| --- | --- |
| `options?` | [`WebOptions`](https://forges.link/reference/providers#weboptions) |

**Returns:** [`ForgeWeb<"upstream">`](https://forges.link/reference/providers#forgeweb)

### `createForges()`

Combines forges into a registry that reads URLs and references on any of them.

**Example**

```ts
import { createForges, github, gitlab } from 'forges/web'

const forges = createForges([github(), gitlab({ baseUrl: 'https://gitlab.example.com' })])
const parsed = forges.parseUrl('https://gitlab.example.com/acme/widgets/-/merge_requests/3')
```

```ts
function createForges<const T extends ForgeWeb>(forges: readonly T[]): WebForges<T>
```

| Parameter | Type | Description |
| --- | --- | --- |
| `forges` | `readonly T[]` | Forges that the factories of `forges/web` create, or providers. |

**Returns:** [`WebForges<T>`](https://forges.link/reference/providers#webforges)


## Sitemap

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