2022-01-21 08:28:41 +00:00
# plugin-rest-endpoint-methods.js
> Octokit plugin adding one method for all of api.github.com REST API endpoints
[![@latest ](https://img.shields.io/npm/v/@octokit/plugin-rest-endpoint-methods.svg )](https://www.npmjs.com/package/@octokit/plugin-rest-endpoint-methods)
[![Build Status ](https://github.com/octokit/plugin-rest-endpoint-methods.js/workflows/Test/badge.svg )](https://github.com/octokit/plugin-rest-endpoint-methods.js/actions?workflow=Test)
## Usage
< table >
< tbody valign = top align = left >
< tr > < th >
Browsers
< / th > < td width = 100% >
2023-12-19 14:36:33 +00:00
Load `@octokit/plugin-rest-endpoint-methods` and [`@octokit/core` ](https://github.com/octokit/core.js ) (or core-compatible module) directly from [cdn.skypack.dev ](https://cdn.skypack.dev )
2022-01-21 08:28:41 +00:00
```html
< script type = "module" >
2023-12-19 14:36:33 +00:00
import { Octokit } from "https://cdn.skypack.dev/@octokit/core";
import { restEndpointMethods } from "https://cdn.skypack.dev/@octokit/plugin-rest-endpoint-methods";
2022-01-21 08:28:41 +00:00
< / script >
```
< / td > < / tr >
< tr > < th >
Node
< / th > < td >
Install with `npm install @octokit/core @octokit/plugin-rest-endpoint-methods` . Optionally replace `@octokit/core` with a compatible module
```js
const { Octokit } = require("@octokit/core");
const {
2023-12-19 14:36:33 +00:00
restEndpointMethods,
2022-01-21 08:28:41 +00:00
} = require("@octokit/plugin-rest-endpoint-methods");
```
< / td > < / tr >
< / tbody >
< / table >
```js
const MyOctokit = Octokit.plugin(restEndpointMethods);
const octokit = new MyOctokit({ auth: "secret123" });
// https://developer.github.com/v3/users/#get-the-authenticated-user
2023-12-19 14:36:33 +00:00
octokit.rest.users.getAuthenticated();
```
2022-01-21 08:28:41 +00:00
2023-12-19 14:36:33 +00:00
There is one method for each REST API endpoint documented at [https://developer.github.com/v3 ](https://developer.github.com/v3 ). All endpoint methods are documented in the [docs/ ](docs/ ) folder, e.g. [docs/users/getAuthenticated.md ](docs/users/getAuthenticated.md )
2022-01-21 08:28:41 +00:00
2023-12-19 14:36:33 +00:00
## TypeScript
2022-01-21 08:28:41 +00:00
2023-12-19 14:36:33 +00:00
Parameter and response types for all endpoint methods exported as `{ RestEndpointMethodTypes }` .
2022-01-21 08:28:41 +00:00
2023-12-19 14:36:33 +00:00
Example
2022-01-21 08:28:41 +00:00
2023-12-19 14:36:33 +00:00
```ts
import { RestEndpointMethodTypes } from "@octokit/plugin-rest-endpoint-methods";
2022-01-21 08:28:41 +00:00
2023-12-19 14:36:33 +00:00
type UpdateLabelParameters =
RestEndpointMethodTypes["issues"]["updateLabel"]["parameters"];
type UpdateLabelResponse =
RestEndpointMethodTypes["issues"]["updateLabel"]["response"];
2022-01-21 08:28:41 +00:00
```
2023-12-19 14:36:33 +00:00
In order to get types beyond parameters and responses, check out [`@octokit/openapi-types` ](https://github.com/octokit/openapi-types.ts/#readme ), which is a direct transpilation from GitHub's official OpenAPI specification.
2022-01-21 08:28:41 +00:00
## Contributing
See [CONTRIBUTING.md ](CONTRIBUTING.md )
## License
[MIT ](LICENSE )