got

v15.0.0 MIT

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

Weekly Downloads
25.7M
Stars
14.9K
Forks
981
Open Issues
0
Gzip Size
48.7 kB
Unpacked Size
340.5 kB
Dependencies
22
Last Updated
3mo ago

got Download Trends

Download trends for got036.4M72.8M109.2M145.7MFeb 2025MayAugNovFebApr 2026
got

About got

Got is a high-level, promise-based HTTP request library designed to simplify making outbound requests in Node.js applications. It addresses the common complexities associated with network requests, such as handling redirects, authentication, error management, and response parsing, by providing a more intuitive and developer-friendly interface compared to the built-in Node.js http modules.

The core philosophy behind got revolves around developer ergonomics and powerful features without sacrificing performance. It aims to be the go-to solution for developers who need a reliable and versatile HTTP client for various tasks, from simple API calls to complex integrations, offering a modern API design that aligns with current JavaScript practices.

Key API patterns include chained methods for building requests, automatic JSON parsing, and robust error handling through specific error classes. It supports features like request cancellation via AbortController, stream handling for large payloads, and advanced options for configuring timeouts, retries, and proxies. The library exposes hooks for request and response interception, allowing for deep customization.

Got integrates seamlessly into modern JavaScript and Node.js workflows. It's commonly used in backend services, CLI tools, and server-rendered applications. Its promise-based nature makes it straightforward to use with async/await syntax, fitting well within frameworks that leverage asynchronous operations like Express.js or NestJS.

With a substantial weekly download count of 33.2 million and a large GitHub star count of 14.9K, got demonstrates significant community adoption and a mature codebase. Its unpacked size of 340.5 kB and gzipped bundle size of 48.7 kB indicate a reasonably optimized package, balancing feature richness with efficient distribution.

While powerful, developers should note that got is an abstraction layer. For extremely low-level control over the HTTP protocol or when targeting environments with very strict module size constraints, a more direct approach using native modules or a specialized, lighter-weight library might be considered. Its comprehensive feature set may also introduce overhead for trivial, single-purpose requests.

When to use

  • When making complex, authenticated API calls that require custom headers, retry logic, and specific error handling.
  • For streaming large response bodies or uploading large request payloads efficiently using its stream support.
  • When leveraging AbortController for request cancellation in long-running operations or race conditions.
  • For automatically parsing JSON responses or handling various content types with built-in decoders.
  • When building CLI tools that need to interact with remote APIs, benefiting from its user-friendly error messages.
  • For implementing custom retry strategies or request/response interception logic using its hook system.

When NOT to use

  • If your sole requirement is to fetch static HTML content without advanced features, a simpler built-in Node.js `fetch` or a minimal HTML parsing library might suffice.
  • For extremely performance-critical, high-frequency requests where every nanosecond counts, consider lower-level abstractions.
  • If you are working in a highly constrained JavaScript environment (e.g., specific browser extensions or embedded systems) where the 48.7 kB (gzip) bundle size is prohibitive.
  • When building a simple web scraper that only needs to retrieve and parse a few pages, a more specialized or lightweight scraping tool might be more appropriate.
  • For scenarios requiring direct access to the underlying TCP socket or network stream manipulation, which got abstracts away.

got Alternatives

got Categories