got README

The project's README from github.com/sindresorhus/got. As one markdown file: README.md.



Got




Sindre's open source work is supported by the community.
Special thanks to:



Depot logo
Fast remote container builds and GitHub Actions runners.











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>. It also exposes a .json(schema) function that validates the payload with a Standard Schema and infers the type from the schema.

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

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 7234 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
Build
Bugs
Dependents
Install size
GitHub stars
TypeScript support
Last commit

* 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.
: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.

Click here to see the install size of the Got dependencies.

Maintainers

Sindre Sorhus Szymon Marczak
Sindre Sorhus Szymon Marczak

got (sindresorhus/got)

Searching Database…

15K ·GitHub
What is this?Got is a human-friendly and powerful HTTP request library for Node.js, offering a Promise API, streams, pagination, caching, retries, hooks and more.
Is this a framework or just a library I import?It is a library you import into a Node.js project to make HTTP requests, not a standalone app or framework.
How do I add it to a project?Install it as an npm package and import it in your Node.js code; it is a single library, not a service you run separately.
What do I need to use it?You need Node.js 22 or newer, and your project must be ESM since Got no longer ships a CommonJS build.
Any install pitfalls I should know about?Got is now native ESM only with no CommonJS export, so CommonJS projects must convert to ESM; the older v11 branch is unmaintained and won't get backports.
Why pick Got over fetch, axios, or superagent?Got offers things most alternatives lack out of the box: RFC 7234-compliant caching, advanced retries and timeouts, a Pagination API, Unix socket support, and response timing metadata.
What is Ky, and when should I use it instead?Ky is a sibling project by the same author built on the Fetch API. It is smaller, also works in the browser, and is recommended if you don't specifically need Got's Node-only features.
Are there official extensions for specific services?Yes, there are companion packages like gh-got and gl-got for GitHub/GitLab APIs, gotql for GraphQL, got-scraping for web scraping, and got-ssrf to guard against SSRF attacks.
How battle-tested is Got in production?It's used by over 10,000 packages and 5 million repositories, and companies like Segment, Antora, and Renovate rely on it for their backend HTTP traffic.
What are similar projects?ky, requests, guzzle, reqwest, httpx, hyper, pingora, mongoose
Size
4.5 MB
Stars
15K
Age
12y
Commits · 90 Days