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 install superagent
yarn add superagent
pnpm add superagent
Import
import superagent from 'superagent';
Quick Example
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
| Package | superagent |
| Category | HTTP |
| Weekly Downloads | 8M+ |
| License | MIT |
| Install | npm install superagent |
Related Packages
Axios is a promise-based HTTP client for the browser and Node.js that provides an elegant and powerf…
Got is a human-friendly and powerful HTTP request library for Node.js that provides an extensive fea…
Node-fetch is a lightweight module that brings the browser's Fetch API to Node.js, providing a famil…
SuperTest is a high-level HTTP assertion library built on SuperAgent that makes it easy to test Node…
Ky is a tiny and elegant HTTP client based on the browser Fetch API, providing a more convenient API…
Browse npm Packages by Category
Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.