7,875
stars
+0+2+19
1,286
forks
181
watchers
1,567
prs
1,023
issues
73
releases
–
discussions
README
octokit.js
The all-batteries-included GitHub SDK for Browsers, Node.js, and Deno.
The octokit package integrates the three main Octokit libraries
1. API client (REST API requests, GraphQL API queries, Authentication)
2. App client (GitHub App & installations, Webhooks, OAuth)
3. Action client (Pre-authenticated API client for single repository)
Table of contents
- octokit.js
- Features
- Usage
- Octokit API Client
- Constructor options
- Authentication
- Proxy Servers (Node.js only)
- Fetch missing
- REST API
- octokit.rest endpoint methods
- octokit.request()
- Pagination
- Media Type formats
- Request error handling
- GraphQL API queries
- Pagination
- Schema previews
- App client
- GitHub App
- Webhooks
- OAuth
- App Server
- OAuth for browser apps
- Action client
- LICENSE
Features
- Complete. All features of GitHub's platform APIs are covered.
- Prescriptive. All recommended best practices are implemented.
- Universal. Works in all modern browsers, Node.js, and Deno.
- Tested. All libraries have a 100% test coverage.
- Typed. All libraries have extensive TypeScript declarations.
- Decomposable. Use only the code you need. You can build your own Octokit in only a few lines of code or use the underlying static methods. Make your own tradeoff between functionality and bundle size.
- Extendable. A feature missing? Add functionalities with plugins, hook into the request or webhook lifecycle or implement your own authentication strategy.
Usage
Browsers
Load octokit directly from esm.sh
html
import { Octokit, App } from "https://esm.sh/octokit";
Deno
Load octokit directly from esm.sh
ts
import { Octokit, App } from "https://esm.sh/octokit?dts";
Node
Install with npm/pnpm install octokit, or yarn add octokit
js
import { Octokit, App } from "octokit";
[!IMPORTANT]
As we use conditional exports, you will need to adapt your tsconfig.json by setting "moduleResolution": "node16", "module": "node16".
See the TypeScript docs on package.json "exports".
See this helpful guide on transitioning to ESM from @sindresorhus
Octokit API Client
standalone minimal Octokit: @octokit/core.
The Octokit client can be used to send requests to GitHub's REST API and queries to GitHub's GraphQL API.
Example: Get the username for the authenticated user.
js
// Create a personal access token at https://github.com/settings/tokens/new?scopes=repo
const octokit = new Octokit({ auth: personal-access-token123 });
// Compare: https://docs.github.com/en/rest/reference/usersget-the-authenticated-user
const {
data: { login },
} = await octokit.rest.users.getAuthenticated();
console.log("Hello, %s", login);
Constructor options
The most commonly used options are
name
type
description
userAgent