Cette page est affichée en anglais. Une traduction française est en cours.
ConfigsMay 25, 2026·2 min de lecture

Got — Human-Friendly HTTP Client for Node.js

Got is a lightweight, feature-rich HTTP client for Node.js with built-in retry logic, pagination, caching, and hooks for composable request pipelines.

Prêt pour agents

Staging sûr pour cet actif

Cet actif est d'abord staged. Le prompt copié demande à l'agent d'inspecter les fichiers staged avant d'activer scripts, config MCP ou config globale.

Stage only · 27/100Policy : staging
Surface agent
Tout agent MCP/CLI
Type
CLI Tool
Installation
Single
Confiance
Confiance : Established
Point d'entrée
Got Overview
Commande de staging sûr
npx -y tokrepo@latest install 25accf22-5837-11f1-9bc6-00163e2b0d79 --target codex

Stage les fichiers d'abord; l'activation exige la revue du README et du plan staged.

Introduction

Got is a Node.js HTTP client designed as a modern, developer-friendly alternative to the built-in http module. It covers common needs like automatic retries, redirect following, streaming, and JSON parsing with a clean promise-based API.

What Got Does

  • Sends HTTP requests with a simple promise and stream interface
  • Retries failed requests automatically with configurable backoff
  • Follows redirects and handles cookies transparently
  • Supports pagination through built-in link-header traversal
  • Provides lifecycle hooks for request and response transformation

Architecture Overview

Got wraps Node.js native http/https modules and adds a layered middleware pipeline. Each request passes through normalizers, hooks (beforeRequest, afterResponse, beforeRetry), and response handlers. Options cascade from defaults to instance-level to per-request, and the client can be extended with got.extend() to create pre-configured instances.

Self-Hosting & Configuration

  • Install via npm: npm install got
  • ESM-only since v12; use import got from "got"
  • Create custom instances with got.extend({ prefixUrl, headers })
  • Configure retry count, methods, and status codes via the retry option
  • Set timeouts per phase (lookup, connect, socket, response) for fine-grained control

Key Features

  • Automatic retries with exponential backoff on network errors and 5xx responses
  • First-class TypeScript types ship with the package
  • Stream and promise APIs available for every request
  • RFC-compliant caching via a pluggable cache adapter
  • Hooks system enables logging, auth token injection, and response transforms

Comparison with Similar Tools

  • Axios — Works in both browser and Node; Got is Node-only but lighter and ESM-native
  • node-fetch — Minimal Fetch API polyfill; Got adds retries, hooks, and pagination
  • undici — Lower-level HTTP/1.1 client from the Node.js team; faster but less ergonomic
  • ky — Browser-focused Fetch wrapper by the same author; Got is the Node.js counterpart

FAQ

Q: Does Got work in the browser? A: No. Got is Node.js-only. For browsers, use ky or native Fetch.

Q: How do I migrate from Axios to Got? A: Replace axios.get(url) with got(url).json(). Most options map directly; see the migration guide in the repo.

Q: Can I use Got with HTTP/2? A: Yes. Pass http2: true in the options to enable HTTP/2 with automatic ALPN negotiation.

Q: Is Got actively maintained? A: Yes. The project is maintained by Sindre Sorhus and receives regular releases.

Sources

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires