# JavaScript HTTP client libraries

JavaScript HTTP client libraries send requests to web servers and read the responses. Apps and AI agents use these libraries to call external APIs with features the built-in fetch lacks, such as retries and response caching.

## 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.2B.

## 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)

Undici is an HTTP client written from scratch for Node.js, and the built-in `fetch` in Node.js runs on a bundled copy of it. Installing the package adds APIs the built-in version lacks: `request`, `stream`, and `pipeline` for lower-level calls, and `ProxyAgent` and `MockAgent` for proxies and tests. An `Agent` or `Pool` controls connection pooling, and `setGlobalDispatcher` applies one to every request. Undici's HTTP parser runs on WebAssembly, so requests fail in a Node.js setup that turns WebAssembly off.

- 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**

- **Controls reusable connection pools.** Choose Agent or Pool when connection behavior needs explicit control.
- **Retries through dispatcher composition.** Wrap a dispatcher in RetryAgent to retry eligible failed requests.

**Watch out for**

- **Response bodies must be consumed.** Read or cancel each response body so its connection can be reused.
- **Fetch bodies use web streams.** Convert the response body when a Node stream is required.

```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%20TypeScript%20projects%20using%20undici%20for%20retry%20interceptors%2C%20package%20registry%20metadata%20and%20owned%20connection%20cleanup&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)

node-fetch brings the browser's Fetch API to Node.js, built on the native `http` module rather than a browser polyfill. A call to `fetch(url)` returns a promise of a `Response`, read with `res.json()` or `res.text()`. Request and response bodies are Node streams, and the library decodes gzip, deflate, and Brotli responses. Options add a redirect limit and a response size limit that the Fetch standard leaves out. The current major version is an ES module only, and the previous one still loads with `require`.

- 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)

**Watch out for**

- **ES module only.** The current version can't be loaded with require; CommonJS projects stay on the previous major version.

```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)

Gaxios is an HTTP client from Google that offers an interface like Axios on top of node-fetch. `request({ url })` sends a request and resolves to a response whose `data` field holds the parsed body. A `Gaxios` instance stores defaults such as a base URL and headers for every request it sends, and `instance.fetch` offers a Fetch-compatible call. The package is built for calls to 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)

Axios sends HTTP requests from the browser and from Node.js with the same promise-based API. Methods such as `axios.get` resolve to a response whose `data` field holds the parsed body, and objects passed as data serialize to JSON. Interceptors run code on every request or response to add logic or transform data. `axios.create` makes an instance with its own base URL, headers, and timeout. Requests can be cancelled, and a response with an error status rejects the promise.

- 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**

- **Works in browsers and Node.** Use browser and server adapters through the same request interface.
- **Intercepts requests and responses.** Add shared request configuration and response handling through interceptors.

**Watch out for**

- **Retry policies need an integration.** Add axios-retry when transient request failures should trigger retries.
- **Timeouts are disabled by default.** Set a timeout explicitly when requests must stop waiting.

```sh
npm install axios
```

**softonic/axios-retry** (2.0K stars)

[softonic/axios-retry](https://github.com/softonic/axios-retry) 

```javascript
const axiosRetry: AxiosRetry = (axiosInstance, defaultOptions) => {
  const requestInterceptorId = axiosInstance.interceptors.request.use((config) => {
    setCurrentState(config, defaultOptions, true);
    if (config[namespace]?.validateResponse) {
      // by setting this, all HTTP responses will be go through the error interceptor first
      config.validateStatus = () => false;
    }
    return config;
  });

  const responseInterceptorId = axiosInstance.interceptors.response.use(null, async (error) => {
    const { config } = error;
    // If we have no information to retry the request
    if (!config) {
      return Promise.reject(error);
    }
    const currentState = setCurrentState(config, defaultOptions);
    if (error.response && currentState.validateResponse?.(error.response)) {
      // no issue with response
      return error.response;
    }
    if (await shouldRetry(currentState, error)) {
      return handleRetry(axiosInstance, currentState, error, config);
    }

    await handleMaxRetryTimesExceeded(currentState, error);

    return Promise.reject(error);
  });

  return { requestInterceptorId, responseInterceptorId };
};
```

[src/index.ts](https://github.com/softonic/axios-retry/blob/a748627fdc5e22e659055b6cfb44e35ad5801bf4/src/index.ts#L301-L332) · [More projects using Axios →](https://dashboard.exa.ai/playground/search?q=JavaScript%20TypeScript%20projects%20using%20axios%20for%20retry%20interceptors%2C%20package%20registry%20metadata%20and%20owned%20connection%20cleanup&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 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)

### 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)

Got is an HTTP request library for Node.js with promise and stream interfaces. `got.post(url, { json })` sends a JSON body, and `.json()` on the returned promise parses the response. Failed requests retry by default, and options cover timeouts, caching, proxies, and Unix sockets. The package is an ES module only. Its README points browser code to Ky, a Fetch-based client from the same authors.

- 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**

- **Provides promise and stream APIs.** Choose parsed responses or streaming transfers for Node applications.
- **Includes configurable retry behavior.** Set eligible methods, failure codes, and retry delays.

**Watch out for**

- **Requires ES module imports.** Convert CommonJS integration code before importing current Got.
- **POST is excluded from retries.** Configure retry.methods explicitly when repeating a POST request is safe.

```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%20TypeScript%20projects%20using%20got%20for%20retry%20interceptors%2C%20package%20registry%20metadata%20and%20owned%20connection%20cleanup&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)

make-fetch-happen is a Node.js Fetch client that adds an HTTP cache, retries, request pooling, and proxy support to `minipass-fetch`. Setting `cachePath` stores responses on disk and follows HTTP caching rules, including `Cache-Control`, `ETag`, and conditional requests. Retries follow HTTP semantics, and a cached copy can answer when the network fails. `fetch.defaults` returns a fetch function with preset options.

- 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)

SuperAgent sends HTTP requests with a chained API that runs the same way in Node.js and in the browser. Methods such as `.post`, `.send`, and `.set` build the request, which goes out on `.end` with a callback or when awaited as a promise. An object passed to `.send` becomes a JSON request body. The browser build also loads from a script tag through jsDelivr or unpkg.

- 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)

ofetch wraps the Fetch API with defaults for JSON and errors, and runs in Node.js, browsers, and workers. `ofetch('/api/users')` parses a JSON response on its own, and an object passed as `body` goes out as JSON with matching headers. A response with an error status throws a `FetchError` that carries the parsed error body. Failed requests retry once by default, except for `POST`, `PUT`, `PATCH`, and `DELETE`, which retry only when configured.

- 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)

**Watch out for**

- **No retries for writes.** POST, PUT, PATCH, and DELETE requests don't retry unless retry is set.

```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 client should I use?

In Node.js with no extra package, use the built-in `fetch`, which runs on [Undici](#undici). For one API across the browser and Node.js with interceptors and instances, use [Axios](#axios). For Node.js with retries and streams, use [Got](#got), and for Fetch with JSON parsing and retries in any runtime, use [ofetch](#ofetch).

### What is node-fetch?

[node-fetch](#node-fetch) brings the browser's Fetch API to Node.js. Node.js now ships a built-in `fetch` powered by [Undici](#undici), so current Node.js versions can call fetch without a package. node-fetch adds Node streams for request and response bodies and options such as a response size limit.

### Axios vs fetch: what is the difference?

[Axios](#axios) parses JSON responses, rejects the promise on an error status, and supports interceptors and preconfigured instances. Fetch is built into browsers and Node.js, returns a response whose body needs a separate `json()` call, and resolves even when the server returns an error status.

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

[Axios](#axios) has no retry option of its own, and the axios-retry package adds one. [Got](#got), [ofetch](#ofetch), and [SuperAgent](#superagent) retry failed requests without an extra package.

### How do I set a timeout in Axios?

Pass `timeout` in milliseconds in the request config, or on an instance made with `axios.create`. [Axios](#axios) sets no timeout by default.

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

[Got](#got) runs only in Node.js, retries failed requests by default, and offers a stream interface. [Axios](#axios) runs in browsers and Node.js with one API and needs the axios-retry package for retries.

## How this page was built

Data checked Nov 19, 2026.

Reproduce it with the Exa API:

```json
{
  "endpoint": "/search",
  "body": {
    "query": "Best JavaScript HTTP client libraries Axios Got Ky Undici Node fetch code examples",
    "numResults": 5
  }
}
```

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