got
Human-friendly HTTP requests for Node.js — a powerful fetch alternative with retry, pagination, caching, and hooks built in.
got
General JSHuman-friendly HTTP requests for Node.js — a powerful fetch alternative with retry, pagination, caching, and hooks built in.
Fit
Bundle (gzip)
46.5 kB
152.2 kB raw
Install size includes transitive dependencies. Bundle size is gzipped browser payload.
Freshness
The Problem
Node.js's built-in fetch and the http module lack retry logic, request hooks, pagination helpers, and response caching. Building these on top of bare fetch requires significant wrapper code.
What It Does
Got provides a feature-rich HTTP client for Node.js: automatic retry with exponential backoff, request/response hooks for auth and logging, built-in pagination for cursor/page-based APIs, response caching, and detailed timing metrics. The extend() API creates pre-configured instances for different services.
Installation
npm install gotUsage Example
import got from 'got';
// Create a pre-configured instance for your API
const api = got.extend({
prefixUrl: 'https://api.example.com',
headers: { Authorization: `Bearer ${token}` },
retry: { limit: 3, statusCodes: [429, 503] },
});
const user = await api.get('users/123').json<User>();
// Paginate through all results automatically
for await (const user of api.paginate<User>('users', {
pagination: { paginate: ({ currentItems, nextPageUrl }) => nextPageUrl ? { url: nextPageUrl } : false },
})) {
process(user);
}Related packages
Unified TypeScript SDK for building AI-powered apps — switch between 20+ LLM providers without rewriting code.
animejsGeneral JSLightweight JavaScript animation library with a tiny footprint and a powerful, expressive API.
AOSGeneral JSAn easy-to-use library that makes elements fade, slide, or zoom into view as the user scrolls down your page.
archiverGeneral JSStreaming interface for generating ZIP and TAR archives in Node.js — create compressed archives programmatically from files, directories, and buffers.
@formkit/auto-animateGeneral JS> Add smooth transitions to any element with a single line — zero-config animations for adds, removes, and moves.