PHPackages                             scaytrase/json-rpc-client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. scaytrase/json-rpc-client

ActiveLibrary[API Development](/categories/api)

scaytrase/json-rpc-client
=========================

JSON-RPC 2.0 Client implementation

1.0.2(9y ago)4155.6k—8.3%2MITPHPPHP ~5.5|~7.0

Since Apr 13Pushed 8y ago2 watchersCompare

[ Source](https://github.com/scaytrase/json-rpc-client)[ Packagist](https://packagist.org/packages/scaytrase/json-rpc-client)[ RSS](/packages/scaytrase-json-rpc-client/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (6)Versions (3)Used By (2)

[![Build Status](https://camo.githubusercontent.com/bd4d3d9c8e68d21644ebf4a8e5a63fce07313dcd156de6e07d7d21bdb2ed4f12/68747470733a2f2f7472617669732d63692e6f72672f7363617974726173652f6a736f6e2d7270632d636c69656e742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/scaytrase/json-rpc-client)[![Code Coverage](https://camo.githubusercontent.com/d9737268a1fd5fdebf15ba41301a0e5027ac17e4414519c76146e1e38cc241b5/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7363617974726173652f6a736f6e2d7270632d636c69656e742f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/scaytrase/json-rpc-client/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/4eeabb00cfb244bf180d060378d1c256e62f853960aee42b1432a4df84e7259a/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7363617974726173652f6a736f6e2d7270632d636c69656e742f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/scaytrase/json-rpc-client/?branch=master)[![SensioLabsInsight](https://camo.githubusercontent.com/1ca99f384d5e533b93759a80b2130b02264db98615b9bce4e70d955cc7b8268f/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f39373036393138612d333964342d343832322d386532352d6430613031313832623130622f6d696e692e706e67)](https://insight.sensiolabs.com/projects/9706918a-39d4-4822-8e25-d0a01182b10b)

[![Latest Stable Version](https://camo.githubusercontent.com/1b2efc63a1bd2940755e888cad32ead27c3724c4c0159841d5157ba21b65263e/68747470733a2f2f706f7365722e707567782e6f72672f7363617974726173652f6a736f6e2d7270632d636c69656e742f762f737461626c65)](https://packagist.org/packages/scaytrase/json-rpc-client)[![Total Downloads](https://camo.githubusercontent.com/899796ade56ca8323803e2fd71eab67e8cf077e11ee59f28a565f06dd2412167/68747470733a2f2f706f7365722e707567782e6f72672f7363617974726173652f6a736f6e2d7270632d636c69656e742f646f776e6c6f616473)](https://packagist.org/packages/scaytrase/json-rpc-client)[![Latest Unstable Version](https://camo.githubusercontent.com/57b875a40580a0b58b127d3ca8323b0c2158e5905b1231e2aaecb13a45fd7e3f/68747470733a2f2f706f7365722e707567782e6f72672f7363617974726173652f6a736f6e2d7270632d636c69656e742f762f756e737461626c65)](https://packagist.org/packages/scaytrase/json-rpc-client)

JSON-RPC 2.0 Client implementation
==================================

[](#json-rpc-20-client-implementation)

Extension of [`scaytrase/rpc-common`](https://github.com/scaytrase/rpc-common)

- JSON RPC Interfaces
- JSON RPC client
- Async with Guzzle
- Automatic batch with multiple requests or `LazyClientDecorator`

[JSON-RPC 2.0 Specification](http://www.jsonrpc.org/specification)

Usage
-----

[](#usage)

1. Configure a [Guzzle client](http://docs.guzzlephp.org/en/latest/).
2. Instantiate the client:

```
use ScayTrase\Api\JsonRpc\JsonRpcClient;

$client = new JsonRpcClient($guzzleClient, 'http://endpoint/url/');
```

4. Optionally pass the ID generator as third argument and the PSR-3 logger as the fourth argument

Simple UUID generator and PSR-3 `NullLogger` are used by default. ID is generated for `RpcRequestInterface` instances. If request is instance of `JsonRpcRequestInterface` and does not contain an ID assigned, the request is traited as notification request and will not receive the response from server.

5. Create a `RpcRequestInterface` instance

With `JsonRpcRequest` class:

```
$request = new \ScayTrase\Api\JsonRpc\JsonRpcRequest('my/method', ['param1' => 'val1'], 'request_id');
$notification = new \ScayTrase\Api\JsonRpc\JsonRpcRequest('my/method', ['param1' => 'val1']);
```

With `JsonRpcNotification` class:

```
$notification = new \ScayTrase\Api\JsonRpc\JsonRpcNotification('my/method', ['param1' => 'val1']);
```

With custom `RpcRequestInterface` implementation:

```
final class MyRpcRequest implements \ScayTrase\Api\Rpc\RpcRequestInterface
{
    public function getMethod()
    {
        return 'my/method';
    }

    public function getParameters()
    {
        return ['param1' => 'val1'];
    }
}

$request = new MyRpcRequest;
```

6. Call the client

```
/** @var \ScayTrase\Api\Rpc\RpcClientInterface $client */
/** @var \ScayTrase\Api\Rpc\RpcRequestInterface $request */

$collection = $client->invoke($request);
$collection = $client->invoke([$request]);
```

The collection object contains the mapping between the requests and the responses

```
/** @var \ScayTrase\Api\Rpc\RpcRequestInterface $request */
/** @var \ScayTrase\Api\Rpc\ResponseCollectionInterface $collection */

$response = $collection->getResponse($request);
```

Decorating
----------

[](#decorating)

Refer [`scaytrase/rpc-common`](https://github.com/scaytrase/rpc-common) base library for some useful decorators:

- `CacheableRpcClient`
- `LazyRpcClient`
- `LoggableRpcClient`
- `ProfiledClient`
- `TraceableClient`

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity35

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~190 days

Total

3

Last Release

3308d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ed906771163ff68cfb365bdd3b8278a3ce1b464f94051ff7ab50c03a30110efe?d=identicon)[scaytrase](/maintainers/scaytrase)

---

Top Contributors

[![scaytrase](https://avatars.githubusercontent.com/u/6578413?v=4)](https://github.com/scaytrase "scaytrase (17 commits)")

---

Tags

apijson-rpcjson-rpc-apijson-rpc-clientjson-rpc2

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/scaytrase-json-rpc-client/health.svg)

```
[![Health](https://phpackages.com/badges/scaytrase-json-rpc-client/health.svg)](https://phpackages.com/packages/scaytrase-json-rpc-client)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[theodo-group/llphant

LLPhant is a library to help you build Generative AI applications.

1.5k311.5k5](/packages/theodo-group-llphant)[wheelpros/fitment-platform-api

Magento 2 (Open Source)

12.1k1.2k](/packages/wheelpros-fitment-platform-api)[avalara/avataxclient

Client library for Avalara's AvaTax suite of business tax calculation and processing services. Uses the REST v2 API.

517.9M7](/packages/avalara-avataxclient)[alexacrm/dynamics-webapi-toolkit

Web API toolkit for Microsoft Dynamics 365 and Dynamics CRM

81324.1k1](/packages/alexacrm-dynamics-webapi-toolkit)[commercetools/commercetools-sdk

The official PHP SDK for the commercetools Composable Commerce APIs

19281.5k](/packages/commercetools-commercetools-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
