> ## Documentation Index
> Fetch the complete documentation index at: https://docs.corsair.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# API

> API reference for Sourcegraph: every `sourcegraph.api.*` operation with input and output types.

Every `sourcegraph.api.*` operation is listed below with parameter shapes and return types from the plugin Zod schemas.

> [!NOTE]
>
> **New to Corsair?** See [API access](https://docs.corsair.dev/concepts/api.md), [authentication](https://docs.corsair.dev/concepts/auth.md), and [error handling](https://docs.corsair.dev/concepts/error-handling).

## Repository

### compareCommits

`repository.compareCommits`

Compare two commits and list file diffs

**Risk:** `read`

```ts theme={null}
await corsair.sourcegraph.api.repository.compareCommits({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `repo` | `string` | Yes | — |
| `base` | `string` | Yes | — |
| `head` | `string` | Yes | — |
| `first` | `number` | No | — |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `repository` | `object \| null` | Yes | — |

> [accordion] repository full type
>
> ```ts theme={null}
> {
>   comparison?: {
>     range?: {
>       expr?: string
>     } | null,
>     fileDiffs?: {
>       nodes?: {
>         oldPath?: string | null,
>         newPath?: string | null,
>         stat?: {
>           added?: number,
>           changed?: number,
>           deleted?: number
>         }
>       }[],
>       totalCount?: number | null,
>       pageInfo?: {
>         hasNextPage?: boolean,
>         endCursor?: string | null
>       }
>     }
>   } | null
> } | null
> ```

***

### getCommitDetails

`repository.getCommitDetails`

Get details for a commit, branch, or tag

**Risk:** `read`

```ts theme={null}
await corsair.sourcegraph.api.repository.getCommitDetails({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `repo` | `string` | Yes | — |
| `rev` | `string` | Yes | — |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `repository` | `object \| null` | Yes | — |

> [accordion] repository full type
>
> ```ts theme={null}
> {
>   commit: {
>     oid: string,
>     abbreviatedOID?: string,
>     message?: string,
>     subject?: string,
>     body?: string | null,
>     url?: string,
>     canonicalURL?: string,
>     author?: {
>       date?: string,
>       person?: {
>         name?: string | null,
>         email?: string | null,
>         displayName?: string | null
>       } | null
>     },
>     committer?: {
>       date?: string,
>       person?: {
>         name?: string | null,
>         email?: string | null,
>         displayName?: string | null
>       } | null
>     } | null
>   } | null
> } | null
> ```

***

### getFileContents

`repository.getFileContents`

Fetch file contents on the default branch (HEAD)

**Risk:** `read`

```ts theme={null}
await corsair.sourcegraph.api.repository.getFileContents({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `repo_name` | `string` | Yes | — |
| `file_path` | `string` | Yes | — |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `repository` | `object \| null` | Yes | — |

> [accordion] repository full type
>
> ```ts theme={null}
> {
>   name?: string,
>   defaultBranch?: {
>     displayName?: string | null
>   } | null,
>   commit?: {
>     oid?: string,
>     file: {
>       name?: string,
>       path?: string,
>       content?: string,
>       binary?: boolean,
>       byteSize?: number
>     } | null
>   } | null
> } | null
> ```

***

### list

`repository.list`

List repositories on the Sourcegraph instance

**Risk:** `read`

```ts theme={null}
await corsair.sourcegraph.api.repository.list({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `first` | `number` | Yes | — |
| `after` | `string` | No | — |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `repositories` | `object` | Yes | — |

> [accordion] repositories full type
>
> ```ts theme={null}
> {
>   nodes?: {
>     name: string,
>     url?: string,
>     description?: string | null,
>     language?: string | null
>   }[],
>   totalCount?: number | null,
>   pageInfo?: {
>     hasNextPage?: boolean,
>     endCursor?: string | null
>   }
> }
> ```

***

### listFiles

`repository.listFiles`

List files and directories in a repository path

**Risk:** `read`

```ts theme={null}
await corsair.sourcegraph.api.repository.listFiles({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `repo_name` | `string` | Yes | — |
| `path` | `string` | No | — |
| `rev` | `string` | No | — |
| `recursive` | `boolean` | No | — |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `repository` | `object \| null` | Yes | — |

> [accordion] repository full type
>
> ```ts theme={null}
> {
>   commit: {
>     tree: {
>       path?: string,
>       isRoot?: boolean,
>       entries?: {
>         name?: string,
>         path?: string,
>         isDirectory?: boolean
>       }[]
>     } | null
>   } | null
> } | null
> ```

***

### listLanguages

`repository.listLanguages`

List languages used in a repository

**Risk:** `read`

```ts theme={null}
await corsair.sourcegraph.api.repository.listLanguages({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `repoName` | `string` | Yes | — |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `repository` | `object \| null` | Yes | — |

> [accordion] repository full type
>
> ```ts theme={null}
> {
>   name?: string,
>   language?: string | null,
>   commit?: {
>     languages?: string[],
>     languageStatistics?: {
>       name?: string,
>       totalBytes?: number,
>       totalLines?: number
>     }[]
>   } | null
> } | null
> ```

***

## Site

### checkSettingsEditPermission

`site.checkSettingsEditPermission`

Check whether the viewer can edit site settings through the GraphQL API

**Risk:** `read`

```ts theme={null}
await corsair.sourcegraph.api.site.checkSettingsEditPermission({});
```

**Input:** *empty object*

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `site` | `object \| null` | No | — |
| `currentUser` | `object \| null` | No | — |
| `canEditSiteSettings` | `boolean` | Yes | — |

> [accordion] site full type
>
> ```ts theme={null}
> {
>   id?: string,
>   siteID?: string,
>   canReloadSite?: boolean,
>   viewerCanAdminister?: boolean
> } | null
> ```

> [accordion] currentUser full type
>
> ```ts theme={null}
> {
>   siteAdmin?: boolean,
>   viewerCanAdminister?: boolean
> } | null
> ```

***

## User

### getCurrent

`user.getCurrent`

Retrieve the currently authenticated Sourcegraph user

**Risk:** `read`

```ts theme={null}
await corsair.sourcegraph.api.user.getCurrent({});
```

**Input:** *empty object*

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `currentUser` | `object \| null` | Yes | — |

> [accordion] currentUser full type
>
> ```ts theme={null}
> {
>   id?: string,
>   username?: string,
>   displayName?: string | null,
>   email?: string | null,
>   siteAdmin?: boolean,
>   viewerCanAdminister?: boolean,
>   avatarURL?: string | null,
>   url?: string,
>   createdAt?: string
> } | null
> ```

***


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.