Gathering detailed insights and metrics for @octokit-next/core
Gathering detailed insights and metrics for @octokit-next/core
Gathering detailed insights and metrics for @octokit-next/core
Gathering detailed insights and metrics for @octokit-next/core
npm install @octokit-next/core
Typescript
Module System
Node Version
NPM Version
73.2
Supply Chain
91.8
Quality
78.3
Maintenance
100
Vulnerability
99.6
License
JavaScript (79.48%)
TypeScript (20.52%)
Total Downloads
13,040
Last Day
5
Last Week
298
Last Month
494
Last Year
2,601
MIT License
24 Stars
302 Commits
3 Forks
8 Watchers
5 Branches
17 Contributors
Updated on May 20, 2025
Minified
Minified + Gzipped
Latest Version
3.0.0
Package Id
@octokit-next/core@3.0.0
Unpacked Size
56.53 kB
Size
13.60 kB
File Count
21
NPM Version
10.9.2
Node Version
22.15.0
Published on
May 20, 2025
Cumulative downloads
Total Downloads
Last Day
25%
5
Compared to previous day
Last Week
405.1%
298
Compared to previous week
Last Month
52%
494
Compared to previous month
Last Year
-47.4%
2,601
Compared to previous year
Extendable client for GitHub's REST & GraphQL APIs
If you need a minimalistic library to utilize GitHub's REST API and GraphQL API which you can extend with plugins as needed, then @octokit-next/core
is a great starting point.
If you don't need the Plugin API then using @octokit-next/request
or @octokit-next/graphql
directly is a good alternative.
Browsers |
Load @octokit-next/core directly from cdn.skypack.dev
|
---|---|
Node |
Install with
|
Deno |
Load
|
1// Create a personal access token at https://github.com/settings/tokens/new?scopes=repo
2const octokit = new Octokit({ auth: `personal-access-token123` });
3
4const response = await octokit.request("GET /orgs/{org}/repos", {
5 org: "octokit",
6 type: "private",
7});
See @octokit-next/request
for full documentation of the .request
method.
1const octokit = new Octokit({ auth: `secret123` }); 2 3const response = await octokit.graphql( 4 `query ($login: String!) { 5 organization(login: $login) { 6 repositories(privacy: PRIVATE) { 7 totalCount 8 } 9 } 10 }`, 11 { login: "octokit" } 12);
See @octokit-next/graphql
for full documentation of the .graphql
method.
name | type | description |
---|---|---|
options.authStrategy
|
Function |
Defaults to @octokit-next/auth-token . See Authentication below for examples.
|
options.auth
|
String or Object
| See Authentication below for examples. |
options.baseUrl
|
String
|
When using with GitHub Enterprise Server, set
|
options.previews
|
Array of Strings
|
Some REST API endpoints require preview headers to be set, or enable additional features. Preview headers can be set on a per-request basis, e.g.
You can also set previews globally, by setting the
|
options.request
|
Object
|
Set a default request timeout ( There are more |
options.timeZone
|
String
|
Sets the
The time zone header will determine the timezone used for generating the timestamp when creating commits. See GitHub's Timezones documentation. |
options.userAgent
|
String
|
A custom user agent string for your app or library. Example
|
You can create a new Octokit class with customized default options.
1const MyOctokit = Octokit.withDefaults({
2 auth: "personal-access-token123",
3 baseUrl: "https://github.acme-inc.com/api/v3",
4 userAgent: "my-app/v1.2.3",
5});
6const octokit1 = new MyOctokit();
7const octokit2 = new MyOctokit();
If you pass additional options to your new constructor, the options will be merged shallowly.
1const MyOctokit = Octokit.withDefaults({
2 foo: {
3 opt1: 1,
4 },
5});
6const octokit = new MyOctokit({
7 foo: {
8 opt2: 1,
9 },
10});
11// options will be { foo: { opt2: 1 }}
If you need a deep or conditional merge, you can pass a function instead.
1const MyOctokit = Octokit.withDefaults((options) => {
2 return {
3 foo: Object.assign({}, options.foo, { opt1: 1 }),
4 };
5});
6const octokit = new MyOctokit({
7 foo: { opt2: 1 },
8});
9// options will be { foo: { opt1: 1, opt2: 1 }}
Be careful about mutating the options
object in the Octokit.withDefaults
callback, as it can have unforeseen consequences.
Authentication is optional for some REST API endpoints accessing public data, but is required for GraphQL queries. Using authentication also increases your API rate limit.
By default, Octokit authenticates using the token authentication strategy. Pass in a token using options.auth
. It can be a personal access token, an OAuth token, an installation access token or a JSON Web Token for GitHub App authentication. The Authorization
header will be set according to the type of token.
1import { Octokit } from "@octokit-next/core"; 2 3const octokit = new Octokit({ 4 auth: "mypersonalaccesstoken123", 5}); 6 7const { data } = await octokit.request("/user");
To use a different authentication strategy, set options.authStrategy
. A list of authentication strategies is available at octokit-next/authentication-strategies.js.
Example
1import { Octokit } from "@octokit-next/core"; 2import { createAppAuth } from "@octokit-next/auth-app"; 3 4const appOctokit = new Octokit({ 5 authStrategy: createAppAuth, 6 auth: { 7 appId: 123, 8 privateKey: process.env.PRIVATE_KEY, 9 }, 10}); 11 12const { data } = await appOctokit.request("/app");
The .auth()
method returned by the current authentication strategy can be accessed at octokit.auth()
. Example
1const { token } = await appOctokit.auth({ 2 type: "installation", 3 installationId: 123, 4});
There are four built-in log methods
octokit.log.debug(message[, additionalInfo])
octokit.log.info(message[, additionalInfo])
octokit.log.warn(message[, additionalInfo])
octokit.log.error(message[, additionalInfo])
They can be configured using the log
client option. By default, octokit.log.debug()
and octokit.log.info()
are no-ops, while the other two call console.warn()
and console.error()
respectively.
This is useful if you build reusable plugins.
If you would like to make the log level configurable using an environment variable or external option, we recommend the console-log-level package. Example
1const octokit = new Octokit({ 2 log: require("console-log-level")({ level: "info" }), 3});
You can customize Octokit's request lifecycle with hooks.
1octokit.hook.before("request", async (options) => { 2 validate(options); 3}); 4octokit.hook.after("request", async (response, options) => { 5 console.log(`${options.method} ${options.url}: ${response.status}`); 6}); 7octokit.hook.error("request", async (error, options) => { 8 if (error.status === 304) { 9 return findInCache(error.response.headers.etag); 10 } 11 12 throw error; 13}); 14octokit.hook.wrap("request", async (request, options) => { 15 // add logic before, after, catch errors or replace the request altogether 16 return request(options); 17});
See before-after-hook for more documentation on hooks.
Octokit’s functionality can be extended using plugins. The Octokit.withPlugins()
method accepts a plugin (or many) and returns a new constructor.
A plugin is a function which gets two arguments:
In order to extend octokit
's API, the plugin must return an object with the new methods.
1// index.js 2const { Octokit } = require("@octokit-next/core") 3const MyOctokit = Octokit.withPlugins([ 4 require("./lib/my-plugin"), 5 require("octokit-plugin-example") 6] 7); 8 9const octokit = new MyOctokit({ greeting: "Moin moin" }); 10octokit.helloWorld(); // logs "Moin moin, world!" 11octokit.request("GET /"); // logs "GET / - 200 in 123ms" 12 13// lib/my-plugin.js 14module.exports = (octokit, options = { greeting: "Hello" }) => { 15 // hook into the request lifecycle 16 octokit.hook.wrap("request", async (request, options) => { 17 const time = Date.now(); 18 const response = await request(options); 19 console.log( 20 `${options.method} ${options.url} – ${response.status} in ${Date.now() - 21 time}ms` 22 ); 23 return response; 24 }); 25 26 // add a custom method 27 return { 28 helloWorld: () => console.log(`${options.greeting}, world!`); 29 } 30};
You can build your own Octokit class with preset default options and plugins. In fact, this is mostly how the @octokit-next/<context>
modules work, such as @octokit-next/action
:
1const { Octokit } = require("@octokit-next/core"); 2const MyActionOctokit = Octokit.withPlugins([ 3 require("@octokit-next/plugin-paginate-rest").paginateRest, 4 require("@octokit-next/plugin-throttling").throttling, 5 require("@octokit-next/plugin-retry").retry, 6]).withDefaults({ 7 throttle: { 8 onAbuseLimit: (retryAfter, options) => { 9 /* ... */ 10 }, 11 onRateLimit: (retryAfter, options) => { 12 /* ... */ 13 }, 14 }, 15 authStrategy: require("@octokit-next/auth-action").createActionAuth, 16 userAgent: `my-octokit-action/v1.2.3`, 17}); 18 19const octokit = new MyActionOctokit(); 20const installations = await octokit.paginate("GET /app/installations");
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
15 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
packaging workflow detected
Details
Reason
SAST tool is run on all commits
Details
Reason
0 existing vulnerabilities detected
Reason
security policy file detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 2
Details
Reason
Found 1/28 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Score
Last Scanned on 2025-05-12
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More