# tser

> A general client for RESTful API

Latest version **1.4.0** (published 2014-12-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install tser
pnpm add tser
yarn add tser
bun add tser
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.4.0 |
| Published | 2014-12-31 |
| First published | 2014-12-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.11.13 |
| Dependencies | 5 |
| Known vulnerabilities | 0 (+6 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Zihua Li |
| Maintainers | luin |
| Keywords | restful, api, client, rest |

## Links

- npm: https://www.npmjs.com/package/tser
- Repository: https://github.com/luin/tser
- Issues: https://github.com/luin/tser/issues
- npm.io page: https://npm.io/package/tser

## Dependencies (5)

- [lodash](https://npm.io/package/lodash.md) ^2.4.1
- [methods](https://npm.io/package/methods.md) ~1.1.0
- [request](https://npm.io/package/request.md) ^2.48.0
- [harmony-proxy](https://npm.io/package/harmony-proxy.md) 0.0.2
- [request-promise](https://npm.io/package/request-promise.md) ^0.3.2

## 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.4.0 (latest) — 2014-12-31
- 1.3.1 — 2014-12-16
- 1.3.0 — 2014-12-16
- 1.2.0 — 2014-12-07
- 1.1.0 — 2014-12-07
- 1.0.0 — 2014-12-06

## README

Tser
====

A general node.js client for RESTful API

[![Build Status](https://travis-ci.org/luin/tser.png?branch=master)](https://travis-ci.org/luin/tser)

Install
-------

    $ npm install tser

Usage
-----

Tser is the reversed 'Rest' and it can turn any RESTful API into a node.js client.

```javascript
var tser = require('tser');

var api = tser('http://demo7394653.mockable.io/');

// GET http://domain.com/api/users/12/projects?status=active
api.users(12).projects.get({ status: 'active' }).then(function(res) {
  console.log(res);
});
```

```javascript
var tser = require('tser');

var api = tser('http://demo7394653.mockable.io/');

// POST http://demo7394653.mockable.io/api/users
//  with json body { name: 'Bob' }
api.users.post({ name: 'Bob' }).then(function(res) {
  console.log(res);
});
```

```javascript
var tser = require('tser');

var api = tser('http://demo7394653.mockable.io/', {
  transform: {
    request: function(options) {
      if (this.auth) {
        options.auth = this.auth;
      }
      return options;
    }
  }
});

// GET http://demo7394653.mockable.io/api/users/me
api.users('me').get().catch(function(err) {
  // 401
});

api.$set('auth', {
  user: 'abc',
  pass: 'pass'
});

// GET http://demo7394653.mockable.io/api/users/me
api.users('me').get().then(function(me) {
    console.log(me);
});
```

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