---
title: "Repositories"
description: "Repositories, files, commits, releases, accounts, teams and search."
canonical_url: "https://forges.link/reference/repositories"
---
# Repositories

> Repositories, files, commits, releases, accounts, teams and search.

For an operation that the forge lacks, see [Unsupported operations](https://forges.link/reference/provider#unsupported-operations).

## `provider.repos`

Repositories, and the labels, milestones and collaborators that belong to them.

### `repos.get()`

Reads a repository by its ref. Rejects with `NotFoundError` when it does not exist or the credential cannot see
it.

**Capability:** `repos.get`.

```ts
repos.get(ref: RepoRef, options?: RepoGetOptions): Promise<Repo>
```

| Parameter | Type |
| --- | --- |
| `ref` | [`RepoRef`](https://forges.link/reference/data-model#reporef) |
| `options?` | [`RepoGetOptions`](https://forges.link/reference/data-model#repogetoptions) |

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

<api-explorer verb="repos.get">



</api-explorer>

### `repos.list()`

The authenticated account's repositories, or the installation's under app auth.

**Capability:** `repos.list`. Anonymous providers reject it.

```ts
repos.list(options?: RepoQuery): ForgeListing<Repo>
```

| Parameter | Type |
| --- | --- |
| `options?` | [`RepoQuery`](https://forges.link/reference/data-model#repoquery) |

**Returns:** `ForgeListing<Repo>`

<api-explorer verb="repos.list">



</api-explorer>

### `repos.byOwner()`

The repositories of a user, organisation, group, workspace or project that the credential can see.

**Capability:** `repos.byOwner`.

```ts
repos.byOwner(owner: RepoRef, query?: OwnerRepoQuery): ForgeListing<Repo>
```

| Parameter | Type | Description |
| --- | --- | --- |
| `owner` | [`RepoRef`](https://forges.link/reference/data-model#reporef) | A namespace ref, such as `namespaceRef(provider, 'acme')`. |
| `query?` | [`OwnerRepoQuery`](https://forges.link/reference/data-model#ownerrepoquery) |  |

**Returns:** `ForgeListing<Repo>`

<api-explorer verb="repos.byOwner">



</api-explorer>

### `repos.labels()`

Every label defined on the repository, whether or not a thread carries it.

**Capability:** `repos.labels`.

```ts
repos.labels(repo: RepoRef, options?: PageOptions): ForgeListing<Label>
```

| Parameter | Type |
| --- | --- |
| `repo` | [`RepoRef`](https://forges.link/reference/data-model#reporef) |
| `options?` | [`PageOptions`](https://forges.link/reference/requests#pageoptions) |

**Returns:** `ForgeListing<Label>`

<api-explorer verb="repos.labels">



</api-explorer>

### `repos.createLabel()`

Creates a label in a repository. A repeat rejects on most forges, because the name is taken.

**Capability:** `repos.createLabel`. Read-only and anonymous providers reject it.

```ts
repos.createLabel(repo: RepoRef, label: LabelInput, options?: BaseOptions): Promise<Label>
```

| Parameter | Type |
| --- | --- |
| `repo` | [`RepoRef`](https://forges.link/reference/data-model#reporef) |
| `label` | [`LabelInput`](https://forges.link/reference/data-model#labelinput) |
| `options?` | [`BaseOptions`](https://forges.link/reference/requests#baseoptions) |

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

<api-explorer verb="repos.createLabel">



</api-explorer>

### `repos.milestones()`

Lists the milestones of a repository.

**Capability:** `repos.milestones`.

```ts
repos.milestones(repo: RepoRef, options?: MilestoneListOptions): ForgeListing<Milestone>
```

| Parameter | Type |
| --- | --- |
| `repo` | [`RepoRef`](https://forges.link/reference/data-model#reporef) |
| `options?` | [`MilestoneListOptions`](https://forges.link/reference/data-model#milestonelistoptions) |

**Returns:** `ForgeListing<Milestone>`

<api-explorer verb="repos.milestones">



</api-explorer>

### `repos.issueTypes()`

The issue types that issues in the repository can have. On GitHub, the enabled types of the account that owns it.

**Capability:** `repos.issueTypes`.

```ts
repos.issueTypes(repo: RepoRef, options?: BaseOptions): Promise<IssueType[]>
```

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

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

<api-explorer verb="repos.issueTypes">



</api-explorer>

### `repos.collaborators()`

Lists the collaborators of a repository, with their roles.

**Capability:** `repos.collaborators`.

```ts
repos.collaborators(repo: RepoRef, options?: PageOptions): ForgeListing<Collaborator>
```

| Parameter | Type |
| --- | --- |
| `repo` | [`RepoRef`](https://forges.link/reference/data-model#reporef) |
| `options?` | [`PageOptions`](https://forges.link/reference/requests#pageoptions) |

**Returns:** `ForgeListing<Collaborator>`

<api-explorer verb="repos.collaborators">



</api-explorer>

### `repos.contributors()`

Lists the commit authors of a repository with their commit counts, most commits first. Pass
`includeUnlinked: true` to include the contributors the forge has not linked to an account.

**Capability:** `repos.contributors`.

```ts
repos.contributors(repo: RepoRef, options?: ContributorQuery): ForgeListing<Contributor>
```

| Parameter | Type |
| --- | --- |
| `repo` | [`RepoRef`](https://forges.link/reference/data-model#reporef) |
| `options?` | [`ContributorQuery`](https://forges.link/reference/data-model#contributorquery) |

**Returns:** `ForgeListing<Contributor>`

<api-explorer verb="repos.contributors">



</api-explorer>

### `repos.contributorStats()`

Weekly commit activity of each contributor to a repository. Where the forge computes the statistics in the
background, the provider waits for them, and throws a `ForgeApiError` with status `202` if they are still not ready.

**Capability:** `repos.contributorStats`.

```ts
repos.contributorStats(repo: RepoRef, options?: BaseOptions): Promise<ContributorStats[]>
```

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

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

<api-explorer verb="repos.contributorStats">



</api-explorer>

### `repos.templates()`

The issue and pull request templates a repository offers, ready to fill in before `threads.create()`. On GitHub,
a repository without its own falls back to the owner's `.github` repository, same as the web UI.

**Example**

```ts
const [template] = await provider.repos.templates(repo, { kind: 'pull_request' })
const body = template?.body ?? ''
```

**Capability:** `repos.templates`.

```ts
repos.templates(repo: RepoRef, options?: RepoTemplateOptions): Promise<RepoTemplate[]>
```

| Parameter | Type |
| --- | --- |
| `repo` | [`RepoRef`](https://forges.link/reference/data-model#reporef) |
| `options?` | [`RepoTemplateOptions`](https://forges.link/reference/data-model#repotemplateoptions) |

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

<api-explorer verb="repos.templates">



</api-explorer>

### `repos.permissionFor()`

One account's role on the repository; `'none'` when it has no access.

**Capability:** `repos.permissionFor`.

```ts
repos.permissionFor(repo: RepoRef, actor: string | Actor, options?: BaseOptions): Promise<RepoRole>
```

| Parameter | Type |
| --- | --- |
| `repo` | [`RepoRef`](https://forges.link/reference/data-model#reporef) |
| `actor` | [`string \| Actor`](https://forges.link/reference/data-model#actor) |
| `options?` | [`BaseOptions`](https://forges.link/reference/requests#baseoptions) |

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

<api-explorer verb="repos.permissionFor">



</api-explorer>

### `repos.branchRules()`

The checks and approvals a pull request needs before it can merge into a branch. On GitHub it reads both
rulesets and classic branch protection, and only an admin can read the approvals that classic protection asks for.

**Example**

```ts
const rules = await provider.repos.branchRules(repo, 'main')
const names = rules.requiredChecks.map(check => check.name)
```

**Capability:** `repos.branchRules`.

```ts
repos.branchRules(repo: RepoRef, branch: string, options?: BaseOptions): Promise<BranchRules>
```

| Parameter | Type | Description |
| --- | --- | --- |
| `repo` | [`RepoRef`](https://forges.link/reference/data-model#reporef) | The repository that holds the branch. |
| `branch` | `string` | The name of the branch, which has to exist. |
| `options?` | [`BaseOptions`](https://forges.link/reference/requests#baseoptions) |  |

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

<api-explorer verb="repos.branchRules">



</api-explorer>

### `repos.addCollaborator()`

Gives an account a role on a repository, or invites it where the forge asks the account to accept first. A repeat
can reject where the forge refuses to add an existing member (GitLab).

**Capability:** `repos.addCollaborator`. Read-only and anonymous providers reject it.

```ts
repos.addCollaborator(repo: RepoRef, actor: string | Actor, role: RepoRole, options?: BaseOptions): Promise<AddCollaboratorResult>
```

| Parameter | Type |
| --- | --- |
| `repo` | [`RepoRef`](https://forges.link/reference/data-model#reporef) |
| `actor` | [`string \| Actor`](https://forges.link/reference/data-model#actor) |
| `role` | [`RepoRole`](https://forges.link/reference/data-model#reporole) |
| `options?` | [`BaseOptions`](https://forges.link/reference/requests#baseoptions) |

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

<api-explorer verb="repos.addCollaborator">



</api-explorer>

### `repos.assignableUsers()`

Accounts that can be assigned to a thread in the repository.

**Capability:** `repos.assignableUsers`.

```ts
repos.assignableUsers(repo: RepoRef, options?: PageOptions): ForgeListing<Actor>
```

| Parameter | Type |
| --- | --- |
| `repo` | [`RepoRef`](https://forges.link/reference/data-model#reporef) |
| `options?` | [`PageOptions`](https://forges.link/reference/requests#pageoptions) |

**Returns:** `ForgeListing<Actor>`

<api-explorer verb="repos.assignableUsers">



</api-explorer>

### `repos.reviewerCandidates()`

Accounts that can be asked to review a given pull request.

**Capability:** `repos.reviewerCandidates`.

```ts
repos.reviewerCandidates(ref: ThreadRef, options?: PageOptions): ForgeListing<Actor>
```

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

**Returns:** `ForgeListing<Actor>`

<api-explorer verb="repos.reviewerCandidates">



</api-explorer>

### `repos.events()`

Lists the activity feed of a repository: pushes, new branches and tags, and changes to its threads and releases.
Events come in the order the forge added them to the feed, latest first, which can differ from `occurredAt`
where the forge adds events late. Each event has `source: 'poll'`.

Where the forge supports conditional requests, the first page has an `etag`; pass it back as
`cursor: { etag }` to read the first page again, which has `notModified: true` and no items when the feed is
unchanged. Where the forge sets a minimum wait between reads, reading the first page again sooner sends no
request and returns a `throttled` page with a `feed_throttled` warning, unless you pass `force: true`.
Iterating then yields nothing, and the warning lands in `warnings`.

**Example**

```ts
const page = await provider.repos.events(repo, { cursor: etag ? { etag } : undefined }).page()
if (!page.notModified) {
  etag = page.etag
}
```

**Capability:** `repos.events`.

```ts
repos.events(repo: RepoRef, options?: EventFeedOptions): ForgeListing<ForgeEvent>
```

| Parameter | Type |
| --- | --- |
| `repo` | [`RepoRef`](https://forges.link/reference/data-model#reporef) |
| `options?` | [`EventFeedOptions`](https://forges.link/reference/data-model#eventfeedoptions) |

**Returns:** `ForgeListing<ForgeEvent>`

<api-explorer verb="repos.events">



</api-explorer>

## `provider.contents`

Files, trees, branches and tags of a repository, comparisons between refs, and commits that write files.

### `contents.getFile()`

One file's contents. Binary-safe: `content` is a `Uint8Array` unless the
forge reports text and `as: 'text'` was asked for. Files past the forge's
inline limit (1 MB on GitHub) are read from the raw or blob endpoint
instead of failing.

**Example**

```ts
const file = await provider.contents.getFile(repo, 'package.json', { as: 'text' })
const manifest = JSON.parse(file.content as string)
```

**Capability:** `contents.getFile`.

```ts
contents.getFile(repo: RepoRef, path: string, options?: FileOptions): Promise<FileContent>
```

| Parameter | Type | Description |
| --- | --- | --- |
| `repo` | [`RepoRef`](https://forges.link/reference/data-model#reporef) | The repository to read from. |
| `path` | `string` | The path of the file from the repository root. |
| `options?` | [`FileOptions`](https://forges.link/reference/data-model#fileoptions) | The revision to read, and whether to decode the content as text. |

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

<api-explorer verb="contents.getFile">



</api-explorer>

### `contents.tree()`

One level, or every descendant with `recursive`. Truncated listings carry a `tree_truncated` warning.

**Capability:** `contents.tree`.

```ts
contents.tree(repo: RepoRef, options?: TreeOptions): ForgeListing<TreeEntry>
```

| Parameter | Type |
| --- | --- |
| `repo` | [`RepoRef`](https://forges.link/reference/data-model#reporef) |
| `options?` | [`TreeOptions`](https://forges.link/reference/data-model#treeoptions) |

**Returns:** `ForgeListing<TreeEntry>`

<api-explorer verb="contents.tree">



</api-explorer>

### `contents.branches()`

Lists the branches of a repository.

**Capability:** `contents.branches`.

```ts
contents.branches(repo: RepoRef, options?: PageOptions): ForgeListing<Branch>
```

| Parameter | Type |
| --- | --- |
| `repo` | [`RepoRef`](https://forges.link/reference/data-model#reporef) |
| `options?` | [`PageOptions`](https://forges.link/reference/requests#pageoptions) |

**Returns:** `ForgeListing<Branch>`

<api-explorer verb="contents.branches">



</api-explorer>

### `contents.tags()`

Lists the tags of a repository.

**Capability:** `contents.tags`.

```ts
contents.tags(repo: RepoRef, options?: PageOptions): ForgeListing<Tag>
```

| Parameter | Type |
| --- | --- |
| `repo` | [`RepoRef`](https://forges.link/reference/data-model#reporef) |
| `options?` | [`PageOptions`](https://forges.link/reference/requests#pageoptions) |

**Returns:** `ForgeListing<Tag>`

<api-explorer verb="contents.tags">



</api-explorer>

### `contents.resolveRef()`

Resolves a branch, tag or sha to a full commit sha; a full sha is returned as is.

**Capability:** `contents.resolveRef`.

```ts
contents.resolveRef(repo: RepoRef, ref: string, options?: BaseOptions): Promise<string>
```

| Parameter | Type |
| --- | --- |
| `repo` | [`RepoRef`](https://forges.link/reference/data-model#reporef) |
| `ref` | `string` |
| `options?` | [`BaseOptions`](https://forges.link/reference/requests#baseoptions) |

**Returns:** `Promise<string>`

<api-explorer verb="contents.resolveRef">



</api-explorer>

### `contents.compare()`

Commits and files between two refs.

**Capability:** `contents.compare`.

```ts
contents.compare(repo: RepoRef, base: string, head: string, options?: CompareOptions): Promise<Comparison>
```

| Parameter | Type |
| --- | --- |
| `repo` | [`RepoRef`](https://forges.link/reference/data-model#reporef) |
| `base` | `string` |
| `head` | `string` |
| `options?` | [`CompareOptions`](https://forges.link/reference/data-model#compareoptions) |

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

<api-explorer verb="contents.compare">



</api-explorer>

### `contents.commitFiles()`

Writes and deletes files in one commit on a branch, and moves the branch to it. A repeat with `expectedHead` or
`createFrom` rejects once the first attempt has moved or created the branch; without them, it adds a second commit.

**Example**

```ts
const commit = await provider.contents.commitFiles(repo, {
  branch: 'docs/readme',
  createFrom: 'main',
  message: 'docs: update readme',
  changes: [
    { path: 'README.md', content: '# widgets\n' },
    { path: 'OLD.md', content: null },
  ],
})
```

**Capability:** `contents.commitFiles`. Read-only and anonymous providers reject it.

```ts
contents.commitFiles(repo: RepoRef, input: CommitFilesInput, options?: BaseOptions): Promise<Commit>
```

| Parameter | Type | Description |
| --- | --- | --- |
| `repo` | [`RepoRef`](https://forges.link/reference/data-model#reporef) | The repository to commit to. |
| `input` | [`CommitFilesInput`](https://forges.link/reference/data-model#commitfilesinput) | The branch, the message and the files, with the head the branch must have and the ref to create it from. |
| `options?` | [`BaseOptions`](https://forges.link/reference/requests#baseoptions) |  |

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

**Throws:**

- `BranchMovedError` when the branch no longer points at `expectedHead`.
- `NotFoundError` when a file to delete does not exist.

<api-explorer verb="contents.commitFiles">



</api-explorer>

## `provider.commits`

Commits of a repository and the comments on them.

### `commits.list()`

Lists the commits that lead to `ref`, or to the default branch.

**Capability:** `commits.list`.

```ts
commits.list(repo: RepoRef, query?: CommitQuery): ForgeListing<Commit>
```

| Parameter | Type |
| --- | --- |
| `repo` | [`RepoRef`](https://forges.link/reference/data-model#reporef) |
| `query?` | [`CommitQuery`](https://forges.link/reference/data-model#commitquery) |

**Returns:** `ForgeListing<Commit>`

<api-explorer verb="commits.list">



</api-explorer>

### `commits.get()`

One commit, with its files and stats.

**Capability:** `commits.get`.

```ts
commits.get(ref: CommitRef, options?: BaseOptions): Promise<Commit>
```

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

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

<api-explorer verb="commits.get">



</api-explorer>

### `commits.comments()`

Lists the comments on a commit.

**Capability:** `commits.comments`.

```ts
commits.comments(ref: CommitRef, options?: PageOptions): ForgeListing<CommitComment>
```

| Parameter | Type |
| --- | --- |
| `ref` | [`CommitRef`](https://forges.link/reference/data-model#commitref) |
| `options?` | [`PageOptions`](https://forges.link/reference/requests#pageoptions) |

**Returns:** `ForgeListing<CommitComment>`

### `commits.getComment()`

Reads one comment on a commit. Where the forge has no endpoint for it (`capabilities.commits.getComment` is
`'emulated'`), it lists the comments of the commit page by page until the id matches, which costs a request for
each page read.

**Capability:** `commits.getComment`.

```ts
commits.getComment(ref: CommitCommentRef, options?: BaseOptions): Promise<CommitComment>
```

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

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

### `commits.createComment()`

Comments on a commit.

**Capability:** `commits.createComment`. Read-only and anonymous providers reject it.

```ts
commits.createComment(ref: CommitRef, body: string, options?: BaseOptions): Promise<CommitComment>
```

| Parameter | Type |
| --- | --- |
| `ref` | [`CommitRef`](https://forges.link/reference/data-model#commitref) |
| `body` | `string` |
| `options?` | [`BaseOptions`](https://forges.link/reference/requests#baseoptions) |

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

### `commits.updateComment()`

Replaces the body of a comment on a commit.

**Capability:** `commits.updateComment`. Read-only and anonymous providers reject it.

```ts
commits.updateComment(ref: CommitCommentRef, body: string, options?: BaseOptions): Promise<CommitComment>
```

| Parameter | Type |
| --- | --- |
| `ref` | [`CommitCommentRef`](https://forges.link/reference/data-model#commitcommentref) |
| `body` | `string` |
| `options?` | [`BaseOptions`](https://forges.link/reference/requests#baseoptions) |

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

### `commits.deleteComment()`

Deletes a comment on a commit. A repeat can reject with `NotFoundError` once the comment is gone.

**Capability:** `commits.deleteComment`. Read-only and anonymous providers reject it.

```ts
commits.deleteComment(ref: CommitCommentRef, options?: BaseOptions): Promise<void>
```

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

**Returns:** `Promise<void>`

### `commits.hideComment()`

Hides a comment on a commit behind a note of the reason, as `threads.hideComment()` does for a thread comment. A repeat leaves it hidden.

**Capability:** `commits.hideComment`. Read-only and anonymous providers reject it.

```ts
commits.hideComment(ref: CommitCommentRef, reason: HideCommentReason, options?: BaseOptions): Promise<void>
```

| Parameter | Type |
| --- | --- |
| `ref` | [`CommitCommentRef`](https://forges.link/reference/data-model#commitcommentref) |
| `reason` | [`HideCommentReason`](https://forges.link/reference/data-model#hidecommentreason) |
| `options?` | [`BaseOptions`](https://forges.link/reference/requests#baseoptions) |

**Returns:** `Promise<void>`

### `commits.unhideComment()`

Shows a hidden comment on a commit again. A repeat leaves it shown.

**Capability:** `commits.hideComment`. Read-only and anonymous providers reject it.

```ts
commits.unhideComment(ref: CommitCommentRef, options?: BaseOptions): Promise<void>
```

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

**Returns:** `Promise<void>`

## `provider.releases`

Reading, creating and updating the releases of a repository, and downloading their assets.

### `releases.list()`

Lists the releases of a repository, including drafts and pre-releases where the credential can see them.

**Capability:** `releases.list`.

```ts
releases.list(repo: RepoRef, options?: PageOptions): ForgeListing<Release>
```

| Parameter | Type |
| --- | --- |
| `repo` | [`RepoRef`](https://forges.link/reference/data-model#reporef) |
| `options?` | [`PageOptions`](https://forges.link/reference/requests#pageoptions) |

**Returns:** `ForgeListing<Release>`

<api-explorer verb="releases.list">



</api-explorer>

### `releases.get()`

Reads a release by its ref.

**Capability:** `releases.get`.

```ts
releases.get(ref: ReleaseRef, options?: BaseOptions): Promise<Release>
```

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

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

<api-explorer verb="releases.get">



</api-explorer>

### `releases.getByTag()`

The release for a tag name.

**Capability:** `releases.getByTag`.

```ts
releases.getByTag(repo: RepoRef, tag: string, options?: BaseOptions): Promise<Release>
```

| Parameter | Type |
| --- | --- |
| `repo` | [`RepoRef`](https://forges.link/reference/data-model#reporef) |
| `tag` | `string` |
| `options?` | [`BaseOptions`](https://forges.link/reference/requests#baseoptions) |

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

<api-explorer verb="releases.getByTag">



</api-explorer>

### `releases.downloadAsset()`

Downloads a release asset, as a stream of its bytes, a `Uint8Array` with `as: 'binary'` or a string with
`as: 'text'`. A redirect to a CDN host is followed without the `Authorization` header, which those hosts reject.

**Example**

```ts
const release = await provider.releases.getByTag(repo, 'v1.0.0')
const asset = release.assets?.find(asset => asset.name.endsWith('.pdf'))
if (asset?.ref) {
  const bytes = await provider.releases.downloadAsset(asset.ref, { as: 'binary' })
}
```

**Capability:** `releases.downloadAsset`.

**Overload 1 of 3**

```ts
releases.downloadAsset(ref: ReleaseAssetRef, options?: DownloadAssetOptions & { as?: 'stream' }): Promise<ReadableStream<Uint8Array>>
```

| Parameter | Type |
| --- | --- |
| `ref` | [`ReleaseAssetRef`](https://forges.link/reference/data-model#releaseassetref) |
| `options?` | [`DownloadAssetOptions & { as?: 'stream' }`](https://forges.link/reference/data-model#downloadassetoptions) |

**Returns:** `Promise<ReadableStream<Uint8Array>>`

**Overload 2 of 3**

```ts
releases.downloadAsset(ref: ReleaseAssetRef, options: DownloadAssetOptions & { as: 'binary' }): Promise<Uint8Array>
```

| Parameter | Type |
| --- | --- |
| `ref` | [`ReleaseAssetRef`](https://forges.link/reference/data-model#releaseassetref) |
| `options` | [`DownloadAssetOptions & { as: 'binary' }`](https://forges.link/reference/data-model#downloadassetoptions) |

**Returns:** `Promise<Uint8Array>`

**Overload 3 of 3**

```ts
releases.downloadAsset(ref: ReleaseAssetRef, options: DownloadAssetOptions & { as: 'text' }): Promise<string>
```

| Parameter | Type |
| --- | --- |
| `ref` | [`ReleaseAssetRef`](https://forges.link/reference/data-model#releaseassetref) |
| `options` | [`DownloadAssetOptions & { as: 'text' }`](https://forges.link/reference/data-model#downloadassetoptions) |

**Returns:** `Promise<string>`

<api-explorer verb="releases.downloadAsset">



</api-explorer>

### `releases.latest()`

The most recent published release that is not a draft or prerelease, if any.

**Capability:** `releases.latest`.

```ts
releases.latest(repo: RepoRef, options?: BaseOptions): Promise<Release | undefined>
```

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

**Returns:** [`Promise<Release | undefined>`](https://forges.link/reference/data-model#release)

<api-explorer verb="releases.latest">



</api-explorer>

### `releases.create()`

Creates a release, and its tag from `target` when the tag does not exist yet. A repeat for the same tag rejects on
forges that hold one release per tag; read it back with `getByTag()`.

**Example**

```ts
const release = await provider.releases.create(repo, { tag: 'v1.2.0', body: notes, draft: true })
```

**Capability:** `releases.create`. Read-only and anonymous providers reject it.

```ts
releases.create(repo: RepoRef, input: ReleaseInput, options?: BaseOptions): Promise<Release>
```

| Parameter | Type | Description |
| --- | --- | --- |
| `repo` | [`RepoRef`](https://forges.link/reference/data-model#reporef) | The repository to release. |
| `input` | [`ReleaseInput`](https://forges.link/reference/data-model#releaseinput) | The tag, the name, the notes and whether the release is a draft or a prerelease. |
| `options?` | [`BaseOptions`](https://forges.link/reference/requests#baseoptions) |  |

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

**Throws:**

- `UnsupportedOperationError` for `draft: true` or `prerelease: true` on a forge without drafts or prereleases.

### `releases.update()`

Changes a release. Fields left out stay as they are, so `{ draft: false }` publishes a draft.

**Capability:** `releases.update`. Read-only and anonymous providers reject it.

```ts
releases.update(ref: ReleaseRef, update: ReleaseUpdate, options?: BaseOptions): Promise<Release>
```

| Parameter | Type |
| --- | --- |
| `ref` | [`ReleaseRef`](https://forges.link/reference/data-model#releaseref) |
| `update` | [`ReleaseUpdate`](https://forges.link/reference/data-model#releaseupdate) |
| `options?` | [`BaseOptions`](https://forges.link/reference/requests#baseoptions) |

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

**Throws:**

- `UnsupportedOperationError` for a change the forge cannot make, such as a new tag on GitLab.
- `ForbiddenError` with reason `immutable_release` when the forge refuses the write because the
release is immutable (GitHub); its name, notes, prerelease and `latest` flags stay editable.

## `provider.users`

Reading accounts.

### `users.get()`

Reads an account by login, without needing a credential where the forge allows it.

**Capability:** `users.get`.

```ts
users.get(login: string, options?: BaseOptions): Promise<User>
```

| Parameter | Type |
| --- | --- |
| `login` | `string` |
| `options?` | [`BaseOptions`](https://forges.link/reference/requests#baseoptions) |

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

<api-explorer verb="users.get">



</api-explorer>

### `users.me()`

The account the provider's credential belongs to.

**Example**

```ts
const me = await provider.users.me()
console.log(me.login)
```

**Capability:** `users.me`. Anonymous providers reject it.

```ts
users.me(options?: BaseOptions): Promise<User>
```

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

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

<api-explorer verb="users.me">



</api-explorer>

### `users.sponsorable()`

Whether an account accepts sponsorship on the forge, such as through a GitHub Sponsors listing. Rejects with
`NotFoundError` when no account has the login.

**Example**

```ts
if (await provider.users.sponsorable('danielroe')) {
  console.log('https://github.com/sponsors/danielroe')
}
```

**Capability:** `users.sponsorable`. Anonymous providers reject it.

```ts
users.sponsorable(login: string, options?: BaseOptions): Promise<boolean>
```

| Parameter | Type | Description |
| --- | --- | --- |
| `login` | `string` | The account to check. |
| `options?` | [`BaseOptions`](https://forges.link/reference/requests#baseoptions) |  |

**Returns:** `Promise<boolean>`

<api-explorer verb="users.sponsorable">



</api-explorer>

### `users.sponsorableMany()`

Whether several accounts accept sponsorship, batched where the forge allows. Returns one entry per login, in
input order. GitHub reads up to 50 logins per request, so a few dozen maintainers cost one request rather than
one each. An unknown or renamed login becomes an `ok: false` entry with an `account_not_found` warning, and an
account that cannot be read for another reason becomes `account_unreadable`, rather than rejecting the call. A
request-level failure, such as a transport error, rate limit, or rejected credential, rejects the whole call.
Other GraphQL failures without `data` return an `ok: false` warning for each login in the affected chunk.

**Example**

```ts
for (const result of await provider.users.sponsorableMany(['danielroe', 'octocat'])) {
  if (result.ok && result.sponsorable) {
    console.log(`https://github.com/sponsors/${result.login}`)
  }
}
```

**Capability:** `users.sponsorableMany`. Anonymous providers reject it.

```ts
users.sponsorableMany(logins: string[], options?: BaseOptions): Promise<SponsorableManyResult[]>
```

| Parameter | Type | Description |
| --- | --- | --- |
| `logins` | `string[]` | The accounts to check. A repeated login gets an entry of its own. |
| `options?` | [`BaseOptions`](https://forges.link/reference/requests#baseoptions) |  |

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

<api-explorer verb="users.sponsorableMany">



</api-explorer>

### `users.events()`

Lists what an account did across the repositories the credential can see, in the feed's order as for
`ReposApi.events`, with the same conditional requests and throttling. Each event has `source: 'poll'`.

**Capability:** `users.events`.

```ts
users.events(login: string, options?: EventFeedOptions): ForgeListing<ForgeEvent>
```

| Parameter | Type |
| --- | --- |
| `login` | `string` |
| `options?` | [`EventFeedOptions`](https://forges.link/reference/data-model#eventfeedoptions) |

**Returns:** `ForgeListing<ForgeEvent>`

<api-explorer verb="users.events">



</api-explorer>

### `users.block()`

Blocks an account on behalf of the account the credential belongs to. A repeat can reject with a
`ForgeApiError` with `status` 422.

**Capability:** `users.block`. Read-only and anonymous providers reject it.

```ts
users.block(login: string, options?: BaseOptions): Promise<void>
```

| Parameter | Type | Description |
| --- | --- | --- |
| `login` | `string` | The account to block. |
| `options?` | [`BaseOptions`](https://forges.link/reference/requests#baseoptions) |  |

**Returns:** `Promise<void>`

<api-explorer verb="users.block">



</api-explorer>

### `users.unblock()`

Unblocks an account that `block()` blocked. A repeat can reject with a `ForgeApiError` with `status` 422.

**Capability:** `users.block`. Read-only and anonymous providers reject it.

```ts
users.unblock(login: string, options?: BaseOptions): Promise<void>
```

| Parameter | Type |
| --- | --- |
| `login` | `string` |
| `options?` | [`BaseOptions`](https://forges.link/reference/requests#baseoptions) |

**Returns:** `Promise<void>`

<api-explorer verb="users.unblock">



</api-explorer>

## `provider.installations`

The installations of the app that the provider authenticates as.

### `installations.list()`

Lists the installations of the app.

**Capability:** `installations.list`. Anonymous providers reject it.

```ts
installations.list(options?: PageOptions): ForgeListing<Installation>
```

| Parameter | Type |
| --- | --- |
| `options?` | [`PageOptions`](https://forges.link/reference/requests#pageoptions) |

**Returns:** `ForgeListing<Installation>`

### `installations.get()`

Reads one installation.

**Capability:** `installations.list`. Anonymous providers reject it.

```ts
installations.get(installation: Installation | string, options?: BaseOptions): Promise<Installation>
```

| Parameter | Type |
| --- | --- |
| `installation` | [`Installation \| string`](https://forges.link/reference/data-model#installation) |
| `options?` | [`BaseOptions`](https://forges.link/reference/requests#baseoptions) |

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

### `installations.token()`

Mints (or reuses a cached) installation token.

**Capability:** `installations.list`. Anonymous providers reject it.

```ts
installations.token(installation: Installation | string, options?: BaseOptions): Promise<InstallationToken>
```

| Parameter | Type |
| --- | --- |
| `installation` | [`Installation \| string`](https://forges.link/reference/data-model#installation) |
| `options?` | [`BaseOptions`](https://forges.link/reference/requests#baseoptions) |

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

### `installations.repos()`

Lists the repositories that an installation can access.

**Capability:** `installations.list`. Anonymous providers reject it.

```ts
installations.repos(installation: Installation | string, options?: PageOptions): ForgeListing<Repo>
```

| Parameter | Type |
| --- | --- |
| `installation` | [`Installation \| string`](https://forges.link/reference/data-model#installation) |
| `options?` | [`PageOptions`](https://forges.link/reference/requests#pageoptions) |

**Returns:** `ForgeListing<Repo>`

### `installations.provider()`

Provider authenticated as one installation, sharing this instance's app credentials.

**Capability:** `installations.list`. Anonymous providers reject it.

```ts
installations.provider(installation: Installation | string): ForgeProvider
```

| Parameter | Type |
| --- | --- |
| `installation` | [`Installation \| string`](https://forges.link/reference/data-model#installation) |

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

### `installations.providers()`

One provider per installation.

**Capability:** `installations.list`. Anonymous providers reject it.

```ts
installations.providers(): AsyncIterable<{ installation: Installation, provider: ForgeProvider }>
```

**Returns:** `AsyncIterable<{ installation: Installation, provider: ForgeProvider }>`

## `provider.orgs`

The teams of an organisation and their members. An organisation is a
namespace ref, as `repos.byOwner()` takes one. GitLab has no teams of its
own, so its subgroups play the role of teams and their members are the
subgroup's members.

### `orgs.teams()`

Lists the teams of an organisation.

**Capability:** `orgs.teams`.

```ts
orgs.teams(org: RepoRef, options?: PageOptions): ForgeListing<Team>
```

| Parameter | Type | Description |
| --- | --- | --- |
| `org` | [`RepoRef`](https://forges.link/reference/data-model#reporef) | A namespace ref, such as `namespaceRef(provider, 'acme')`. |
| `options?` | [`PageOptions`](https://forges.link/reference/requests#pageoptions) |  |

**Returns:** `ForgeListing<Team>`

<api-explorer verb="orgs.teams">



</api-explorer>

### `orgs.teamMembers()`

Lists the members of a team, as actors.

**Capability:** `orgs.teamMembers`. Anonymous providers reject it.

```ts
orgs.teamMembers(team: TeamRef, options?: PageOptions): ForgeListing<Actor>
```

| Parameter | Type | Description |
| --- | --- | --- |
| `team` | [`TeamRef`](https://forges.link/reference/data-model#teamref) | A team's `ref` from `teams()`, or a ref with only `org` and `slug`, such as `{ forge, instance, org, slug: 'stewards' }`. |
| `options?` | [`PageOptions`](https://forges.link/reference/requests#pageoptions) |  |

**Returns:** `ForgeListing<Actor>`

<api-explorer verb="orgs.teamMembers">



</api-explorer>

### `orgs.block()`

Blocks an account from the repositories of an organisation. A repeat can reject with a `ForgeApiError` with
`status` 422.

**Example**

```ts
await provider.orgs.block(namespaceRef(provider, 'acme'), 'spammer')
```

**Capability:** `orgs.block`. Read-only and anonymous providers reject it.

```ts
orgs.block(org: RepoRef, login: string, options?: BaseOptions): Promise<void>
```

| Parameter | Type | Description |
| --- | --- | --- |
| `org` | [`RepoRef`](https://forges.link/reference/data-model#reporef) | A namespace ref, as for `teams()`. |
| `login` | `string` | The account to block. |
| `options?` | [`BaseOptions`](https://forges.link/reference/requests#baseoptions) |  |

**Returns:** `Promise<void>`

<api-explorer verb="orgs.block">



</api-explorer>

### `orgs.unblock()`

Unblocks an account that `block()` blocked. A repeat can reject with a `ForgeApiError` with `status` 422.

**Capability:** `orgs.block`. Read-only and anonymous providers reject it.

```ts
orgs.unblock(org: RepoRef, login: string, options?: BaseOptions): Promise<void>
```

| Parameter | Type |
| --- | --- |
| `org` | [`RepoRef`](https://forges.link/reference/data-model#reporef) |
| `login` | `string` |
| `options?` | [`BaseOptions`](https://forges.link/reference/requests#baseoptions) |

**Returns:** `Promise<void>`

<api-explorer verb="orgs.unblock">



</api-explorer>

## `provider.search`

Searching issues and pull requests, repositories, commits and code across the forge.

### `search.threads()`

Issues and pull requests across repositories. Fields the forge cannot
filter on come back as a `filter_unsupported` warning on the page.

**Capability:** `search.threads`.

```ts
search.threads(query: ThreadSearchQuery): ForgeListing<Thread>
```

| Parameter | Type |
| --- | --- |
| `query` | [`ThreadSearchQuery`](https://forges.link/reference/data-model#threadsearchquery) |

**Returns:** `ForgeListing<Thread>`

<api-explorer verb="search.threads">



</api-explorer>

### `search.repos()`

Searches repositories.

**Capability:** `search.repos`.

```ts
search.repos(query: RepoSearchQuery): ForgeListing<Repo>
```

| Parameter | Type |
| --- | --- |
| `query` | [`RepoSearchQuery`](https://forges.link/reference/data-model#reposearchquery) |

**Returns:** `ForgeListing<Repo>`

<api-explorer verb="search.repos">



</api-explorer>

### `search.commits()`

Commits across repositories, where the forge indexes them.

**Capability:** `search.commits`.

```ts
search.commits(query: CommitSearchQuery): ForgeListing<Commit>
```

| Parameter | Type |
| --- | --- |
| `query` | [`CommitSearchQuery`](https://forges.link/reference/data-model#commitsearchquery) |

**Returns:** `ForgeListing<Commit>`

<api-explorer verb="search.commits">



</api-explorer>

### `search.code()`

Searches the contents of files, where the forge indexes them.

**Capability:** `search.code`.

```ts
search.code(query: CodeSearchQuery): ForgeListing<CodeMatch>
```

| Parameter | Type |
| --- | --- |
| `query` | [`CodeSearchQuery`](https://forges.link/reference/data-model#codesearchquery) |

**Returns:** `ForgeListing<CodeMatch>`


## Sitemap

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