# to-api

> Library `to-api` generates REST API client with [`fetch`](https://fetch.spec.whatwg.org) under the hood.

Latest version **0.3.10** (published 2022-03-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install to-api
pnpm add to-api
yarn add to-api
bun add to-api
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.10 |
| Published | 2022-03-04 |
| First published | 2016-12-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 36.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Vladimir Shushkov |
| Maintainers | vladimir.shushkov |
| Keywords | api, creator, fetch, http, client |

## Links

- npm: https://www.npmjs.com/package/to-api
- Repository: https://github.com/vshushkov/to-api
- Homepage: https://github.com/vshushkov/to-api#readme
- Issues: https://github.com/vshushkov/to-api/issues
- npm.io page: https://npm.io/package/to-api

## Dependencies (1)

- [isomorphic-fetch](https://npm.io/package/isomorphic-fetch.md) ^3.0.0

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

- 0.3.10 (latest) — 2022-03-04
- 0.3.9 — 2022-03-03
- 0.3.8 — 2022-03-03
- 0.3.7 — 2020-12-30
- 0.3.6 — 2020-12-30
- 0.3.5 — 2020-12-30
- 0.3.4 — 2020-11-17
- 0.3.3 — 2020-09-25
- 0.3.2 — 2020-04-03
- 0.3.1 — 2020-03-12
- 0.3.0 — 2020-03-12
- 0.2.5 — 2019-02-07
- 0.2.4 — 2019-02-07
- 0.2.3 — 2019-01-11
- 0.2.2 — 2018-05-23
- … 12 more at https://npm.io/package/to-api/versions

## README

# to-api

Library `to-api` generates REST API client with [`fetch`](https://fetch.spec.whatwg.org) under the hood.

## Usage

```js
import create from 'to-api';

const clientApi = create({ baseUrl: 'http://api/users' });

clientApi
  .addHeader('Authorization', 'bearer ...')
  .processResponse(({ data }) => data);

const usersClient = clientApi({
  create: 'POST /',
  updateById: 'PUT /:id',
  deleteById: 'DELETE /:id',
  find: '/',
  findById: 'GET /:id'
});

(async () => {
    const newUser = await usersClient.create({ email: 'user@example.com' });
    const user = await usersClient.findById({ id: 'user-id' });
})();
```

More examples you can find in tests.

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