{"name":"gh-got","version":"11.0.0","keywords":["got","gh","github","api","request","http","https","get","url","utility"],"author":{"url":"https://sindresorhus.com","name":"Sindre Sorhus","email":"sindresorhus@gmail.com"},"license":"MIT","_id":"gh-got@11.0.0","maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"homepage":"https://github.com/sindresorhus/gh-got#readme","bugs":{"url":"https://github.com/sindresorhus/gh-got/issues"},"dist":{"shasum":"921af93de8df47747d4c4f281204914051a1fd25","tarball":"http://registry-npm.ywwl.com/gh-got/download/gh-got-11.0.0.tgz","fileCount":4,"integrity":"sha512-NvQx9adVzJNYVlTzawHn36ZdEvGTiiYe4nQRzks/Sni80J307KOL6mDN9k5loIxNQRmkM2t8EkRG6oCNcWxjTQ==","signatures":[{"sig":"MEUCIQD7dCKpJTavPFTWeuP+rATU7inDZgTjj4LPNIiuwQYe3AIgF90N6fWhtFhXW5q8igNKLtU2vDTA8XKOOXCx3IQBdyA=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":8233,"size":3462,"noattachment":false,"key":"/gh-got/-/gh-got-11.0.0.tgz"},"type":"module","engines":{"node":">=20"},"exports":"./index.js","funding":"https://github.com/sindresorhus/got?sponsor=1","gitHead":"0909c9995885fdeb4036959fbe33136dd2c64f11","scripts":{"test":"xo && NODE_ENV=test node --test"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"repository":{"url":"git+https://github.com/sindresorhus/gh-got.git","type":"git"},"_npmVersion":"11.6.1","description":"Convenience wrapper for Got to interact with the GitHub API","directories":{},"sideEffects":false,"_nodeVersion":"20.19.5","dependencies":{"got":"^14.6.1"},"_hasShrinkwrap":false,"devDependencies":{"xo":"^1.2.3","nock":"^14.0.10","get-stream":"^9.0.1"},"_npmOperationalInternal":{"tmp":"tmp/gh-got_11.0.0_1762060336905_0.06746706054067353","host":"s3://npm-registry-packages-npm-production"},"readme":"# gh-got\n\n> Convenience wrapper for [Got](https://github.com/sindresorhus/got) to interact with the [GitHub API](https://developer.github.com/v3/)\n\nUnless you're already using Got, you should probably use GitHub's own [@octokit/rest.js](https://github.com/octokit/rest.js) or [@octokit/graphql.js](https://github.com/octokit/graphql.js) packages instead.\n\n## Install\n\n```sh\nnpm install gh-got\n```\n\n## Usage\n\nInstead of:\n\n```js\nimport got from 'got';\n\nconst token = 'foo';\n\nconst {body} = await got('https://api.github.com/users/sindresorhus', {\n\tjson: true,\n\theaders: {\n\t\t'accept': 'application/vnd.github.v3+json',\n\t\t'authorization': `token ${token}`\n\t}\n});\n\nconsole.log(body.login);\n//=> 'sindresorhus'\n```\n\nYou can do:\n\n```js\nimport ghGot from 'gh-got';\n\nconst {body} = await ghGot('users/sindresorhus', {\n\tcontext: {\n\t\ttoken: 'foo'\n\t}\n});\n\nconsole.log(body.login);\n//=> 'sindresorhus'\n```\n\nOr:\n\n```js\nimport ghGot from 'gh-got';\n\nconst {body} = await ghGot('https://api.github.com/users/sindresorhus', {\n\tcontext: {\n\t\ttoken: 'foo'\n\t}\n});\n\nconsole.log(body.login);\n//=> 'sindresorhus'\n```\n\n## API\n\nSame API as [`got`](https://github.com/sindresorhus/got), including options, the stream API, aliases, pagination, etc, but with some additional options below.\n\nErrors are improved by using the custom GitHub error messages. Doesn't apply to the stream API.\n\n### `gh-got` specific options\n\n#### token\n\nType: `string`\n\nGitHub [access token](https://github.com/settings/tokens/new).\n\nCan be set globally with the `GITHUB_TOKEN` environment variable.\n\n#### prefixUrl\n\nType: `string`\\\nDefault: `https://api.github.com/`\n\nTo support [GitHub Enterprise](https://enterprise.github.com).\n\nCan be set globally with the `GITHUB_ENDPOINT` environment variable.\n\n#### body\n\nType: `object`\n\nCan be specified as a plain object and will be serialized as JSON with the appropriate headers set.\n\n## Rate limit\n\nResponses and errors have a `.rateLimit` property with info about the current [rate limit](https://developer.github.com/v3/#rate-limiting). *(This is not yet implemented for the stream API)*\n\n```js\nimport ghGot from 'gh-got';\n\nconst {rateLimit} = await ghGot('users/sindresorhus');\n\nconsole.log(rateLimit);\n//=> {limit: 5000, remaining: 4899, reset: [Date 2018-12-31T20:45:20.000Z]}\n```\n\n## Authorization\n\nAuthorization for GitHub uses the following logic:\n\n1. If `options.headers.authorization` is passed to `gh-got`, then this will be used as first preference.\n2. If `options.token` is provided, then the `authorization` header will be set to `token <options.token>`.\n3. If `options.headers.authorization` and `options.token` are not provided, then the `authorization` header will be set to `token <process.env.GITHUB_TOKEN>`\n\nIn most cases, this means you can simply set `GITHUB_TOKEN`, but it also allows it to be overridden by setting `options.token` or `options.headers.authorization` explicitly. For example, if [authenticating as a GitHub App](https://developer.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app), you could do the following:\n\n```js\nimport ghGot from 'gh-got';\n\nconst options = {\n\theaders: {\n\t\tauthorization: `Bearer ${jwt}`\n\t}\n};\nconst {body} = await ghGot('app', options);\n\nconsole.log(body.name);\n//=> 'MyApp'\n```\n\n## Pagination\n\nSee the [Got docs](https://github.com/sindresorhus/got/blob/main/documentation/4-pagination.md).\n","publish_time":1762060337105,"_cnpm_publish_time":1762060337105,"dist-tags":{"latest":"12.0.0"}}