Registry / http-networking / gh-got

gh-got

JSON →
library12.0.0jsnpmunverified

Convenience wrapper for Got to interact with the GitHub API. Current stable version is 12.0.0 (requires Node.js 22). Release cadence is irregular with major versions often tied to Got updates. Key differentiators: automatic token handling via GITHUB_TOKEN env var, built-in rate limit info on responses/errors, supports GitHub Enterprise via prefixUrl. Pure ESM since v10, uses Got 15 internally. Consider @octokit/rest.js or @octokit/graphql.js unless already using Got.

npm install gh-got
INSTALL
IMPORT
SIG · GH-GOT
G
gh-got
http-networkingjavascriptv12.0.0
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ghGot
✓ import ghGot from 'gh-got'
✗ const ghGot = require('gh-got')
Package is pure ESM since v10; CommonJS require() will throw an error.
ghGot
✓ import ghGot from 'gh-got'
✗ import { ghGot } from 'gh-got'
gh-got has a default export only, not a named export.
response.rateLimit
✓ const { rateLimit } = await ghGot('users/sindresorhus')
rateLimit is a property on the response object with { limit, remaining, reset }. Not available in stream API.

Demonstrates basic usage: import default, authenticate via token context, handle response and rate limit info.

import ghGot from 'gh-got'; async function main() { try { const { body, rateLimit } = await ghGot('users/sindresorhus', { context: { token: process.env.GITHUB_TOKEN ?? '' } }); console.log(body.login); console.log('Rate limit remaining:', rateLimit.remaining); } catch (error) { console.error('GitHub API error:', error.message); } } main();
gh-got --version
Debug
Known issues
breakingStarting from v10, package is pure ESM and requires Node.js 14+.
fix
Use import syntax instead of require(); update Node.js to >=14 (v12 requires Node.js 22).
affects: >=10.0.0
breakingIn v10, leading slashes in paths no longer work (e.g., '/users' fails).
fix
Remove leading slash: use 'users' instead of '/users'.
affects: >=10.0.0
breakingv9 renamed the 'endpoint' option to 'baseUrl'.
fix
Replace 'endpoint' with 'baseUrl' in options.
affects: >=9.0.0
breakingv12 requires Node.js 22 and updates Got to v15.
fix
Upgrade Node.js to >=22.
affects: >=12.0.0
deprecatedPackage recommends using @octokit/rest.js or @octokit/graphql.js instead unless already using Got.
fix
Consider migrating to official GitHub SDKs for better features and support.
affects: >=10.0.0
gotchaAuthorization order: options.headers.authorization takes precedence over options.token, which falls back to GITHUB_TOKEN env var.
fix
Set token via context.token or GITHUB_TOKEN env var. Use options.headers.authorization for non-token auth (e.g., Bearer JWT).
affects: *
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module not supported
CommonJS require() called on ES module package.
fix
Use import statement instead of require(), or update Node.js to >=14 and use dynamic import.
GotError: The prefix 'https://api.github.com/' must start with a valid URL prefix
Invalid prefixUrl provided (e.g., missing trailing slash).
fix
Ensure prefixUrl ends with trailing slash, e.g., 'https://api.github.com/'.
HTTPError: Response code 401 (Unauthorized)
Missing or invalid GitHub token.
fix
Set GITHUB_TOKEN environment variable or pass token in options.context.token.
Upgrade
Version history
12.0.0latest on npm
Audit
Dependencies
gotrequiredCore HTTP client used for requests
Agent activity
40 hits · last 30 days
node
34
OpenAI (training)
1
Resources
gh-got — npm install gh-got · libregistry