# restyped-axios

> Axios typings for consuming RESTyped APIs

Latest version **2.0.0** (published 2018-08-02) · MIT license · 0 weekly downloads

## Install

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

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2018-08-02 |
| First published | 2017-10-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 6.3 KB |
| Known vulnerabilities | 0 (+25 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 29 |
| Author | Arman Dezfuli-Arjomandi |
| Maintainers | rawrmaan |

## Links

- npm: https://www.npmjs.com/package/restyped-axios
- Repository: https://github.com/rawrmaan/restyped-axios
- Homepage: https://github.com/rawrmaan/restyped-axios#readme
- Issues: https://github.com/rawrmaan/restyped-axios/issues
- npm.io page: https://npm.io/package/restyped-axios

## Dependencies (3)

- [axios](https://npm.io/package/axios.md) ^0.16.2
- [restyped](https://npm.io/package/restyped.md) 1.1.0
- [typescript](https://npm.io/package/typescript.md) ^2.9.2

## Recent versions

- 2.0.0 (latest) — 2018-08-02
- 1.3.2 — 2018-04-05
- 1.3.1 — 2017-11-03
- 1.3.0 — 2017-11-03
- 1.2.0 — 2017-11-02
- 1.1.1 — 2017-10-11
- 1.1.0 — 2017-10-11
- 1.0.0 — 2017-10-11

## README

# RESTyped Axios

Axios typings for consuming [RESTyped](https://github.com/rawrmaan/restyped) APIs

## Usage

`npm install restyped-axios`

_Note: >=2.0.0 supports TypeScript 2.8 and higher. Use a lower version if you need TypeScript 2.4-2.7 support._

It's just like normal axios, except you'll need to provide a RESTyped API definition file for the API you want to use.

```typescript
import axios from 'restyped-axios'
import {GiphyAPI} from 'restyped-giphy-api'

const client = axios.create<GiphyAPI>({baseURL: 'http://api.giphy.com/v1'})

// You'll get a compile error if you call an invalid route or use incorrect query params. Yay!
client.request({
  url: '/gifs/trending',
  params: {
    api_key: 'Qr5fw...'
  }
}).then(...)
```

## Special cases

### GET with query params (e.g. `/gifs/trending?api_key=...`)

Use the `client.request({url: ..., params: ...})` syntax instead of `client.get` in order to have your params typechecked. See above.

### Routes with params in their paths (e.g. `/posts/:id/like`)

Explicitly declare the canonical route in angle brackets to avoid an invalid route error.

```typescript
client.post<'/posts/:id/like'>('/posts/3/like')
```

## Popular APIs to try out

- Giphy API: [`restyped-giphy-api`](https://github.com/rawrmaan/restyped-giphy-api)

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