Ajax for Node.js and browsers (JS HTTP client)
open sourceMITself-hostablefree
SuperAgent is a JavaScript HTTP client with the same chainable API in browsers and in Node.js (superagent.post(url).send(body).set(header)), usable with callbacks, promises or async/await. It handles JSON and form bodies, multipart file attachments, retries, response and deadline timeouts, Basic and Bearer auth, cookie-keeping agents, TLS client certificates, piping and streaming in Node.js, upload and download progress and forced HTTP/2. Plugins add caching, prefixes, mocking, throttling and AWS request signing. TJ Holowaychuk created it in 2011, and it is now maintained for Forward Email and Lad in the forwardemail GitHub organization. It's an alternative to axios, Got and Ky.
Problems it solves
- a chainable request API that works the same in the browser and in Node.js
- upload files as multipart form data from Node.js with extra form fields
- keep a logged-in session's cookies across requests in Node.js tests
- send requests with a client TLS certificate and a custom CA from Node.js
- pipe a large HTTP response straight to a file in Node.js
- set a deadline for the whole request and a separate limit for the first byte
- retry idempotent requests on network errors and 5xx responses
- extend every request with small plugins for caching, URL prefixes or mocking
Features
- same chainable API in browsers and Node.js
- callbacks, promises and async/await
- JSON and URL-encoded bodies
- multipart attachments and fields
- retries for transient failures
- deadline and response timeouts
- Basic and Bearer auth
- agents that keep cookies
- TLS options: CA, client certificate and key, PFX
- piping and streaming in Node.js
View 4 more
- upload and download progress events
- HTTP/2 with .http2()
- maximum response size for buffered bodies
- plugins with .use()
Capabilities
| Has an API | plan not known |
|---|---|
| Takes plugins | plan not known |
Alternatives
The same job
These do what SuperAgent does.
- Got Human-friendly and powerful HTTP request library for Node.js
- axios Promise based HTTP client for the browser and node.js
- undici An HTTP/1.1 client, written from scratch for Node.js
- Ky Tiny & elegant JavaScript HTTP client based on the Fetch API
- node-fetch A light-weight module that brings the Fetch API to Node.js
- ofetch A better fetch API. Works on node, browser, and workers.
