Human-friendly and powerful HTTP request library for Node.js
open sourceMITself-hostablefree
Got is an HTTP request library for Node.js with a promise API and a stream API. It covers what server-side code needs beyond fetch: retries on failure (on by default), timeouts for each phase of a request, a pagination API, RFC 7234 response caching, cookies, HTTP/2, proxies, Unix domain sockets, request timings and errors that carry metadata. Hooks, instances and plugins (such as wrappers for the GitHub and GitLab APIs or AWS-signed requests) build on it, and JSON responses can be validated with a Standard Schema validator. Sindre Sorhus and the same maintainers also make Ky, and Got's README now points most users to Ky, which is smaller and runs in browsers too; Got has migration guides from axios and the old request library.
Problems it solves
- page through a REST API's paginated results in Node.js without writing the loop myself
- cache HTTP responses in Node.js following the Cache-Control headers the server sends
- keep cookies between requests in a Node.js script that logs in to a site
- set separate timeouts for DNS lookup, connect, TLS handshake and the response in Node.js
- measure how long each phase of an outbound HTTP request took
- stream a large download to disk with progress events in Node.js
- send HTTP requests over a Unix domain socket from Node.js
- retry failed requests automatically in a Node.js service, with hooks to refresh tokens
- replace the deprecated request package with something maintained
- make HTTP/2 requests from Node.js code
Features
- promise API and stream API
- retries on failure, on by default
- advanced timeouts per request phase
- pagination API
- RFC 7234 compliant caching
- cookies
- HTTP/2 support
- proxy support and Unix domain sockets
- request timings
- errors with metadata
View 5 more
- hooks, instances and plugins
- progress events
- JSON mode and response validation with Standard Schema
- Diagnostics Channel integration
- migration guides from request, axios and Node.js http
Limitations
- Doesn't run in the browser: it's an HTTP library for Node.js only1
- Doesn't provide a CommonJS export: it's native ESM, so CommonJS projects must convert to ESM1
Capabilities
| Has an API | plan not known |
|---|---|
| Takes plugins | plan not known |
Alternatives
The same job
These do what Got does.
- SuperAgent Ajax for Node.js and browsers (JS HTTP client)
- undici An HTTP/1.1 client, written from scratch for Node.js
- node-fetch A light-weight module that brings the Fetch API to Node.js
- Ky Tiny & elegant JavaScript HTTP client based on the Fetch API
- axios Promise based HTTP client for the browser and node.js
- ofetch A better fetch API. Works on node, browser, and workers.
