You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* style: prettier
* refactor: update URLs to new website: https://docs.github.com/rest/
* build(package): apply prettier to all `*.md` files in root folder
Copy file name to clipboardExpand all lines: HOW_IT_WORKS.md
+17-13
Original file line number
Diff line number
Diff line change
@@ -12,9 +12,10 @@
12
12
4.[Hooks ⑤ & ⑨](#request)
13
13
14
14
<aname="endpoint-options"></a>
15
+
15
16
## Endpoint options (① - ④)
16
17
17
-
`@octokit/rest` exposes a method for each [REST API endpoint](https://developer.github.com/v3/), for example `octokit.repos.listForOrg()` for [`GET /orgs/:org/repos`](https://developer.github.com/v3/repos/#list-organization-repositories). The methods are generated in [`@octokit/plugin-rest-endpoint-methods`](https://github.com/octokit/plugin-rest-endpoint-methods.js/). The [`src/generated/endpoints.ts` file](https://github.com/octokit/plugin-rest-endpoint-methods.js/blob/master/src/generated/endpoints.ts) defines the **② endpoint default options**`method`, `url`, and in some cases `mediaType` and `headers`.
18
+
`@octokit/rest` exposes a method for each [REST API endpoint](https://docs.github.com/en/rest/reference/), for example `octokit.repos.listForOrg()` for [`GET /orgs/:org/repos`](https://docs.github.com/en/rest/reference/repos/#list-organization-repositories). The methods are generated in [`@octokit/plugin-rest-endpoint-methods`](https://github.com/octokit/plugin-rest-endpoint-methods.js/). The [`src/generated/endpoints.ts` file](https://github.com/octokit/plugin-rest-endpoint-methods.js/blob/master/src/generated/endpoints.ts) defines the **② endpoint default options**`method`, `url`, and in some cases `mediaType` and `headers`.
18
19
19
20
**② endpoint default options** are merged with **① global defaults**, which are based on [@octokit/endpoint/src/defaults.ts](https://github.com/octokit/endpoint.js/blob/master/src/defaults.ts) and the options that were passed into the `new Octokit(options)` constructor.
20
21
@@ -23,7 +24,7 @@ Both are merged with **③ user options** passed into each method. Altogether th
23
24
**Example**: get all public repositories of the the [@octokit](https://github.com/octokit) GitHub organization.
**④ Endpoint options** are **⑥ transformed** into **⑦ request options** using [@octokit/endpoint](https://github.com/octokit/endpoint.js).
@@ -101,34 +103,36 @@ For example, the endpoint options shown above would result in
101
103
</table>
102
104
103
105
<aname="request"></a>
106
+
104
107
## Sending a request & receiving a response ⑧ & ⑩
105
108
106
109
Using **⑦ request options**, a **⑧ request** is sent to the GitHub REST API. The **⑩ response** is returned to the user.
107
110
108
111
Requests are sent using [`@octokit/request`](https://github.com/octokit/request.js). It's using the native fetch method in the browsers and [node-fetch](https://github.com/bitinn/node-fetch) in other environments.
109
112
110
113
<aname="hooks"></a>
114
+
111
115
## Hooks ⑤ & ⑨
112
116
113
117
Hooks are used to inject functionality like authentication. For example, the [request log plugin](https://github.com/octokit/plugin-request-log.js) is registering a request hook in [src/index.ts](https://github.com/octokit/plugin-request-log.js/blob/e8308e36e049946a0b1813b8b25aa28d4a6c8789/src/index.ts#L9-L35). A debug message is logged before sending the request, and an info message is logged once a response is received.
114
118
115
119
Hooks can be registered using `octokit.hook.{before|after|error|wrap}`:
The methods can return a Promise for asynchronous execution. `options` can be changed in the `octokit.hook.before` callback before they are **⑥ transformed**. The **⑩ response** can be changed in the `octokit.hook.after` callback before it is returned to the user. `octokit.hook.wrap` allows to do both, or replace the original request method altogether with a custom request method.
Copy file name to clipboardExpand all lines: docs/src/pages/api/00_usage.md
+4-4
Original file line number
Diff line number
Diff line change
@@ -49,7 +49,7 @@ Learn more about [authentication](#authentication).
49
49
auth:"secret123",
50
50
```
51
51
52
-
Setting a user agent [is required](https://developer.github.com/v3/#user-agent-required). It defaults to `octokit/rest.js v1.2.3` where `v1.2.3` is the current version of `@octokit/rest`, but you should set it to something that identifies your app or script.
52
+
Setting a user agent [is required](https://docs.github.com/en/rest/overview/resources-in-the-rest-api#user-agent-required). It defaults to `octokit/rest.js v1.2.3` where `v1.2.3` is the current version of `@octokit/rest`, but you should set it to something that identifies your app or script.
53
53
54
54
```js
55
55
userAgent:'myApp v1.2.3',
@@ -69,7 +69,7 @@ A default time zone can be enabled by setting the `timeZone` option.
69
69
timeZone:'Europe/Amsterdam',
70
70
```
71
71
72
-
Learn more about [using time zones with the GitHub API](https://developer.github.com/v3/#using-the-time-zone-header).
72
+
Learn more about [using time zones with the GitHub API](https://docs.github.com/en/rest/overview/resources-in-the-rest-api#timezones).
73
73
74
74
In order to use Octokit with GitHub Enterprise, set the `baseUrl` option.
Some API endpoints support alternative response formats, see [Media types](https://developer.github.com/v3/media/). For example, to [request the above pull request in a diff format](https://developer.github.com/v3/media/#diff), pass the `mediaType.format` option.
120
+
Some API endpoints support alternative response formats, see [Media types](https://docs.github.com/en/rest/overview/media-types). For example, to [request the above pull request in a diff format]((https://docs.github.com/en/rest/overview/media-types/#diff), pass the `mediaType.format` option.
121
121
122
122
Learn more about [request formats](#request-formats).
For the API endpoints that do not have a matching method, such as the [root endpoint](https://developer.github.com/v3/#root-endpoint) or legacy endpoints, you can send custom requests.
135
+
For the API endpoints that do not have a matching method, such as the [root endpoint](https://docs.github.com/en/rest/overview/resources-in-the-rest-api#root-endpoint) or legacy endpoints, you can send custom requests.
136
136
137
137
Learn more about [custom requests](#custom-requests).
Copy file name to clipboardExpand all lines: docs/src/pages/api/01_authentication.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
title: "Authentication"
3
3
---
4
4
5
-
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](https://developer.github.com/v3/#rate-limiting).
5
+
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](https://docs.github.com/en/rest/overview/resources-in-the-rest-api#rate-limiting).
6
6
7
7
By default, Octokit authenticates using the [token authentication strategy](https://github.com/octokit/auth-token.js). 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.
Copy file name to clipboardExpand all lines: docs/src/pages/api/05_pagination.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
title: "Pagination"
3
3
---
4
4
5
-
All endpoint methods starting with `.list*` do not return all results at once but instead return the first 30 items by default, see also [GitHub’s REST API pagination documentation](https://developer.github.com/v3/#pagination).
5
+
All endpoint methods starting with `.list*` do not return all results at once but instead return the first 30 items by default, see also [GitHub’s REST API pagination documentation](https://docs.github.com/en/rest/overview/resources-in-the-rest-api#pagination).
6
6
7
7
To automatically receive all results across all pages, you can use the `octokit.paginate()` method:
8
8
@@ -20,7 +20,7 @@ octokit
20
20
21
21
`octokit.paginate()` accepts the same options as [`octokit.request()`](#custom-requests). You can optionally pass an additional function to map the results from each response. The map must return a new value, usually an array with mapped data.
22
22
23
-
**Note:** the map function is called with the `{ data, headers, status, url }` response object. The `data` property is guaranteed to be an array of the result items, even for list endpoints that respond with an object instead of an array, such as the [search endpoints](https://developer.github.com/v3/search/#example).
23
+
**Note:** the map function is called with the `{ data, headers, status, url }` response object. The `data` property is guaranteed to be an array of the result items, even for list endpoints that respond with an object instead of an array, such as the [search endpoints](https://docs.github.com/en/rest/reference/search/#example).
Copy file name to clipboardExpand all lines: docs/src/pages/api/09_throttling.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ title: "Throttling"
4
4
5
5
When you send too many requests in too little time you will likely hit errors due to rate and/or abuse limits.
6
6
7
-
In order to automatically throttle requests as recommended in [GitHub’s best practices for integrators](https://developer.github.com/v3/guides/best-practices-for-integrators/), we recommend you install the [`@octokit/plugin-throttling` plugin](https://github.com/octokit/plugin-throttling.js).
7
+
In order to automatically throttle requests as recommended in [GitHub’s best practices for integrators](https://docs.github.com/en/rest/reference/guides/best-practices-for-integrators/), we recommend you install the [`@octokit/plugin-throttling` plugin](https://github.com/octokit/plugin-throttling.js).
8
8
9
9
The `throttle.onAbuseLimit` and `throttle.onRateLimit` options are required.
0 commit comments