Gathering detailed insights and metrics for @octokit/endpoint
Gathering detailed insights and metrics for @octokit/endpoint
Gathering detailed insights and metrics for @octokit/endpoint
Gathering detailed insights and metrics for @octokit/endpoint
@octokit/plugin-rest-endpoint-methods
Octokit plugin adding one method for all of api.github.com REST API endpoints
@octokit/plugin-paginate-rest
Octokit plugin to paginate REST API endpoint responses
@octokit/plugin-paginate-graphql
Octokit plugin to paginate GraphQL API endpoint responses
@octokit-next/endpoint
Turns REST API endpoints into generic request options
Turns REST API endpoints into generic request options
npm install @octokit/endpoint
Typescript
Module System
Min. Node Version
Node Version
NPM Version
99.3
Supply Chain
99.5
Quality
87.5
Maintenance
100
Vulnerability
100
License
TypeScript (95.01%)
JavaScript (4.99%)
Total Downloads
1,679,034,013
Last Day
2,352,036
Last Week
13,245,688
Last Month
53,923,328
Last Year
538,749,715
MIT License
60 Stars
718 Commits
26 Forks
10 Watchers
14 Branches
29 Contributors
Updated on May 20, 2025
Latest Version
11.0.0
Package Id
@octokit/endpoint@11.0.0
Unpacked Size
58.02 kB
Size
13.62 kB
File Count
35
NPM Version
10.8.1
Node Version
22.15.0
Published on
May 20, 2025
Cumulative downloads
Total Downloads
Last Day
4.7%
2,352,036
Compared to previous day
Last Week
5.4%
13,245,688
Compared to previous week
Last Month
1.4%
53,923,328
Compared to previous month
Last Year
35.3%
538,749,715
Compared to previous year
Turns GitHub REST API endpoints into generic request options
@octokit/endpoint
combines GitHub REST API routes with your parameters and turns them into generic request options that can be used in any request library.
Browsers |
Load @octokit/endpoint directly from esm.sh
|
---|---|
Node |
Install with
|
Example for List organization repositories
1const requestOptions = endpoint("GET /orgs/{org}/repos", { 2 headers: { 3 authorization: "token 0000000000000000000000000000000000000001", 4 }, 5 org: "octokit", 6 type: "private", 7});
The resulting requestOptions
looks as follows
1{ 2 "method": "GET", 3 "url": "https://api.github.com/orgs/octokit/repos?type=private", 4 "headers": { 5 "accept": "application/vnd.github.v3+json", 6 "authorization": "token 0000000000000000000000000000000000000001", 7 "user-agent": "octokit/endpoint.js v1.2.3" 8 } 9}
You can pass requestOptions
to common request libraries
1const { url, ...options } = requestOptions; 2// using with fetch (https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) 3fetch(url, options); 4// using with request (https://github.com/request/request) 5request(requestOptions); 6// using with got (https://github.com/sindresorhus/got) 7got[options.method](url, options); 8// using with axios 9axios(requestOptions);
[!IMPORTANT] As we use conditional exports, you will need to adapt your
tsconfig.json
. See the TypeScript docs on package.json "exports".
endpoint(route, options)
or endpoint(options)
name | type | description |
---|---|---|
route
| String |
If set, it has to be a string consisting of URL and the request method, e.g., GET /orgs/{org} . If it’s set to a URL, only the method defaults to GET .
|
options.method
| String |
Required unless route is set. Any supported http verb. Defaults to GET .
|
options.url
| String |
Required unless route is set. A path or full URL which may contain :variable or {variable} placeholders,
e.g., /orgs/{org}/repos . The url is parsed using url-template.
|
options.baseUrl
| String |
Defaults to https://api.github.com .
|
options.headers
| Object |
Custom headers. Passed headers are merged with defaults:headers['user-agent'] defaults to octokit-endpoint.js/1.2.3 (where 1.2.3 is the released version).headers['accept'] defaults to application/vnd.github.v3+json . |
options.mediaType.format
| String |
Media type param, such as raw , diff , or text+json . See Media Types. Setting options.mediaType.format will amend the headers.accept value.
|
options.data
| Any |
Set request body directly instead of setting it to JSON based on additional parameters. See "The data parameter" below.
|
options.request
| Object |
Pass custom meta information for the request. The request object will be returned as is.
|
All other options will be passed depending on the method
and url
options.
url
, it will be used as the replacement. For example, if the passed options are {url: '/orgs/{org}/repos', org: 'foo'}
the returned options.url
is https://api.github.com/orgs/foo/repos
.method
is GET
or HEAD
, the option is passed as a query parameter.Result
endpoint()
is a synchronous method and returns an object with the following keys:
key | type | description |
---|---|---|
method | String | The http method. Always lowercase. |
url | String | The url with placeholders replaced with passed parameters. |
headers | Object | All header names are lowercased. |
body | Any | The request body if one is present. Only for PATCH , POST , PUT , DELETE requests. |
request | Object | Request meta option, it will be returned as it was passed into endpoint() |
endpoint.defaults()
Override or set default options. Example:
1const request = require("request"); 2const myEndpoint = require("@octokit/endpoint").defaults({ 3 baseUrl: "https://github-enterprise.acme-inc.com/api/v3", 4 headers: { 5 "user-agent": "myApp/1.2.3", 6 authorization: `token 0000000000000000000000000000000000000001`, 7 }, 8 org: "my-project", 9 per_page: 100, 10}); 11 12request(myEndpoint(`GET /orgs/{org}/repos`));
You can call .defaults()
again on the returned method, the defaults will cascade.
1const myProjectEndpoint = endpoint.defaults({ 2 baseUrl: "https://github-enterprise.acme-inc.com/api/v3", 3 headers: { 4 "user-agent": "myApp/1.2.3", 5 }, 6 org: "my-project", 7}); 8const myProjectEndpointWithAuth = myProjectEndpoint.defaults({ 9 headers: { 10 authorization: `token 0000000000000000000000000000000000000001`, 11 }, 12});
myProjectEndpointWithAuth
now defaults the baseUrl
, headers['user-agent']
,
org
and headers['authorization']
on top of headers['accept']
that is set
by the global default.
endpoint.DEFAULTS
The current default options.
1endpoint.DEFAULTS.baseUrl; // https://api.github.com 2const myEndpoint = endpoint.defaults({ 3 baseUrl: "https://github-enterprise.acme-inc.com/api/v3", 4}); 5myEndpoint.DEFAULTS.baseUrl; // https://github-enterprise.acme-inc.com/api/v3
endpoint.merge(route, options)
or endpoint.merge(options)
Get the defaulted endpoint options, but without parsing them into request options:
1const myProjectEndpoint = endpoint.defaults({ 2 baseUrl: "https://github-enterprise.acme-inc.com/api/v3", 3 headers: { 4 "user-agent": "myApp/1.2.3", 5 }, 6 org: "my-project", 7}); 8myProjectEndpoint.merge("GET /orgs/{org}/repos", { 9 headers: { 10 authorization: `token 0000000000000000000000000000000000000001`, 11 }, 12 org: "my-secret-project", 13 type: "private", 14}); 15 16// { 17// baseUrl: 'https://github-enterprise.acme-inc.com/api/v3', 18// method: 'GET', 19// url: '/orgs/{org}/repos', 20// headers: { 21// accept: 'application/vnd.github.v3+json', 22// authorization: `token 0000000000000000000000000000000000000001`, 23// 'user-agent': 'myApp/1.2.3' 24// }, 25// org: 'my-secret-project', 26// type: 'private' 27// }
endpoint.parse()
Stateless method to turn endpoint options into request options. Calling
endpoint(options)
is the same as calling endpoint.parse(endpoint.merge(options))
.
data
parameter – set request body directlySome endpoints such as Render a Markdown document in raw mode don’t have parameters that are sent as request body keys, instead, the request body needs to be set directly. In these cases, set the data
parameter.
1const options = endpoint("POST /markdown/raw", { 2 data: "Hello world github/linguist#1 **cool**, and #1!", 3 headers: { 4 accept: "text/html;charset=utf-8", 5 "content-type": "text/plain", 6 }, 7}); 8 9// options is 10// { 11// method: 'post', 12// url: 'https://api.github.com/markdown/raw', 13// headers: { 14// accept: 'text/html;charset=utf-8', 15// 'content-type': 'text/plain', 16// 'user-agent': userAgent 17// }, 18// body: 'Hello world github/linguist#1 **cool**, and #1!' 19// }
There are API endpoints that accept both query parameters as well as a body. In that case, you need to add the query parameters as templates to options.url
, as defined in the RFC 6570 URI Template specification.
Example
1endpoint( 2 "POST https://uploads.github.com/repos/octocat/Hello-World/releases/1/assets{?name,label}", 3 { 4 name: "example.zip", 5 label: "short description", 6 headers: { 7 "content-type": "text/plain", 8 "content-length": 14, 9 authorization: `token 0000000000000000000000000000000000000001`, 10 }, 11 data: "Hello, world!", 12 }, 13);
5.3/10
Summary
@octokit/endpoint has a Regular Expression in parse that Leads to ReDoS Vulnerability Due to Catastrophic Backtracking
Affected Versions
>= 10.0.0, < 10.1.3
Patched Versions
10.1.3
5.3/10
Summary
@octokit/endpoint has a Regular Expression in parse that Leads to ReDoS Vulnerability Due to Catastrophic Backtracking
Affected Versions
>= 9.0.5, < 9.0.6
Patched Versions
9.0.6
Reason
no dangerous workflow patterns detected
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
security policy file detected
Details
Reason
Found 6/7 approved changesets -- score normalized to 8
Reason
9 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 7
Reason
dependency not pinned by hash detected -- score normalized to 4
Details
Reason
6 existing vulnerabilities detected
Details
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