🌐
HTTP8M+/wkMIT

superagent

SuperAgent is a progressive HTTP request library for Node.js and the browser that provides a flexible and readable chaining API for making HTTP requests. Origin

Installation

npm
npm install superagent
yarn
yarn add superagent
pnpm
pnpm add superagent

Import

ESM
import superagent from 'superagent';

Quick Example

usage
const res = await superagent
  .get('https://api.example.com/users')
  .set('Authorization', 'Bearer token')
  .query({ page: 1 });

console.log(res.body);

About superagent

SuperAgent is a progressive HTTP request library for Node.js and the browser that provides a flexible and readable chaining API for making HTTP requests. Originally created in 2011, SuperAgent was one of the first JavaScript HTTP libraries to offer a fluent API where methods like .set(), .query(), .send(), and .type() are chained to build requests incrementally. The library supports multipart form data uploads, automatic content type detection and parsing, redirect following with configurable limits, TLS/SSL certificate options, and HTTP authentication. SuperAgent handles cookies, allows attaching files to requests, and supports both callback and promise-based patterns. The library works in both browser and Node.js environments with the same API, making it useful for isomorphic applications. SuperAgent includes built-in support for retrying failed requests, setting timeouts, and piping responses to writable streams. While newer libraries like Axios and Got have surpassed SuperAgent in popularity, it remains widely used in legacy codebases and is the HTTP client used internally by the SuperTest testing library for API endpoint testing.

Quick Facts

Packagesuperagent
CategoryHTTP
Weekly Downloads8M+
LicenseMIT
Installnpm install superagent

Related Packages

Browse npm Packages by Category

Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.