{"id":18383,"library":"gh-got","title":"gh-got","description":"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.","status":"active","version":"12.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/sindresorhus/gh-got","tags":["javascript","got","gh","github","api","request","http","https","get"],"install":[{"cmd":"npm install gh-got","lang":"bash","label":"npm"},{"cmd":"yarn add gh-got","lang":"bash","label":"yarn"},{"cmd":"pnpm add gh-got","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core HTTP client used for requests","package":"got","optional":false}],"imports":[{"note":"Package is pure ESM since v10; CommonJS require() will throw an error.","wrong":"const ghGot = require('gh-got')","symbol":"ghGot","correct":"import ghGot from 'gh-got'"},{"note":"gh-got has a default export only, not a named export.","wrong":"import { ghGot } from 'gh-got'","symbol":"ghGot","correct":"import ghGot from 'gh-got'"},{"note":"rateLimit is a property on the response object with { limit, remaining, reset }. Not available in stream API.","wrong":"","symbol":"response.rateLimit","correct":"const { rateLimit } = await ghGot('users/sindresorhus')"}],"quickstart":{"code":"import ghGot from 'gh-got';\n\nasync function main() {\n  try {\n    const { body, rateLimit } = await ghGot('users/sindresorhus', {\n      context: {\n        token: process.env.GITHUB_TOKEN ?? ''\n      }\n    });\n    console.log(body.login);\n    console.log('Rate limit remaining:', rateLimit.remaining);\n  } catch (error) {\n    console.error('GitHub API error:', error.message);\n  }\n}\n\nmain();","lang":"javascript","description":"Demonstrates basic usage: import default, authenticate via token context, handle response and rate limit info."},"warnings":[{"fix":"Use import syntax instead of require(); update Node.js to >=14 (v12 requires Node.js 22).","message":"Starting from v10, package is pure ESM and requires Node.js 14+.","severity":"breaking","affected_versions":">=10.0.0"},{"fix":"Remove leading slash: use 'users' instead of '/users'.","message":"In v10, leading slashes in paths no longer work (e.g., '/users' fails).","severity":"breaking","affected_versions":">=10.0.0"},{"fix":"Replace 'endpoint' with 'baseUrl' in options.","message":"v9 renamed the 'endpoint' option to 'baseUrl'.","severity":"breaking","affected_versions":">=9.0.0"},{"fix":"Upgrade Node.js to >=22.","message":"v12 requires Node.js 22 and updates Got to v15.","severity":"breaking","affected_versions":">=12.0.0"},{"fix":"Consider migrating to official GitHub SDKs for better features and support.","message":"Package recommends using @octokit/rest.js or @octokit/graphql.js instead unless already using Got.","severity":"deprecated","affected_versions":">=10.0.0"},{"fix":"Set token via context.token or GITHUB_TOKEN env var. Use options.headers.authorization for non-token auth (e.g., Bearer JWT).","message":"Authorization order: options.headers.authorization takes precedence over options.token, which falls back to GITHUB_TOKEN env var.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use import statement instead of require(), or update Node.js to >=14 and use dynamic import.","cause":"CommonJS require() called on ES module package.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module not supported"},{"fix":"Ensure prefixUrl ends with trailing slash, e.g., 'https://api.github.com/'.","cause":"Invalid prefixUrl provided (e.g., missing trailing slash).","error":"GotError: The prefix 'https://api.github.com/' must start with a valid URL prefix"},{"fix":"Set GITHUB_TOKEN environment variable or pass token in options.context.token.","cause":"Missing or invalid GitHub token.","error":"HTTPError: Response code 401 (Unauthorized)"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}