# yarc-client

> Yet Another REST API Client

Latest version **0.1.0** (published 2019-10-01) · ISC license · 0 weekly downloads

## Install

```sh
npm install yarc-client
pnpm add yarc-client
yarn add yarc-client
bun add yarc-client
```

## 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.1.0 |
| Published | 2019-10-01 |
| First published | 2019-10-01 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 20.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | @janis_t |
| Maintainers | yanis |
| Keywords | api, rest, promise |

## Links

- npm: https://www.npmjs.com/package/yarc-client
- npm.io page: https://npm.io/package/yarc-client

## 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.1.0 (latest) — 2019-10-01

## README

# 🌱 YARC — Yet Another REST Client

A semantic REST client that focuses on REST entities and endpoints. It provides a higher-level abstraction for your API calls.

## What's this about / Features

- Semantic code organization
- Promise-based (async/await) API
- Custom actions
- Nested endpoints
- Depends on the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)

## Example of usage

```javascript
const api = yarc(
  { baseUrl: '/api/v1/' },
  {
    users: { books: { onMember: [{ POST: 'mark_read' }] }, notes: {} },
    books: { onCollection: [{ GET: lookup }] },
    notes: { onCollection: [{}] },
  },
)

// Get a single user (GET /api/v1/users/1)
await api.users(1).fetch()

// Update a user (PATCH /api/v1/users/1)
await api.users(1).update({ name: 'John' })

// Get all books (GET /api/v1/books?page=0&limit=20)
await api.books().fetch({ page: 0, limit: 20 })

// Get all notes by a user (GET /api/v1/users/1/notes)
await api
  .users(1)
  .notes()
  .fetch()

// Lookup a book (GET /api/v1/books/lookup?query=abc)
await api.books().lookup({ query: 'abc' })

// Mark a book as read (POST /api/v1/users/1/books/123/mark_read)
await api
  .users(1)
  .books(123)
  .mark_read()
```

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