# alpinejs-axios

> Alpine JS magic methods wrapper for Axios API methods 📨

Latest version **1.0.12** (published 2026-03-29) · 0 weekly downloads

## Install

```sh
npm install alpinejs-axios
pnpm add alpinejs-axios
yarn add alpinejs-axios
bun add alpinejs-axios
```

## Health

**Score 50/100 (C)** — status: stable.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 1.0.12 |
| Published | 2026-03-29 |
| First published | 2023-10-03 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 267.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | markmead |
| Keywords | Alpine, Alpine JS, Alpine JS Plugin, Alpine JS Plugins, Axios, Alpine JS Axios, Alpine JS API, Alpine JS Fetch |

## Links

- npm: https://www.npmjs.com/package/alpinejs-axios
- npm.io page: https://npm.io/package/alpinejs-axios

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 1.0.12 (latest) — 2026-03-29
- 1.0.11 — 2026-03-29
- 1.0.10 — 2025-09-10
- 1.0.8 — 2024-10-24
- 1.0.7 — 2024-04-04
- 1.0.6 — 2024-03-22
- 1.0.5 — 2024-01-16
- 1.0.4 — 2023-11-25
- 1.0.2 — 2023-11-12
- 1.0.1 — 2023-10-03
- 1.0.0 — 2023-10-03

## README

# Alpine JS Axios

![](https://img.shields.io/npm/v/alpinejs-axios)
![](https://img.shields.io/npm/dt/alpinejs-axios)
![](https://img.shields.io/github/license/markmead/alpinejs-axios)

Alpine JS magic methods wrapper for Axios API methods 📨

## Install

### With a CDN

```html
<script
  defer
  src="https://unpkg.com/alpinejs-axios@latest/dist/api.min.js"
></script>

<script defer src="https://unpkg.com/alpinejs@3/dist/cdn.min.js"></script>
```

### With a Package Manager

```shell
yarn add -D alpinejs-axios

npm install -D alpinejs-axios
```

```js
import Alpine from 'alpinejs'
import api from 'alpinejs-axios'

Alpine.plugin(api)

Alpine.start()
```

## Example

### GET

```html
<div x-data="{ productData: {} }">
  <button @click="productData = await $get('https://dummyjson.com/products/1')">
    Get
  </button>

  <pre x-text="JSON.stringify(productData, null, 2)"></pre>
</div>
```

### POST

```html
<div x-data="{ productData: {} }">
  <button
    @click="productData = await $post('https://dummyjson.com/products/add', { title: 'BMW Pencil' })"
  >
    Create
  </button>

  <pre x-text="JSON.stringify(productData, null, 2)"></pre>
</div>
```

### PUT/PATCH

```html
<div x-data="{ productData: {} }">
  <button
    @click="productData = await $put('https://dummyjson.com/products/1', { title: 'iPhone Galaxy +1' })"
  >
    Update
  </button>

  <pre x-text="JSON.stringify(productData, null, 2)"></pre>
</div>
```

### DELETE

```html
<div x-data="{ productData: {} }">
  <button
    @click="productData = await $delete('https://dummyjson.com/products/1')"
  >
    Delete
  </button>

  <pre x-text="JSON.stringify(productData, null, 2)"></pre>
</div>
```

## Filtering the Response

A lot of the times you only need a property from the response object, this is
usually `data`. You'll see/write stuff like this:

```js
const { data } = axios.get('https://dummyjson.com/products/1')
```

With this package you can do that by adding `[data]` to the end of the URL.

```html
<div x-data="{ productData: {} }">
  <!-- Single -->
  <button
    @click="productData = await $get('https://dummyjson.com/products/1[data]')"
  >
    Get
  </button>

  <!-- Multiple -->
  <button
    @click="productData = await $get('https://dummyjson.com/products/1[data,status]')"
  >
    Get
  </button>

  <pre x-text="JSON.stringify(productData, null, 2)"></pre>
</div>
```

This works for all the requests and isn't limited to the `data` property.
Anything that is part of the response object can be used to filter the response.
For example, `[status]`.

_Heads up! Syntax is important, the filter property key must be place in square
brackets `[x]`._

### Nested Filters

Sometimes you don't want the whole object back, in this example `data` returns a
lot of information but we only want `title` and `price` back. Here's how you can
do that.

```html

  <button
    @click="productData = await $get('https://dummyjson.com/products/1[data.title,data.price]')"
  >
    Get
  </button>

  <pre x-text="JSON.stringify(productData, null, 2)"></pre>
</div>
```

This will return with the first key, in this case `data` omitted.

```json
{
  "title": "iPhone 9",
  "price": 549
}
```

_Note! You can still pass other filters in when using nested filters, something
like `[data.title, status]` will work fine!_

---
_Source: https://npm.io/package/alpinejs-axios · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
