Awesome
<div align="center"> <br> <br> <img width="360" src="media/logo.svg" alt="Got"> <br> <br> <br> <br> <hr> <p> <p> <sup> Sindre's open source work is supported by the community.<br>Special thanks to: </sup> </p> <br> <br> <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> <br> <br> <br> <br> <a href="https://encore.dev?utm_campaign=github_repo&utm_medium=referral&utm_content=sindre&utm_source=github"> <div> <picture> <source width="230" media="(prefers-color-scheme: dark)" srcset="https://sindresorhus.com/assets/thanks/encore-logo-dark.svg"> <source width="230" media="(prefers-color-scheme: light)" srcset="https://sindresorhus.com/assets/thanks/encore-logo-light.svg"> <img width="230" src="https://sindresorhus.com/assets/thanks/encore-logo-light.svg" alt="Encore logo"> </picture> </div> <b>The development platform for building type-safe distributed systems</b> <div> <sup>End-to-end tooling from local development to automated DevOps and infrastructure in your AWS/GCP.</sup> </div> <br> <br> </a> </p> <hr> <br> <br> <br> <br> <br> <br> <br> </div><!-- [![Coverage Status](https://codecov.io/gh/sindresorhus/got/branch/main/graph/badge.svg)](https://codecov.io/gh/sindresorhus/got/branch/main) -->Human-friendly and powerful HTTP request library for Node.js
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 upon Fetch
.
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 APIsgh-got
- Got convenience wrapper to interact with the GitHub APIgl-got
- Got convenience wrapper to interact with the GitLab APIgotql
- Got convenience wrapper to interact with GraphQL using JSON-parsed queries instead of stringsgot-fetch
- Got with afetch
interfacegot-scraping
- Got wrapper specifically designed for web scraping purposesgot-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 cancelation | :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 | ||||
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.
*** Currently, only DownloadProgress
event is supported, UploadProgress
event is not supported.
¹ 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.
Click here to see the install size of the Got dependencies.
Maintainers
Sindre Sorhus | Szymon Marczak |
<a name="widely-used"></a>
These amazing companies are using Got
<table> <tbody> <tr> <td align="center"> <a href="https://segment.com"> <img width="90" valign="middle" src="https://user-images.githubusercontent.com/697676/47693700-ddb62500-dbb7-11e8-8332-716a91010c2d.png"> </a> </td> <td align="center"> <a href="https://antora.org"> <img width="100" valign="middle" src="https://user-images.githubusercontent.com/79351/47706840-d874cc80-dbef-11e8-87c6-5f0c60cbf5dc.png"> </a> </td> <td align="center"> <a href="https://getvoip.com"> <img width="150" valign="middle" src="https://user-images.githubusercontent.com/10832620/47869404-429e9480-dddd-11e8-8a7a-ca43d7f06020.png"> </a> </td> <td align="center"> <a href="https://github.com/exoframejs/exoframe"> <img width="150" valign="middle" src="https://user-images.githubusercontent.com/365944/47791460-11a95b80-dd1a-11e8-9070-e8f2a215e03a.png"> </a> </td> </tr> <tr> <td align="center"> <a href="http://karaokes.moe"> <img width="140" valign="middle" src="https://karaokes.moe/assets/images/index.png"> </a> </td> <td align="center"> <a href="https://github.com/renovatebot/renovate"> <img width="150" valign="middle" src="https://avatars.githubusercontent.com/u/38656520?s=200&v=4"> </a> </td> <td align="center"> <a href="https://resist.bot"> <img width="150" valign="middle" src="https://user-images.githubusercontent.com/3322287/51992724-28736180-2473-11e9-9764-599cfda4b012.png"> </a> </td> <td align="center"> <a href="https://www.naturalcycles.com"> <img width="150" valign="middle" src="https://user-images.githubusercontent.com/170270/92244143-d0a8a200-eec2-11ea-9fc0-1c07f90b2113.png"> </a> </td> </tr> <tr> <td align="center"> <a href="https://microlink.io"> <img width="150" valign="middle" src="https://user-images.githubusercontent.com/36894700/91992974-1cc5dc00-ed35-11ea-9d04-f58b42ce6a5e.png"> </a> </td> <td align="center"> <a href="https://radity.com"> <img width="150" valign="middle" src="https://user-images.githubusercontent.com/29518613/91814036-97fb9500-ec44-11ea-8c6c-d198cc23ca29.png"> </a> </td> </tr> </tbody> </table> <!-- <br> --> <!-- *Creating an awesome product? Open an issue to get listed here.* --> <br>Segment is a happy user of Got! Got powers the main backend API that our app talks to. It's used by our in-house RPC client that we use to communicate with all microservices.
— <a href="https://github.com/vadimdemedes">Vadim Demedes</a>
Antora, a static site generator for creating documentation sites, uses Got to download the UI bundle. In Antora, the UI bundle (aka theme) is maintained as a separate project. That project exports the UI as a zip file we call the UI bundle. The main site generator downloads that UI from a URL using Got and streams it to vinyl-zip to extract the files. Those files go on to be used to create the HTML pages and supporting assets.
— <a href="https://github.com/mojavelinux">Dan Allen</a>
GetVoIP is happily using Got in production. One of the unique capabilities of Got is the ability to handle Unix sockets which enables us to build a full control interfaces for our docker stack.
— <a href="https://github.com/danielkalen">Daniel Kalen</a>
We're using Got inside of Exoframe to handle all the communication between CLI and server. Exoframe is a self-hosted tool that allows simple one-command deployments using Docker.
— <a href="https://github.com/yamalight">Tim Ermilov</a>
Karaoke Mugen uses Got to fetch content updates from its online server.
— <a href="https://github.com/AxelTerizaki">Axel Terizaki</a>
Renovate uses Got, gh-got and gl-got to send millions of queries per day to GitHub, GitLab, npmjs, PyPi, Packagist, Docker Hub, Terraform, CircleCI, and more.
— <a href="https://github.com/rarkins">Rhys Arkins</a>
Resistbot uses Got to communicate from the API frontend where all correspondence ingresses to the officials lookup database in back.
— <a href="https://github.com/chris-erickson">Chris Erickson</a>
Natural Cycles is using Got to communicate with all kinds of 3rd-party REST APIs (over 9000!).
— <a href="https://github.com/kirillgroshkov">Kirill Groshkov</a>
Microlink is a cloud browser as an API service that uses Got widely as the main HTTP client, serving ~22M requests a month, every time a network call needs to be performed.
— <a href="https://github.com/Kikobeats">Kiko Beats</a>
We’re using Got at Radity. Thanks for such an amazing work!
— <a href="https://github.com/MirzayevFarid">Mirzayev Farid</a>