# client-api

> rest lik client api calls

Latest version **0.1.12** (published 2016-09-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install client-api
pnpm add client-api
yarn add client-api
bun add client-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.1.12 |
| Published | 2016-09-19 |
| First published | 2016-01-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | 4.2.0 |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Holger Schauf |
| Maintainers | fluse |
| Keywords | javascript, node, client, rest, api |

## Links

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

## Dependencies (2)

- [extend](https://npm.io/package/extend.md) ^3.0.0
- [superagent](https://npm.io/package/superagent.md) ^1.8.3

## 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.12 (latest) — 2016-09-19
- 0.1.11 — 2016-09-01
- 0.1.10 — 2016-08-19
- 0.1.9 — 2016-07-29
- 0.1.8 — 2016-04-07
- 0.1.7 — 2016-04-04
- 0.1.6 — 2016-04-04
- 0.1.5 — 2016-03-29
- 0.1.3 — 2016-01-27

## README

# Client API

[![Donate](https://img.shields.io/badge/donate-%20%E2%9D%A4%20-green.svg)](https://www.paypal.me/schauf)

Rest like client api calls

## Install

```shell
> npm install client-api --save
```

dependencies:
 - [superagend](https://github.com/visionmedia/superagent)
 - [node-extend](https://github.com/justmoon/node-extend)

## Use

```javascript
var Api = require('client-api');
```

## Create

```javascript
var api = new Api(settings);
```

## Settings

```javascript
var settings = {
    token: '32digits',
    version: 'v1',
    baseName: '/api/',
    dataType: 'json'
}
```

| name        | type           | description  |
| ------------- |:-------------:| :---------|
| token      | String | server authorization with token |
| version      | String      |   api version |
| baseName | String      |   base url without domain.tld |
| dataType | String      |    data format |

## Calls

```javascript
api(method, path, params, data, callback);
```

| name        | type           | description  |
| ------------- |:-------------:| :---------|
| method      | String | get, post, put, delete, path |
| path      | String      |   api version |
| params | Object      |   set maximal video amount |
| data | Object      |    option on get and delete |
| callback | Function  |    recieving function |

### GET
```javascript
api('get', '/category/article', {}, callback);
```

### GET with Params

each :{name} will replace by key value from params object

```javascript
var params = {
    publisher: 'times',
    category: 'book',
    id: 5
};

api('get', '/:publisher/:category/:id', params, callback);
```

Result
`http://domain.tld./api/v1/times/book/5`

### PUT / POST
```javascript

var data = {
    name: 'newName'
};

api('put', 'category/article/:id', {
    id: inputId
}, data, callback);
```

### DELETE
```javascript

api('delete', 'category/article/:id', {
    id: inputId
}, callback);
```

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