MCPcopy
hub / github.com/sindresorhus/got

github.com/sindresorhus/got @v15.1.0 sqlite

repository ↗ · DeepWiki ↗ · release v15.1.0 ↗
505 symbols 1,417 edges 78 files 51 documented · 10%
README
<img width="360" src="https://github.com/sindresorhus/got/raw/v15.1.0/media/logo.svg" alt="Got">












<hr>






        <sup>
            Sindre's open source work is supported by the community.

Special thanks to:

    <a href="https://www.fame.fi#gh-light-mode-only">
        <img src="https://sindresorhus.com/assets/thanks/fame-logo-light.svg" width="200" alt="Fame Helsinki">
    </a>
    <a href="https://www.fame.fi#gh-dark-mode-only">
        <img src="https://sindresorhus.com/assets/thanks/fame-logo-dark.svg" width="200" alt="Fame Helsinki">
    </a>












    <a href="https://depot.dev?utm_source=github&utm_medium=sindresorhus">












                <img width="180" src="https://sindresorhus.com/assets/thanks/depot-logo-light.svg" alt="Depot logo">






        <b>Fast remote container builds and GitHub Actions runners.</b>
    </a>












<hr>

Human-friendly and powerful HTTP request library for Node.js

Downloads Install size

See how Got compares to other HTTP libraries


You probably want Ky instead, by the same people. It's smaller, works in the browser too, and is more stable since it's built on Fetch. Or fetch-extras for simple needs.


Support questions should be asked here.

Install

npm install got

Warning: This package is native ESM and no longer provides a CommonJS export. If your project uses CommonJS, you will have to convert to ESM. Please don't open issues for questions regarding CommonJS / ESM.

Got v11 is no longer maintained and we will not accept any backport requests.

Take a peek

A quick start guide is available.

JSON mode

Got has a dedicated option for handling JSON payload.\ Furthermore, the promise exposes a .json<T>() function that returns Promise<T>.

import got from 'got';

const {data} = await got.post('https://httpbin.org/anything', {
    json: {
        hello: 'world'
    }
}).json();

console.log(data);
//=> {"hello": "world"}

For advanced JSON usage, check out the parseJson and stringifyJson options.

For more useful tips like this, visit the Tips page.

Highlights

Documentation

By default, Got will retry on failure. To disable this option, set options.retry.limit to 0.

Main API

Timeouts and retries

Advanced creation

Cache, Proxy and UNIX sockets

Integration


Migration guides

Got plugins

  • got4aws - Got convenience wrapper to interact with AWS v4 signed APIs
  • gh-got - Got convenience wrapper to interact with the GitHub API
  • gl-got - Got convenience wrapper to interact with the GitLab API
  • gotql - Got convenience wrapper to interact with GraphQL using JSON-parsed queries instead of strings
  • got-fetch - Got with a fetch interface
  • got-scraping - Got wrapper specifically designed for web scraping purposes
  • got-ssrf - Got wrapper to protect server-side requests against SSRF attacks

Comparison

got node-fetch ky axios superagent
HTTP/2 support :heavy_check_mark:¹ :x: :heavy_check_mark: :x: :heavy_check_mark:**
Browser support :x: :heavy_check_mark:* :heavy_check_mark: :heavy_check_mark: :heavy_check_mark:
Promise API :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark:
Stream API :heavy_check_mark: Node.js only :x: :x: :heavy_check_mark:
Pagination API :heavy_check_mark: :x: :x: :x: :x:
Request aborting :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark:
RFC compliant caching :heavy_check_mark: :x: :x: :x: :x:
Cookies (out-of-the-box) :heavy_check_mark: :x: :x: :x: :x:
Follows redirects :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark:
Retries on failure :heavy_check_mark: :x: :heavy_check_mark: :x: :heavy_check_mark:
Progress events :heavy_check_mark: :x: :heavy_check_mark: Browser only :heavy_check_mark:
Handles gzip/deflate :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark:
Advanced timeouts :heavy_check_mark: :x: :x: :x: :x:
Timings :heavy_check_mark: :x: :x: :x: :x:
Errors with metadata :heavy_check_mark: :x: :heavy_check_mark: :heavy_check_mark: :x:
JSON mode :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark:
Custom defaults :heavy_check_mark: :x: :heavy_check_mark: :heavy_check_mark: :x:
Composable :heavy_check_mark: :x: :x: :x: :heavy_check_mark:
Hooks :heavy_check_mark: :x: :heavy_check_mark: :heavy_check_mark: :x:
Issues open
Issues closed
Downloads
Coverage TBD [][n4] [][k4] [][a4] [![][sc]][s4]
Build [![][gb]][g5] [![][nb]][n5] [![][kb]][k5] [![][ab]][a5] [![][sb]][s5]
Bugs [![][gbg]][g6] [![][nbg]][n6] [![][kbg]][k6] [![][abg]][a6] [![][sbg]][s6]
Dependents [![][gdp]][g7] [![][ndp]][n7] [![][kdp]][k7] [![][adp]][a7] [![][sdp]][s7]
Install size [![][gis]][g8] [![][nis]][n8] [![][kis]][k8] [![][ais]][a8] [![][sis]][s8]
GitHub stars [![][gs]][g9] [![][ns]][n9] [![][ks]][k9] [![][as]][a9] [![][ss]][s9]
TypeScript support [![][gts]][g10] [![][nts]][n10] [![][kts]][k10] [![][ats]][a10] [![][sts]][s11]
Last commit [![][glc]][g11] [![][nlc]][n11] [![][klc]][k11] [![][alc]][a11] [![][slc]][s11]

* It's almost API compatible with the browser fetch API.\ ** Need to switch the protocol manually. Doesn't accept PUSH streams and doesn't reuse HTTP/2 sessions.\ ¹ Requires Node.js 15.10.0 or above.\ :sparkle: Almost-stable feature, but the API may change. Don't hesitate to try it out!\ :grey_question: Feature in early stage of development. Very experimental.

Extension points exported contracts — how you extend this code

ClientRequest (Interface)
(no doc)
source/core/timed-out.ts
RequestPromiseShape (Interface)
(no doc)
source/as-promise/types.ts

Core symbols most depended-on inside this repo

get
called by 816
source/core/options.ts
assertAny
called by 54
source/core/options.ts
json
called by 53
source/core/options.ts
has
called by 41
source/core/utils/weakable-map.ts
set
called by 38
source/core/utils/weakable-map.ts
delay
called by 36
test/timer-utils.ts
createHttpTestServer
called by 36
test/helpers/create-http-test-server.ts
write
called by 32
source/core/index.ts

Shape

Function 292
Method 167
Class 44
Interface 2

Languages

TypeScript100%

Modules by API surface

source/core/options.ts126 symbols
source/core/index.ts72 symbols
test/hooks.ts32 symbols
source/core/errors.ts28 symbols
test/redirects.ts16 symbols
documentation/examples/uppercase-headers.js14 symbols
test/pagination.ts13 symbols
source/core/timed-out.ts13 symbols
test/stream.ts11 symbols
test/error.ts11 symbols
source/core/utils/timer.ts10 symbols
test/unix-socket.ts9 symbols

Dependencies from manifests, versioned

@hapi/bourne3.0.0 · 1×
@sindresorhus/is8.0.0 · 1×
@sindresorhus/tsconfig8.1.0 · 1×
@sinonjs/fake-timers15.3.2 · 1×
@types/benchmark2.1.5 · 1×
@types/express5.0.6 · 1×
@types/node25.6.0 · 1×
@types/pem1.14.4 · 1×
@types/readable-stream4.0.23 · 1×
@types/request2.48.13 · 1×
@types/sinon21.0.0 · 1×
@types/sinonjs__fake-timers15.0.1 · 1×

For agents

$ claude mcp add got \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact