# node-fetch — card for AI agents

Bring the Fetch API to Node.js for making HTTP requests.

Category: HTTP clients and networking · npm package `node-fetch` · latest version 3.3.2 (checked 2026-11-01)
Install: `npm install node-fetch`
License: MIT (permissive)

In your own product (generator, app, hosted service): **yes**. Permissive license: ship it inside your own product, closed or open source, and keep its license and copyright notice.

## Numbers (AgentGid data)
- Gid Score: 75.1 (#203 of all tools, 14 of 126 in its category)
- Used in 106 public projects set up for AI coding agents (1.7%)
- Downloads last week: 300,609,978 (as of 2026-11-24), +39.7% over 4 weeks
- GitHub stars: 8,845 (as of 2026-11-24)
- Last push: 2026-05-12

## Often used with
dotenv 67.9%, Axios 34.0%, Express 31.1%, date-fns 34.0%, Supabase JS 34.9%, TypeScript 77.4%

## Checked alternatives (same job)
- Axios: https://agentgid.com/tools/axios/agent.md
- undici: https://agentgid.com/tools/undici/agent.md
- cross-fetch: https://agentgid.com/tools/cross-fetch/agent.md

## Links
- AgentGid page: https://agentgid.com/tools/node-fetch/
- Homepage: https://github.com/node-fetch/node-fetch
- Repository: https://github.com/node-fetch/node-fetch


## node-fetch: browser-style fetch() for older Node.js code

node-fetch lets a Node.js program load web pages and call online services with fetch(), the same command web pages use. Node.js 18 and newer has fetch() built in, so today it mostly keeps older projects working. It is free under the MIT license.

### Where to use it
- Read data from an online service: Your server script asks another service for data, like a list of products, and gets it back as a ready object.
- Send form or order data onward: When a visitor submits a form, your server passes the details on to another service, for example a mailing list or a shop system.
- Save a large download to disk: Your server downloads a big file, like a report or a video, and writes it to disk piece by piece instead of holding it all in memory.
- Give up on slow requests: A partner service sometimes hangs; your code cancels the request after a set time and shows a friendly error instead of waiting forever.
- Read every cookie a server sets: A test or a login helper needs each Set-Cookie line a server sends; node-fetch gives them as a list.
- Keep an older project working: An older app that still uses require() keeps its web requests working on the version 2 line while you plan an upgrade.

### How to start
- Add node-fetch to your project; version 3 needs Node.js 12.20 or newer.

```
npm install node-fetch
```

- Import it as an ES module. For a require() project, install node-fetch@2 instead.

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

- Treat error statuses yourself; a 404 or 500 does not throw, so check response.ok.

### License
Free to use, also in paid and closed-source products, under the MIT license. Keep the copyright and license notice when you pass its files on.

### Good to know
- Node.js 18 and newer have fetch() built in, so new projects usually do not need node-fetch.
- There has been no new release since July 2023 (3.3.2, and 2.7.0 on the old line).
- Version 3 works only with import, not require(); the maintainers keep version 2 for older code.
- It does not keep cookies between requests; you copy them from one response to the next request yourself.
- It is meant for servers; for code that also runs in the browser, its docs point to cross-fetch.

Checked 2026-11-11 against: https://github.com/node-fetch/node-fetch/blob/main/README.md, https://github.com/node-fetch/node-fetch/blob/main/docs/v3-UPGRADE-GUIDE.md, https://github.com/node-fetch/node-fetch/blob/main/docs/v3-LIMITS.md, https://github.com/node-fetch/node-fetch/blob/main/LICENSE.md, https://registry.npmjs.org/node-fetch, https://registry.npmjs.org/node-fetch/latest, https://nodejs.org/api/globals.html

### Mistakes to avoid
- Don't: const fetch = require('node-fetch')   // with node-fetch 3 → Do: import fetch from 'node-fetch' (or the built-in fetch on Node.js 18+); for require() code install node-fetch@2 (Version 3 is ESM-only and cannot be loaded with require().)
- Don't: fetch(url, { timeout: 5000 }) → Do: Pass signal from an AbortController and call controller.abort() after 5 seconds (The timeout option was dropped in version 3 because it is not part of the fetch standard.)
- Don't: try { await fetch(url) } catch { /* treat as failed */ } and nothing else → Do: Also check response.ok (or response.status) and handle 4xx and 5xx answers (Error statuses do not throw; only network and operational errors do.)
- Don't: fetch('/api/users') → Do: fetch(new URL('/api/users', baseUrl)) (Only absolute addresses work on the server.)
- Don't: npm install node-fetch in a new project on Node.js 18 or newer → Do: Use the global fetch that Node.js provides (Node.js has shipped fetch without a flag since version 18, and node-fetch has had no release since 2023.)

### Questions
- Do I still need node-fetch? Usually not on Node.js 18 or newer, which has fetch() built in. It still helps older Node.js versions and code that uses its extras.
- Why does require('node-fetch') fail? Version 3 is ESM-only. Use import, a dynamic import(), or install version 2.
- How do I set a timeout? The old timeout option was removed in version 3; pass an AbortController's signal and abort it after the time you choose.
- Why did a 404 not throw an error? Error statuses are normal responses; check response.ok or response.status yourself.
- Can I call a relative address like /api/users? No. Give a full address such as https://example.com/api/users; relative ones are rejected.

---
AgentGid's catalog is curated: every entry was checked against the maker's official pages (registry, repository, license and pricing pages) on the date shown; a license value shows the quote it stands on wherever AgentGid has one. Usage numbers come from AgentGid's own scan of public repositories set up for AI coding agents. Claims by makers are reported, not tested by AgentGid.
