# @octoherd/octokit

> Customized Octokit for Octoherd

Latest version **5.0.3** (published 2025-10-31) · ISC license · 0 weekly downloads

## Install

```sh
npm install @octoherd/octokit
pnpm add @octoherd/octokit
yarn add @octoherd/octokit
bun add @octoherd/octokit
```

## Health

**Score 65/100 (B)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 5.0.3 |
| Published | 2025-10-31 |
| First published | 2021-02-25 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >= 18 |
| Dependencies | 6 |
| Unpacked size | 15.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Gregor Martynus |
| Maintainers | gr2m |
| Keywords | octoherd, octokit |

## Links

- npm: https://www.npmjs.com/package/@octoherd/octokit
- Repository: https://github.com/octoherd/octokit
- Homepage: https://github.com/octoherd/octokit#readme
- Issues: https://github.com/octoherd/octokit/issues
- npm.io page: https://npm.io/package/@octoherd/octokit

## Dependencies (6)

- [@octokit/core](https://npm.io/package/@octokit/core.md) ^7.0.0
- [@octokit/plugin-retry](https://npm.io/package/@octokit/plugin-retry.md) ^8.0.0
- [quick-format-unescaped](https://npm.io/package/quick-format-unescaped.md) ^4.0.1
- [@octokit/plugin-throttling](https://npm.io/package/@octokit/plugin-throttling.md) ^11.0.0
- [@octokit/plugin-paginate-rest](https://npm.io/package/@octokit/plugin-paginate-rest.md) ^14.0.0
- [semantic-release-plugin-update-version-in-files](https://npm.io/package/semantic-release-plugin-update-version-in-files.md) ^2.0.0

## Recent versions

- 5.0.3 (latest) — 2025-10-31
- 5.0.2 — 2025-08-11
- 5.0.1 — 2025-04-13
- 5.0.0 — 2024-04-09
- 4.0.3 — 2024-04-09
- 4.0.2 — 2024-03-07
- 4.0.1 — 2023-09-23
- 4.0.0 — 2023-07-11
- 3.0.9 — 2023-06-05
- 3.0.8 — 2023-06-05
- 3.0.7 — 2023-06-05
- 3.0.6 — 2023-05-22
- 3.0.5 — 2023-01-21
- 3.0.4 — 2022-10-26
- 3.0.3 — 2022-10-14
- … 12 more at https://npm.io/package/@octoherd/octokit/versions

## README

# `@octoherd/octokit`

> Customized Octokit for Octoherd

## Usage

<table>
<tbody valign=top align=left>
<tr><th>
Browsers
</th><td width=100%>

Load <code>@octoherd/octokit</code> directly from <a href="https://www.skypack.dev">cdn.skypack.dev</a>

```html
<script type="module">
  import { Octokit } from "https://cdn.skypack.dev/@octoherd/octokit";
</script>
```

</td></tr>
<tr><th>
Node (12+)
</th><td>

Install with <code>npm install @octoherd/octokit</code>

```js
import { Octokit } from "@octoherd/octokit";
```

</td></tr>
<tr><th>
Deno
</th><td>

Load <code>@octoherd/octokit</code> directly from <a href="https://www.skypack.dev">cdn.skypack.dev</a> with the `?dts` query

```js
import { Octokit } from "https://cdn.skypack.dev/@octoherd/octokit?dts";
```

</td></tr>
</tbody>
</table>

```js
import { Octokit } from "@octoherd/octokit";

const octokit = new Octokit({
  auth: /* token here, create one at https://github.com/settings/tokens/new */,
});

const { data: me } = await octokit.request("GET /user")
console.log(me)
```

By default you authenticate using a token, but you can use any [authentication strategy](https://github.com/octokit/core.js#authentication).

### REST API requests and GraphQL queries

`@octokit/octokit` is built on [`@octokit/core`](https://github.com/octokit/core.js#readme). You can send requests to GitHub's REST API using [`octokit.request`](https://github.com/octokit/core.js#rest-api-example) and GraphQL queries [`octokit.graphql`](https://github.com/octokit/core.js#graphql-example).

### Logging

By default, messages are logged with meta data using `console.info`, `console.warn`, and `console.error`. `octokit.log.debug` is a no-op, unless `options.octoherd.debug` is set to `true`.

**Important**: `options.log` is ignored. Setting it has no effect.

You can log simple messages, interpolation is supported.

```js
octokit.log.info("Checking repository %s", repository.full_name);
```

You can pass extra meta information as the first argument

```js
octokit.log.info(
  { id: repository.id },
  "Checking repository %s",
  repository.full_name
);
```

You can also just log meta information for reporting later

```js
octokit.log.info({
  id: repository.id,
  owner: repositor.owner.login,
  repo: repository.name,
  private: repository.private,
});
```

The way data is logged can be customized using `options.octoherd.onLogMessage` and `options.octoherd.onLogData`.

```js
const octokit = new Octokit({
  octoherd: {
    onLogData(data) {
      // e.g. write data as JSON line to debug log file
      // data always has `.level`, and `.time` properties. `.msg` is set from the log message if set.
    },
    onLogMessage(level, message, additionalData) {
      // level is one of: debug, info, warn, error.
      // message is the log message
      // additionalData is any data that was passed as first argument to the log methods. It defaults to {}
      console.log(
        `[%s]`,
        level.toUpperCase(),
        Object.keys(additionalData).length
          ? `${message} ${chalk.gray(JSON.stringify(additionalData))}`
          : message
      );
    },
  },
});
```

Additional context can be changed at runtime using `octokit.log.setContext(context)`. The additional context is only passed to `options.octoherd.onLogData`

```js
octokit.log.setContext({ repo_id: 123 });
octokit.log.info("test");
// data passed to `onLogData` will be { repo_id: 123, msg: "test", level: "info", time: 0 }
// additionalData passed to `onLogMessage` will not have the `.repo_id` property
```

### Built-in plugins

`@octoherd/octokit` comes with a few plugins out of the box:

- [`@octokit/plugin-paginate-rest`](https://github.com/octokit/plugin-paginate-rest.js#readme)
- [`@octokit/plugin-retry`](https://github.com/octokit/plugin-retry.js#readme)
- [`@octokit/plugin-throttling`](https://github.com/octokit/plugin-throttling.js#readme)

You can use [`octokit.paginate()`](https://github.com/octokit/plugin-paginate-rest.js#octokitpaginate) or [`octokit.paginate.iterator()`](https://github.com/octokit/plugin-paginate-rest.js#octokitpaginateiterator) for paginating REST API requests.

The retry & throttling plugins hook into the request lifecycle, retries requests in case of unrelated server errors, and throttles requests to avoid hitting rate or abuse limits.

### Extending

You can extend `@octoherd/octokit` with [hooks](https://github.com/octokit/core.js#hooks) and [plugins](https://github.com/octokit/core.js#plugins)

## License

[ISC](LICENSE.md)

---
_Source: https://npm.io/package/@octoherd/octokit · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
