# Axios — card for AI agents

Promise-based HTTP client for browser and Node.js with interceptors.

Category: HTTP clients and networking · npm package `axios` · latest version 1.21.0 (checked 2026-11-01)
Install: `npm install axios`
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.

## Rules for AI agents (paste into AGENTS.md or CLAUDE.md)

## Axios
- The README's table of contents tags the `CancelToken` and "Concurrency" sections as deprecated. For cancellation, it lists an `AbortController` section; do not add new code that uses the deprecated APIs.
- When global defaults, instance defaults and per-request config overlap, check the README's "Config order of precedence" section rather than guessing which one wins.
- For HTTP 413 and 422, use `ContentTooLarge` and `UnprocessableContent`. Since v1.20.0, `PayloadTooLarge` and `UnprocessableEntity` are deprecated aliases.
- In browser code on v1.20.0+, expect navigation-canceled XHR requests to reject with `ECONNABORTED`, not to resolve with status 0.
- On v1.20.0+, invalid DNS lookup and `httpVersion` failures surface as `AxiosError.ERR_BAD_OPTION_VALUE`.
- Before upgrading to v1.20.0, read PR #11141 for its documented compatibility effects on Fetch redirects, HTTP/2 DNS and proxy handling, `NO_PROXY` matching and data URIs.

## Docs written for agents
- [llms.txt (index of the docs)](https://nodejs.org/llms.txt)

## What it is
- Axios calls itself a "Promise based HTTP client for the browser and node.js". The website puts it more plainly: "a simple HTTP client for the browser and Node.js". The GitHub repository was created on 2014-08-18 and is MIT licensed.
- The website makes three claims. A simple request takes "2 lines of code". An interceptor system lets you change requests, responses and errors. The package declares its own TypeScript types. The README's table of contents also lists sections on instances, config defaults and their order of precedence, error and timeout handling, cancellation, urlencoded and multipart bodies, progress capturing, rate limiting and a fetch adapter.
- The latest release in the sources is v1.20.0, published 2026-08-24. Its notes cover hardened runtime option handling, new RFC 9110 status-code aliases, and fixes to Node.js and XHR reliability.

## Caveats
- CancelToken is on the way out: The README's table of contents lists two cancellation sections. The `AbortController` section has no tag. The `CancelToken` section is tagged deprecated in its anchor.
- A v0 security callout points to a sponsor: Both the website and the README carry a callout, "Get Security Updates for Axios v0", that links to herodevs.com. HeroDevs appears in the sponsor list. The sources do not explain how v0 is maintained.
- 413 and 422 have new names: v1.20.0 adds `ContentTooLarge` and `UnprocessableContent`. It keeps `PayloadTooLarge` and `UnprocessableEntity` as "backward-compatible deprecated aliases". The notes list this under "Breaking Changes &amp; Deprecations".
- Navigation-canceled XHR now rejects: Since v1.20.0, a browser request canceled by navigation rejects with `ECONNABORTED`. It used to resolve with status 0. Code that checked for status 0 sees a different outcome.
- Security hardening has compatibility effects: The v1.20.0 security fix also changes how Axios handles Fetch redirects, HTTP/2 DNS and proxies, CIDR-based `NO_PROXY` and malformed data URIs. The notes point to the PR for "documented compatibility effects".

## Numbers (AgentGid data)
- Gid Score: 91.0 (#9 of all tools, 1 of 126 in its category)
- Used in 470 public projects set up for AI coding agents (7.5%)
- Downloads last week: 150,124,651 (as of 2026-11-24), +30.2% over 4 weeks
- GitHub stars: 109,397 (as of 2026-11-24)
- Last push: 2026-11-23

## Often used with
Tailwind CSS 61.1%, concurrently 27.9%, Vite 43.8%, TypeScript 69.6%, ESLint 53.8%, Laravel Vite Plugin 19.8%

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

## Links
- AgentGid page: https://agentgid.com/tools/axios/
- Homepage: https://axios-http.com
- Repository: https://github.com/axios/axios
- Source: https://github.com/axios/axios#readme
- Source: https://github.com/axios/axios
- Source: https://github.com/axios/axios/releases
- Source: https://axios-http.com


## Axios: send web requests from browser or Node.js

Axios is a free JavaScript library your app uses to talk to other servers, from the browser or from Node.js. You set the server address, sign-in header and time limit once, and every request reuses them. Failed requests come back as clear errors you can show to users.

### Where to use it
- One client for your backend: Your frontend calls your own server from many screens; one shared client adds the address, the sign-in token and a time limit to every call.
- Friendly messages when calls fail: When an order is not found or the server is too slow, show a clear message instead of a blank page.
- Stop an old search request: A search box sends a request on each key; cancel the previous one so an old answer never replaces a newer one.
- Upload with a progress bar: A file upload form fills a progress bar while a photo or document goes up to your server.
- Retry when the server hiccups: When your server briefly fails, try the same request again a few times, waiting a bit longer each time.
- Safe calls to unknown servers: A server-side job fetches pages or files from addresses users give; set a size cap so one bad reply cannot fill the memory.

### How to start
- Install it into your project.

```
npm install axios
```

- Import it. With require, only the default export is there.

```
import axios, { isCancel, AxiosError } from 'axios';
// const axios = require('axios');
```

- Make one instance with your server address and a time limit, and use it everywhere.

```
const instance = axios.create({
  baseURL: 'https://some-domain.com/api/',
  timeout: 1000,
  headers: { 'X-Custom-Header': 'foobar' },
});
```


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

### Good to know
- Without a time limit, a stalled request can wait forever. Always set timeout in real apps.
- By default there is no size limit on replies. On a server that calls unknown sites, set one, or a tiny packed reply can use up the memory.
- In the browser, the default way of sending requests ignores that size limit; switch to the fetch mode if you need it there.
- The base address is not a security wall. If part of the address comes from users, check it before the request.
- Releases are built and signed by the project's own build system, so your tools can check that a downloaded copy was not swapped.

Checked 2026-11-11 against: https://github.com/axios/axios/blob/v1.x/README.md, https://github.com/axios/axios/blob/v1.x/LICENSE, https://github.com/axios/axios/blob/v1.x/SECURITY.md, https://github.com/axios/axios/blob/v1.x/THREATMODEL.md, https://github.com/axios/axios/blob/v1.x/CHANGELOG.md, https://axios-http.com/docs/intro, https://axios.rest/pages/getting-started/first-steps, https://axios.rest/pages/getting-started/upgrade-guide, https://axios.rest/pages/misc/security, https://axios.rest/pages/advanced/retry, https://axios.rest/pages/advanced/testing, https://axios.rest/pages/advanced/fetch-adapter, https://registry.npmjs.org/axios, https://registry.npmjs.org/axios/1.21.1

### Mistakes to avoid
- Don't: axios.get(url) with no timeout in production code → Do: Set timeout on the instance (axios.create({ timeout: 5000 })) and handle ECONNABORTED and ETIMEDOUT (Without a timeout a stalled request never ends; in our run with the fetch adapter the timeout came back as ETIMEDOUT, while the docs name ECONNABORTED as the usual code, so check both.)
- Don't: new axios.CancelToken(...) / source.cancel() in new code → Do: Pass { signal: controller.signal } from an AbortController and test with axios.isCancel(e) (CancelToken is deprecated; AbortController is the supported way since 0.22.0, and our demo cancel ended with ERR_CANCELED.)
- Don't: axios.all([...]) and axios.spread(...) → Do: Promise.all([...]) with array destructuring (The concurrency helpers are deprecated.)
- Don't: const { isCancel } = require('axios') → Do: const axios = require('axios'); axios.isCancel(e) — or use import { isCancel } from 'axios' (With require only the default export is available.)
- Don't: "axios": "^1.x" with no lockfile, or a CDN script without a version → Do: Pin the exact version in a lockfile and run npm audit signatures in CI (The axios docs tell users to check release provenance with npm audit signatures and to treat a missing attestation on an attested version as a possible supply-chain incident.)

### Questions
- Does it work in both the browser and Node.js? Yes. It uses XMLHttpRequest in the browser, the http module in Node.js, and can switch to fetch.
- Why does a 404 or 500 land in catch? Axios treats any status outside 200-299 as an error. Change that with validateStatus.
- How do I cancel a request? Pass an AbortController signal and call abort(). The older CancelToken is deprecated.
- Does it retry failed requests by itself? No. The docs show how to add retries with a response interceptor.
- Can I use it in a paid product? Yes, it is MIT licensed; keep its license notice in copies you ship.

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