# jsonrpc2

> JSON-RPC server and client library

Latest version **0.1.1** (published 2012-02-07) · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2012-02-07 |
| First published | 2011-07-01 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | * |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 36 |
| Author | Eric Florenzano |
| Maintainers | bitcoinjs |
| Keywords | json, rpc, server, client |

## Links

- npm: https://www.npmjs.com/package/jsonrpc2
- Repository: https://github.com/bitcoinjs/node-jsonrpc2
- npm.io page: https://npm.io/package/jsonrpc2

## Dependencies (1)

- [jsonparse](https://npm.io/package/jsonparse.md) >=0.0.1

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.1.1 (latest) — 2012-02-07
- 0.1.0 — 2011-12-30
- 0.0.9 — 2011-12-30
- 0.0.8 — 2011-12-04
- 0.0.6 — 2011-07-16
- 0.0.5 — 2011-07-05
- 0.0.4 — 2011-07-05
- 0.0.3 — 2011-07-04
- 0.0.2 — 2011-07-01
- 0.0.1 — 2011-07-01

## README

# node-jsonrpc2

This is a JSON-RPC server and client library for node.js <http://nodejs.org/>,
the V8 based evented IO framework.

## Install

To install node-jsonrpc2 in the current directory, run:

    npm install jsonrpc2

## Usage

Firing up an efficient JSON-RPC server becomes extremely simple:

``` javascript
var rpc = require('jsonrpc2');

var server = new rpc.Server();

function add(args, opt, callback) {
  callback(null, args[0] + args[1]);
}
server.expose('add', add);

server.listen(8000, 'localhost');
```

And creating a client to speak to that server is easy too:

``` javascript
var rpc = require('jsonrpc2');
var sys = require('sys');

var client = new rpc.Client(8000, 'localhost');

client.call('add', [1, 2], function(err, result) {
    sys.puts('1 + 2 = ' + result);
});
```

To learn more, see the examples directory, peruse test/jsonrpc-test.js, or
simply "Use The Source, Luke".

More documentation and development is on its way.

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