Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/octokit/plugin-rest-endpoint-methods.js
Octokit plugin adding one method for all of api.github.com REST API endpoints
https://github.com/octokit/plugin-rest-endpoint-methods.js
hacktoberfest octokit-js plugin rest-api
Last synced: 4 days ago
JSON representation
Octokit plugin adding one method for all of api.github.com REST API endpoints
- Host: GitHub
- URL: https://github.com/octokit/plugin-rest-endpoint-methods.js
- Owner: octokit
- License: mit
- Created: 2019-11-11T01:45:23.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2024-10-29T07:57:51.000Z (6 days ago)
- Last Synced: 2024-10-29T13:02:14.434Z (5 days ago)
- Topics: hacktoberfest, octokit-js, plugin, rest-api
- Language: TypeScript
- Homepage:
- Size: 10.8 MB
- Stars: 115
- Watchers: 13
- Forks: 55
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
# 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
Browsers
Load `@octokit/plugin-rest-endpoint-methods` and [`@octokit/core`](https://github.com/octokit/core.js) (or core-compatible module) directly from [esm.sh](https://esm.sh)
```html
import { Octokit } from "https://esm.sh/@octokit/core";
import { restEndpointMethods } from "https://esm.sh/@octokit/plugin-rest-endpoint-methods";```
Node
Install with `npm install @octokit/core @octokit/plugin-rest-endpoint-methods`. Optionally replace `@octokit/core` with a compatible module
```js
import { Octokit } from "@octokit/core";
import { restEndpointMethods } from "@octokit/plugin-rest-endpoint-methods";
``````js
const MyOctokit = Octokit.plugin(restEndpointMethods);
const octokit = new MyOctokit({ auth: "secret123" });// https://developer.github.com/v3/users/#get-the-authenticated-user
octokit.rest.users.getAuthenticated();
```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)
## TypeScript
> [!IMPORTANT]
> As we use [conditional exports](https://nodejs.org/api/packages.html#conditional-exports), you will need to adapt your `tsconfig.json` by setting `"moduleResolution": "node16", "module": "node16"`.
>
> See the TypeScript docs on [package.json "exports"](https://www.typescriptlang.org/docs/handbook/modules/reference.html#packagejson-exports).
> See this [helpful guide on transitioning to ESM](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c) from [@sindresorhus](https://github.com/sindresorhus)Parameter and response types for all endpoint methods exported as `{ RestEndpointMethodTypes }`.
Example
```ts
import { RestEndpointMethodTypes } from "@octokit/plugin-rest-endpoint-methods";type UpdateLabelParameters =
RestEndpointMethodTypes["issues"]["updateLabel"]["parameters"];
type UpdateLabelResponse =
RestEndpointMethodTypes["issues"]["updateLabel"]["response"];
```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.
## Contributing
See [CONTRIBUTING.md](CONTRIBUTING.md)
## License
[MIT](LICENSE)