# JavaScript HTTP libraries

JavaScript HTTP libraries send requests to web servers and read their responses in Node.js, browsers, and edge runtimes. A client library wraps each request in an API with defaults for retries, timeouts, and parsed response bodies. These libraries let apps, backend services, and AI agents call external APIs through one configured client.

## Popularity

| Library | Monthly downloads | Stars | Last release | License |
| --- | --- | --- | --- | --- |
| [Undici](#undici) | 1.3B | 7.7K | Nov 2026 | MIT |
| [node-fetch](#node-fetch) | 1.1B | 8.8K | Jul 2023 | MIT |
| [Gaxios](#gaxios) | 597.4M | 3.2K | Nov 2026 | Apache-2.0 |
| [Axios](#axios) | 563.5M | 109.4K | Nov 2026 | MIT |
| [Got](#got) | 205.1M | 15.0K | Oct 2026 | MIT |
| [make-fetch-happen](#make-fetch-happen) | 149.2M | 208 | May 2026 | ISC |
| [SuperAgent](#superagent) | 126.0M | 16.6K | Nov 2026 | MIT |
| [ofetch](#ofetch) | 105.7M | 5.4K | Nov 2025 | MIT |

Downloads: npm, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

[Undici](#undici) has the most monthly downloads in this comparison, at 1.1B.

## Capabilities

| Library | Native retry API | Browser runtime | Throws on HTTP errors by default |
| --- | --- | --- | --- |
| [Undici](#undici) | Yes | No | No |
| [node-fetch](#node-fetch) | No | No | No |
| [Gaxios](#gaxios) | Yes | Yes | Yes |
| [Axios](#axios) | No | Yes | Yes |
| [Got](#got) | Yes | No | Yes |
| [make-fetch-happen](#make-fetch-happen) | Yes | No | No |
| [SuperAgent](#superagent) | Yes | Yes | Yes |
| [ofetch](#ofetch) | Yes | Yes | Yes |

## Libraries

### Undici

[GitHub](https://github.com/nodejs/undici) · [npm](https://www.npmjs.com/package/undici) · [Docs](https://raw.githubusercontent.com/nodejs/undici/main/README.md)

Provides Node HTTP requests, streaming, and configurable dispatchers.

- Downloads / mo: 1.3B
- Stars: 7.7K
- Last release: 8.12.4
- License: MIT
- Capabilities: [From the Undici docs](https://raw.githubusercontent.com/nodejs/undici/main/README.md)

**Strengths**

- **Exposes lower-level request APIs.** Use request and stream APIs alongside the Fetch interface.
- **Adds retries through dispatchers.** Wrap a dispatcher with RetryAgent to apply retry behavior.

**Watch out for**

- **Response bodies need cleanup.** Consume or cancel response bodies to release connection resources.
- **CORS checks are absent.** Server code must enforce its own cross-origin access policy.

```sh
npm install undici
```

**nodejs/node-gyp** (10.7K stars)

[nodejs/node-gyp](https://github.com/nodejs/node-gyp) 

```javascript
async function createDispatcher (gyp) {
  const env = process.env
  const hasProxyEnv = env.http_proxy || env.HTTP_PROXY || env.https_proxy || env.HTTPS_PROXY
  if (!gyp.opts.proxy && !gyp.opts.cafile && !hasProxyEnv) {
    return new RetryAgent(new Agent(), { maxRetries: 3 })
  }

  const opts = {}
  if (gyp.opts.cafile) {
    const ca = await readCAFile(gyp.opts.cafile)
    // EnvHttpProxyAgent forwards opts to both its internal Agent (direct) and
    // ProxyAgent (proxied). Agent reads TLS config from `connect`; ProxyAgent
    // reads it from `requestTls` (origin) / `proxyTls` (proxy). Set all three
    // so the custom CA is applied regardless of which path a request takes.
    opts.connect = { ca }
    opts.requestTls = { ca }
    opts.proxyTls = { ca }
  }
  if (gyp.opts.proxy) {
    opts.httpProxy = gyp.opts.proxy
    opts.httpsProxy = gyp.opts.proxy
  }
  if (gyp.opts.noproxy) {
    opts.noProxy = gyp.opts.noproxy
  }
  return new RetryAgent(new EnvHttpProxyAgent(opts), { maxRetries: 3 })
}
```

[lib/download.js](https://github.com/nodejs/node-gyp/blob/ff3896c031202411409341ba2d3489bd61d11675/lib/download.js#L47-L73) · [More projects using Undici →](https://dashboard.exa.ai/playground/search?q=JavaScript%20projects%20that%20use%20undici&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```javascript
import { fetch } from 'undici';

const response = await fetch('https://example.com');
console.log(await response.text());

```

From [README.md](https://raw.githubusercontent.com/nodejs/undici/main/README.md)

### node-fetch

[GitHub](https://github.com/node-fetch/node-fetch) · [npm](https://www.npmjs.com/package/node-fetch) · [Docs](https://raw.githubusercontent.com/node-fetch/node-fetch/v3.3.2/README.md)

Brings the Fetch API to Node.js as a standalone module.

- Downloads / mo: 1.1B
- Stars: 8.8K
- Last release: 3.3.2
- License: MIT
- Capabilities: [From the node-fetch docs](https://raw.githubusercontent.com/node-fetch/node-fetch/v3.3.2/README.md)

```sh
npm install node-fetch
```

**sindresorhus/p-retry** (1.0K stars)

[sindresorhus/p-retry](https://github.com/sindresorhus/p-retry) 

```javascript
async () => {
	const response = await fetch('https://sindresorhus.com/unicorn');

	// Abort retrying if the resource doesn't exist
	if (response.status === 404) {
		throw new AbortError(response.statusText);
	}

	return response.blob();
}
```

[readme.md](https://github.com/sindresorhus/p-retry/blob/285fdc3f890a6f3d199b3d4abb0bad7c172c2233/readme.md#L19-L28) · [More projects using node-fetch →](https://dashboard.exa.ai/playground/search?q=node-fetch%20GitHub%20projects)

**Quickstart**

```javascript
import fetch from 'node-fetch';

const response = await fetch('https://github.com/');
const body = await response.text();

console.log(body);

```

From [README.md](https://raw.githubusercontent.com/node-fetch/node-fetch/v3.3.2/README.md)

### Gaxios

[GitHub](https://github.com/googleapis/google-cloud-node) · [npm](https://www.npmjs.com/package/gaxios) · [Docs](https://github.com/googleapis/google-cloud-node/blob/main/core/packages/gaxios/README.md)

Provides a common HTTP client for Google APIs and services.

- Downloads / mo: 597.4M
- Stars: 3.2K
- Last release: 8.3.3
- License: Apache-2.0
- Capabilities: [From the Gaxios docs](https://github.com/googleapis/google-cloud-node/blob/main/core/packages/gaxios/README.md)

```sh
npm install gaxios
```

**googleapis/google-auth-library-nodejs** (1.9K stars)

[googleapis/google-auth-library-nodejs](https://github.com/googleapis/google-auth-library-nodejs) 

```javascript
request<T>(opts: GaxiosOptions): GaxiosPromise<T> {
    // ensure the user isn't passing in request-style options
    opts = this.configure(opts);
    validate(opts);
    return this.instance.request<T>(opts).catch(e => {
      throw this.processError(e);
    });
  }
```

[src/transporters.ts](https://github.com/googleapis/google-auth-library-nodejs/blob/69be99032c05997adab5be81bf0f17ae2fe25676/src/transporters.ts#L85-L92) · [More projects using Gaxios →](https://dashboard.exa.ai/playground/search?q=gaxios%20GitHub%20projects)

**Quickstart**

```javascript
import {request} from 'gaxios';
const res = await request({url: 'https://google.com/'});

```

From [README.md](https://github.com/googleapis/google-cloud-node/blob/main/core/packages/gaxios/README.md)

### Axios

[GitHub](https://github.com/axios/axios) · [npm](https://www.npmjs.com/package/axios) · [Docs](https://raw.githubusercontent.com/axios/axios/v1.21.1/README.md)

Makes HTTP requests through browser and server adapters.

- Downloads / mo: 563.5M
- Stars: 109.4K
- Last release: 1.21.1
- License: MIT
- Capabilities: [From the Axios docs](https://raw.githubusercontent.com/axios/axios/v1.21.1/README.md)

**Strengths**

- **Centralizes request and response handling.** Attach interceptors to shared client instances.
- **Supports request cancellation.** Cancel in-flight requests with an AbortController signal.

**Watch out for**

- **Requests need an explicit timeout.** Configure a timeout so stalled requests cannot wait indefinitely.

```sh
npm install axios
```

**Quickstart**

```javascript
import axios from 'axios';

const response = await axios.get('https://httpbin.org/get');
console.log(response.data);

```

From [README.md](https://raw.githubusercontent.com/axios/axios/v1.21.1/README.md) · [Find projects using Axios →](https://dashboard.exa.ai/playground/search?q=JavaScript%20projects%20that%20use%20axios&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

### Got

[GitHub](https://github.com/sindresorhus/got) · [npm](https://www.npmjs.com/package/got) · [Docs](https://raw.githubusercontent.com/sindresorhus/got/v16.2.0/readme.md)

Provides HTTP requests, retries, and streaming APIs for Node applications.

- Downloads / mo: 205.1M
- Stars: 15.0K
- Last release: 16.2.0
- License: MIT
- Capabilities: [From the Got docs](https://raw.githubusercontent.com/sindresorhus/got/v16.2.0/readme.md)

**Strengths**

- **Retries failed requests by default.** Use built-in retry configuration to handle eligible request failures.
- **Provides a streaming request API.** Pipe request or response data through the streaming API.

**Watch out for**

- **Requires native ESM imports.** CommonJS projects need an ESM integration path.
- **Timeouts need explicit configuration.** Set a timeout to bound requests instead of waiting indefinitely.

```sh
npm install got
```

**sindresorhus/package-json** (250 stars)

[sindresorhus/package-json](https://github.com/sindresorhus/package-json) 

```javascript
export default async function packageJson(packageName, options) {
	options = {
		version: 'latest',
		...options,
	};

	const scope = packageName.split('/')[0];
	const registryUrl_ = options.registryUrl || registryUrl(scope);
	const packageUrl = new URL(encodeURIComponent(packageName).replace(/^%40/, '@'), registryUrl_);
	const authInfo = registryAuthToken(registryUrl_.toString(), {recursive: true});

	const headers = {
		accept: 'application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*',
	};

	if (options.fullMetadata) {
		delete headers.accept;
	}

	if (authInfo) {
		headers.authorization = `${authInfo.type} ${authInfo.token}`;
	}

	const gotOptions = {
		headers,
		agent: {
			http: httpAgent,
			https: httpsAgent,
		},
	};

	if (options.agent) {
		gotOptions.agent = options.agent;
	}

	let data;
	try {
		data = await got(packageUrl, gotOptions).json();
	} catch (error) {
		if (error?.response?.statusCode === 404) {
			throw new PackageNotFoundError(packageName);
		}

		throw error;
	}

	if (options.allVersions) {
		return data;
	}

	let {version} = options;
	const versionError = new VersionNotFoundError(packageName, version);

	if (data['dist-tags'][version]) {
		const time = data.time;
		data = data.versions[data['dist-tags'][version]];
		data.time = time;
	} else if (version) {
		if (!data.versions[version]) {
			const versions = Object.keys(data.versions);
			version = semver.maxSatisfying(versions, version);

			if (!version) {
				throw versionError;
			}
		}

		const time = data.time;
		data = data.versions[version];
		data.time = time;

		if (!data) {
			throw versionError;
		}
	}

	return data;
}
```

[index.js](https://github.com/sindresorhus/package-json/blob/0b9859ad8c814782d62cdedd8227787589f798d5/index.js#L32-L109) · [More projects using Got →](https://dashboard.exa.ai/playground/search?q=JavaScript%20projects%20that%20use%20got&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```javascript
import got from 'got';

const {data} = await got.post('https://httpbin.org/anything', {
	json: {
		hello: 'world'
	}
}).json();

console.log(data);
//=> {"hello": "world"}

```

From [readme.md](https://raw.githubusercontent.com/sindresorhus/got/v16.2.0/readme.md)

### make-fetch-happen

[GitHub](https://github.com/npm/make-fetch-happen) · [npm](https://www.npmjs.com/package/make-fetch-happen) · [Docs](https://raw.githubusercontent.com/npm/make-fetch-happen/v16.0.1/README.md)

Provides a fetch client with built-in caching and retries.

- Downloads / mo: 149.2M
- Stars: 208
- Last release: 16.0.1
- License: ISC
- Capabilities: [From the make-fetch-happen docs](https://raw.githubusercontent.com/npm/make-fetch-happen/v16.0.1/README.md)

```sh
npm install --save make-fetch-happen
```

**nodejs/node-gyp** (10.7K stars)

[nodejs/node-gyp](https://github.com/nodejs/node-gyp) 

```javascript
async function download (gyp, url) {
  log.http('GET', url)

  const requestOpts = {
    headers: {
      'User-Agent': `node-gyp v${gyp.version} (node ${process.version})`,
      Connection: 'keep-alive'
    },
    proxy: gyp.opts.proxy,
    noProxy: gyp.opts.noproxy
  }

  const cafile = gyp.opts.cafile
  if (cafile) {
    requestOpts.ca = await readCAFile(cafile)
  }

  const res = await fetch(url, requestOpts)
  log.http(res.status, res.url)

  return res
}
```

[lib/download.js](https://github.com/nodejs/node-gyp/blob/08c91d08adfcf1f24e7ff3e14b454da27bb6be25/lib/download.js#L5-L26) · [More projects using make-fetch-happen →](https://dashboard.exa.ai/playground/search?q=make-fetch-happen%20GitHub%20projects)

**Quickstart**

```javascript
const fetch = require('make-fetch-happen');

fetch('https://example.com')
  .then(response => response.text())
  .then(console.log);

```

From [README.md](https://raw.githubusercontent.com/npm/make-fetch-happen/v16.0.1/README.md)

### SuperAgent

[GitHub](https://github.com/forwardemail/superagent) · [npm](https://www.npmjs.com/package/superagent) · [Docs](https://raw.githubusercontent.com/forwardemail/superagent/v10.4.2/docs/index.md)

Sends HTTP requests from browsers and Node.js through a fluent API.

- Downloads / mo: 126.0M
- Stars: 16.6K
- Last release: 10.4.2
- License: MIT
- Capabilities: [From the SuperAgent docs](https://raw.githubusercontent.com/forwardemail/superagent/v10.4.2/docs/index.md)

```sh
npm install superagent
```

**forwardemail/supertest** (14.4K stars)

[forwardemail/supertest](https://github.com/forwardemail/supertest) 

```javascript
constructor (app, method, path, optHttp2) {
    super(method.toUpperCase(), path);

    if (typeof app === 'function') {
      if (optHttp2) {
        app = http2.createServer(app); // eslint-disable-line no-param-reassign
      } else {
        app = http.createServer(app); // eslint-disable-line no-param-reassign
      }
    }

    this.redirects(0);
    this.buffer();
    this.app = app;
    this._asserts = [];
    this.url = typeof app === 'string'
      ? app + path
      : this.serverAddress(app, path);
  }
```

[lib/test.js](https://github.com/forwardemail/supertest/blob/aff97e7c8eed2ff88d650f6b451f04a321790f88/lib/test.js#L146-L164) · [More projects using SuperAgent →](https://dashboard.exa.ai/playground/search?q=superagent%20GitHub%20projects)

**Quickstart**

```javascript
const request = require('superagent');

request.get('https://httpbin.org/get')
  .then(response => console.log(response.body));

```

From [index.md](https://raw.githubusercontent.com/forwardemail/superagent/v10.4.2/docs/index.md)

### ofetch

[GitHub](https://github.com/unjs/ofetch) · [npm](https://www.npmjs.com/package/ofetch) · [Docs](https://app.unpkg.com/ofetch@1.5.1/files/README.md)

Extends the Fetch API for Node.js, browsers, and workers.

- Downloads / mo: 105.7M
- Stars: 5.4K
- Last release: 1.5.1
- License: MIT
- Capabilities: [From the ofetch docs](https://app.unpkg.com/ofetch@1.5.1/files/README.md)

```sh
npm i ofetch
```

**unjs/ipx** (2.5K stars)

[unjs/ipx](https://github.com/unjs/ipx) 

```javascript
async getData(id) {
      const url = validateId(id);
      const response = await ofetch(url, {
        ...fetchOptions,
        method: "GET",
        responseType: "arrayBuffer",
      });
      return response;
    }
```

[src/storage/http.ts](https://github.com/unjs/ipx/blob/36537bc1395854a57a34ab6aeecb5debfcb02ae1/src/storage/http.ts#L98-L106) · [More projects using ofetch →](https://dashboard.exa.ai/playground/search?q=ofetch%20GitHub%20projects)

**Quickstart**

```javascript
import { ofetch } from 'ofetch';

const html = await ofetch('https://example.com');
console.log(html);

```

From [README.md](https://app.unpkg.com/ofetch@1.5.1/files/README.md)

## FAQ

### Which JavaScript HTTP library should I use?

[Axios](#axios) suits apps that run in browsers and Node.js and want shared interceptors. [Undici](#undici) suits Node.js servers that need control over connections and streams. [ofetch](#ofetch) suits code built on fetch that wants retries and parsed responses.

### Axios vs fetch: which should I use?

Fetch is built into browsers and Node.js and needs no install. [Axios](#axios) adds interceptors, request cancellation, and errors thrown for failed HTTP statuses.

### How do I retry failed requests with Axios?

Axios has no built-in retry API. Retries come from an extension package or application code.

### What are Axios interceptors?

Axios interceptors are functions that run before a request is sent and before a response reaches the calling code. They keep shared request and response handling on one client instance.

### What is Undici?

[Undici](#undici) is an HTTP client written from scratch for Node.js. It exposes request, stream, and pipeline APIs alongside its fetch interface.

### What is node-fetch?

[node-fetch](#node-fetch) brings the Fetch API to Node.js as a standalone module. Its current major version requires ESM imports.

## How this page was built

Data checked Nov 20, 2026.

Reproduce it with the Exa API:

```json
{
  "endpoint": "/search",
  "body": {
    "query": "JavaScript HTTP clients Axios Ky Got Undici retries timeouts cancellation streaming code examples",
    "numResults": 5
  }
}
```

Docs: https://exa.ai/docs/reference/search
