Skip to content

Commit 40ee966

Browse files
feat: set all REST API endpoint methods on octokit.rest.*. The methods are also set on octokit.* for foreseeable time, but no longer documented, and will be deprecated at some point in future (#2054)
1 parent 5350388 commit 40ee966

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1069
-631
lines changed

HOW_IT_WORKS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
## Endpoint options (① - ④)
1717

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+
`@octokit/rest` exposes a method for each [REST API endpoint](https://docs.github.com/en/rest/reference/), for example `octokit.rest.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`.
1919

2020
**② 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.
2121

@@ -24,7 +24,7 @@ Both are merged with **③ user options** passed into each method. Altogether th
2424
**Example**: get all public repositories of the the [@octokit](https://github.com/octokit) GitHub organization.
2525

2626
```js
27-
octokit.repos.listForOrg({ org: "octokit", type: "public" });
27+
octokit.rest.repos.listForOrg({ org: "octokit", type: "public" });
2828
```
2929

3030
**④ endpoint options** will be

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const { Octokit } = require("@octokit/rest");
4040
const octokit = new Octokit();
4141

4242
// Compare: https://docs.github.com/en/rest/reference/repos/#list-organization-repositories
43-
octokit.repos
43+
octokit.rest.repos
4444
.listForOrg({
4545
org: "octokit",
4646
type: "public",
@@ -50,7 +50,7 @@ octokit.repos
5050
});
5151
```
5252

53-
See https://octokit.github.io/rest.js/ for full documentation.
53+
See https://octokit.rest.github.io/rest.js/ for full documentation.
5454

5555
## Contributing
5656

docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Documentation
22

3-
Static documentation website, built with [Gatsby](https://www.gatsbyjs.org/) using [`@octokit/rest`](https://github.com/octokit/rest.js/) and deployed to GitHub Pages: [https://octokit.github.io/rest.js/](https://octokit.github.io/rest.js/)
3+
Static documentation website, built with [Gatsby](https://www.gatsbyjs.org/) using [`@octokit/rest`](https://github.com/octokit/rest.js/) and deployed to GitHub Pages: [https://octokit.rest.github.io/rest.js/](https://octokit.rest.github.io/rest.js/)
44

55
## Local Development
66

docs/src/pages/api/00_usage.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,10 @@ Most of GitHub’s REST API endpoints have matching methods. All endpoint method
107107
(async () => {
108108
```
109109
110-
For example to retrieve a pull request, use [`octokit.pulls.get()`](#octokit-routes-pulls-get). We recommend to use the search above to find the endpoint method you are looking for
110+
For example to retrieve a pull request, use [`octokit.rest.pulls.get()`](#octokit-routes-pulls-get). We recommend to use the search above to find the endpoint method you are looking for
111111
112112
```js
113-
const { data: pullRequest } = await octokit.pulls.get({
113+
const { data: pullRequest } = await octokit.rest.pulls.get({
114114
owner: "octokit",
115115
repo: "rest.js",
116116
pull_number: 123,
@@ -122,7 +122,7 @@ Some API endpoints support alternative response formats, see [Media types](https
122122
Learn more about [request formats](#request-formats-aborts).
123123
124124
```js
125-
const { data: diff } = await octokit.pulls.get({
125+
const { data: diff } = await octokit.rest.pulls.get({
126126
owner: "octokit",
127127
repo: "rest.js",
128128
pull_number: 123,
@@ -160,7 +160,7 @@ Some endpoints return a list which has to be paginated in order to retrieve the
160160
Learn more about [pagination](#pagination).
161161
162162
```js
163-
octokit.paginate(octokit.issues.listForRepo, {
163+
octokit.paginate(octokit.rest.issues.listForRepo, {
164164
owner: 'octokit',
165165
repo: 'rest.js'
166166
})

docs/src/pages/api/02_previews.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Previews can also be enabled for a single request by passing the `mediaType.prev
1616
```js
1717
const {
1818
data: { topics },
19-
} = await octokit.repos.get({
19+
} = await octokit.rest.repos.get({
2020
owner: "octokit",
2121
repo: "rest.js",
2222
mediaType: {

docs/src/pages/api/03_request_formats.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Some API endpoints support alternative response formats, see [Media types](https
77
For example, to request a [pull request as diff format](https://docs.github.com/en/rest/overview/media-types#commits-commit-comparison-and-pull-requests), set the `mediaType.format` option
88

99
```js
10-
const { data: prDiff } = await octokit.pulls.get({
10+
const { data: prDiff } = await octokit.rest.pulls.get({
1111
owner: "octokit",
1212
repo: "rest.js",
1313
pull_number: 1278,
@@ -21,7 +21,7 @@ The [AbortController](https://developer.mozilla.org/en-US/docs/Web/API/AbortCont
2121

2222
```js
2323
const controller = new AbortController();
24-
const { data: prDiff } = await octokit.pulls.get({
24+
const { data: prDiff } = await octokit.rest.pulls.get({
2525
owner: "octokit",
2626
repo: "rest.js",
2727
pull_number: 1278,

docs/src/pages/api/04_custom_requests.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ octokit.request("GET /");
1010

1111
The `baseUrl`, headers and other defaults are already set. For more information on the `octokit.request()` API see [`octokit/request.js`](https://github.com/octokit/request.js/)
1212

13-
All the endpoint methods such as `octokit.repos.get()` are aliases of `octokit.request()` with pre-bound default options. So you can use the `@octokit/request` API to get the default options or get generic request option to use with your preferred request library.
13+
All the endpoint methods such as `octokit.rest.repos.get()` are aliases of `octokit.request()` with pre-bound default options. So you can use the `@octokit/request` API to get the default options or get generic request option to use with your preferred request library.
1414

1515
```js
16-
const defaultOptions = octokit.repos.get.endpoint.DEFAULTS;
17-
const requestOptions = octokit.repos.get.endpoint({
16+
const defaultOptions = octokit.rest.repos.get.endpoint.DEFAULTS;
17+
const requestOptions = octokit.rest.repos.get.endpoint({
1818
owner: "octokit",
1919
repo: "rest.js",
2020
});

docs/src/pages/api/05_pagination.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ octokit
1414
})
1515
.then((issues) => {
1616
// issues is an array of all issue objects. It is not wrapped in a { data, headers, status, url } object
17-
// like results from `octokit.request()` or any of the endpoint methods such as `octokit.issues.listForRepo()`
17+
// like results from `octokit.request()` or any of the endpoint methods such as `octokit.rest.issues.listForRepo()`
1818
});
1919
```
2020

@@ -45,11 +45,11 @@ octokit.paginate("GET /organizations", (response, done) => {
4545
});
4646
```
4747

48-
To paginate responses for one of the registered endpoint methods such as `octokit.issues.listForRepo()` you can pass the method directly as first argument to `octokit.paginate`:
48+
To paginate responses for one of the registered endpoint methods such as `octokit.rest.issues.listForRepo()` you can pass the method directly as first argument to `octokit.paginate`:
4949

5050
```js
5151
octokit
52-
.paginate(octokit.issues.listForRepo, {
52+
.paginate(octokit.rest.issues.listForRepo, {
5353
owner: "octokit",
5454
repo: "rest.js",
5555
})
@@ -62,7 +62,7 @@ If your runtime environment supports async iterators (such as most modern browse
6262

6363
```js
6464
for await (const response of octokit.paginate.iterator(
65-
octokit.issues.listForRepo,
65+
octokit.rest.issues.listForRepo,
6666
{
6767
owner: "octokit",
6868
repo: "rest.js",

docs/src/pages/api/07_custom_endpoints.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function myPlugin(octokit, options) {
4242

4343
---
4444

45-
You can register custom endpoint methods such as `octokit.repos.get()` using the `octokit.registerEndpoints(routes)` method
45+
You can register custom endpoint methods such as `octokit.rest.repos.get()` using the `octokit.registerEndpoints(routes)` method
4646

4747
```js
4848
octokit.registerEndpoints({

0 commit comments

Comments
 (0)