Skip to content
sindresorhusPublic

About

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

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

15.0k stars

Watchers

107 watching

Forks

Latest commit

Β 

History

1,788 Commits

Folders and files

Repository files navigation



Got




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



Fame Helsinki Fame Helsinki



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

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 βœ”οΈ ❌ βœ”οΈ ❌ βœ”οΈ**
Browser support ❌ βœ”οΈ* βœ”οΈ βœ”οΈ βœ”οΈ
Promise API βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ
Stream API βœ”οΈ Node.js only ❌ ❌ βœ”οΈ
Pagination API βœ”οΈ ❌ ❌ ❌ ❌
Request aborting βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ
RFC 7234 caching βœ”οΈ ❌ ❌ ❌ ❌
Cookies (out-of-the-box) βœ”οΈ ❌ ❌ ❌ ❌
Follows redirects βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ
Retries on failure βœ”οΈ ❌ βœ”οΈ ❌ βœ”οΈ
Progress events βœ”οΈ ❌ βœ”οΈ Browser only βœ”οΈ
Handles gzip/deflate βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ
Advanced timeouts βœ”οΈ ❌ ❌ ❌ ❌
Timings βœ”οΈ ❌ ❌ ❌ ❌
Errors with metadata βœ”οΈ ❌ βœ”οΈ βœ”οΈ ❌
JSON mode βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ βœ”οΈ
Custom defaults βœ”οΈ ❌ βœ”οΈ βœ”οΈ ❌
Composable βœ”οΈ ❌ ❌ ❌ βœ”οΈ
Hooks βœ”οΈ ❌ βœ”οΈ βœ”οΈ ❌
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.
❇️ Almost-stable feature, but the API may change. Don't hesitate to try it out!
❔ 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

About

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

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

15.0k stars

Watchers

107 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages