All Projects → pavlov99 → Json Rpc

pavlov99 / Json Rpc

Licence: mit
🔁 JSON-RPC 1/2 transport implementation. Supports python 2/3 and pypy.

Programming Languages

python
139335 projects - #7 most used programming language

Labels

Projects that are alternatives of or similar to Json Rpc

jsonrpc2-zeromq-python
JSON-RPC 2.0 over ZeroMQ in Python
Stars: ✭ 52 (-85.52%)
Mutual labels:  json-rpc
moesif-ethereum-js-example
An example of a Dapp built on web3js/ethereum and using Moesif to monitor JSON-RPC calls.
Stars: ✭ 37 (-89.69%)
Mutual labels:  json-rpc
web3j-scala
Lightweight and idiomatic Scala wrapper around Web3J for Ethereum.
Stars: ✭ 75 (-79.11%)
Mutual labels:  json-rpc
tordam
A library for peer discovery inside the Tor network
Stars: ✭ 13 (-96.38%)
Mutual labels:  json-rpc
instant api
Instantly create an HTTP API with automatic type conversions, JSON RPC, and a Swagger UI. Just add methods!
Stars: ✭ 115 (-67.97%)
Mutual labels:  json-rpc
laravel-bitcoinrpc
Bitcoin JSON-RPC Service Provider for Laravel.
Stars: ✭ 83 (-76.88%)
Mutual labels:  json-rpc
Spooky
An HttpClient based Json RPC 2.0/XML-RPC client for .Net.
Stars: ✭ 16 (-95.54%)
Mutual labels:  json-rpc
Ion Sfu
Pure Go WebRTC SFU
Stars: ✭ 258 (-28.13%)
Mutual labels:  json-rpc
jsonrpcpp
C++ JSON-RPC 2.0 library
Stars: ✭ 97 (-72.98%)
Mutual labels:  json-rpc
aiohttp-rpc
A simple JSON-RPC for aiohttp
Stars: ✭ 22 (-93.87%)
Mutual labels:  json-rpc
aiohttp-json-rpc
Implements JSON-RPC 2.0 using aiohttp
Stars: ✭ 54 (-84.96%)
Mutual labels:  json-rpc
server
Implement the JSON-RPC 2.0 server specification for @laravel.
Stars: ✭ 154 (-57.1%)
Mutual labels:  json-rpc
scala-json-rpc
Let your servers and clients communicate over function calls! JSON-RPC 2.0 library for Scala and Scala.js
Stars: ✭ 38 (-89.42%)
Mutual labels:  json-rpc
JsonRpc.Standard
An asynchronous .NET Standard library for JSON RPC client & server implementation.
Stars: ✭ 27 (-92.48%)
Mutual labels:  json-rpc
rpcsrv
JSON-RPC server based on C++11 and libevent
Stars: ✭ 28 (-92.2%)
Mutual labels:  json-rpc
coreipc
WCF-like service model API for communication over named pipes and TCP. .NET and node.js clients.
Stars: ✭ 22 (-93.87%)
Mutual labels:  json-rpc
web3
⚡️ Web3 PHP is a supercharged PHP API client that allows you to interact with a generic Ethereum RPC.
Stars: ✭ 609 (+69.64%)
Mutual labels:  json-rpc
Joyrpc
high-performance, high-extensibility Java rpc framework.
Stars: ✭ 290 (-19.22%)
Mutual labels:  json-rpc
xeHentai-webui
The web interface for xeHentai https://github.com/fffonion/xeHentai
Stars: ✭ 25 (-93.04%)
Mutual labels:  json-rpc
node-jsonrpc2
JSON-RPC 2.0 server and client library, with HTTP (with Websocket support) and TCP endpoints
Stars: ✭ 103 (-71.31%)
Mutual labels:  json-rpc

json-rpc

.. image:: https://circleci.com/gh/pavlov99/json-rpc/tree/master.svg?style=svg :target: https://circleci.com/gh/pavlov99/json-rpc/tree/master :alt: Build Status

.. image:: https://codecov.io/gh/pavlov99/json-rpc/branch/master/graph/badge.svg :target: https://codecov.io/gh/pavlov99/json-rpc :alt: Coverage Status

.. image:: https://readthedocs.org/projects/json-rpc/badge/?version=latest :target: http://json-rpc.readthedocs.io/en/latest/?badge=latest

.. image:: https://img.shields.io/pypi/v/json-rpc.svg :target: https://pypi.org/project/json-rpc/ :alt: Latest PyPI version

.. image:: https://img.shields.io/pypi/pyversions/json-rpc.svg :target: https://pypi.org/project/json-rpc/ :alt: Supported Python versions

.. image:: https://badges.gitter.im/pavlov99/json-rpc.svg :target: https://gitter.im/pavlov99/json-rpc :alt: Gitter

.. image:: https://opencollective.com/json-rpc/tiers/backer/badge.svg?label=backer&color=brightgreen :target: https://opencollective.com/json-rpc :alt: Bakers

.. image:: https://opencollective.com/json-rpc/tiers/backer/badge.svg?label=sponsor&color=brightgreen :target: https://opencollective.com/json-rpc :alt: Sponsors

JSON-RPC2.0 <http://www.jsonrpc.org/specification>_ and JSON-RPC1.0 <http://json-rpc.org/wiki/specification>_ transport specification implementation. Supports Python 2.6+, Python 3.3+, PyPy. Has optional Django and Flask support. 200+ tests.

Features

This implementation does not have any transport functionality realization, only protocol. Any client or server implementation is easy based on current code, but requires transport libraries, such as requests, gevent or zmq, see examples <https://github.com/pavlov99/json-rpc/tree/master/examples>_.

  • Vanilla Python, no dependencies.
  • 200+ tests for multiple edge cases.
  • Optional backend support for Django, Flask.
  • json-rpc 1.1 and 2.0 support.

Install

.. code-block:: python

pip install json-rpc

Tests

Quickstart ^^^^^^^^^^ This is an essential part of the library as there are a lot of edge cases in JSON-RPC standard. To manage a variety of supported python versions as well as optional backends json-rpc uses tox:

.. code-block:: bash

tox

.. TIP:: During local development use your python version with tox runner. For example, if your are using Python 3.6 run tox -e py36. It is easier to develop functionality for specific version first and then expands it to all of the supported versions.

Continuous integration ^^^^^^^^^^^^^^^^^^^^^^ This project uses CircleCI <https://circleci.com/>_ for continuous integration. All of the python supported versions are managed via tox.ini and .circleci/config.yml files. Master branch test status is displayed on the badge in the beginning of this document.

Test matrix ^^^^^^^^^^^ json-rpc supports multiple python versions: 2.6+, 3.3+, pypy. This introduces difficulties with testing libraries and optional dependencies management. For example, python before version 3.3 does not support mock and there is a limited support for unittest2. Every dependency translates into if-then blocks in the source code and adds complexity to it. Hence, while cross-python support is a core feature of this library, cross-Django or cross-Flask support is limited. In general, json-rpc uses latest stable release which supports current python version. For example, python 2.6 is compatible with Django 1.6 and not compatible with any future versions.

Below is a testing matrix:

+--------+-------+-----------+--------+--------+ | Python | mock | unittest | Django | Flask | +========+=======+===========+========+========+ | 2.6 | 2.0.0 | unittest2 | 1.6 | 0.12.2 | +--------+-------+-----------+--------+--------+ | 2.7 | 2.0.0 | | 1.11 | 0.12.2 | +--------+-------+-----------+--------+--------+ | 3.3 | | | 1.11 | 0.12.2 | +--------+-------+-----------+--------+--------+ | 3.4 | | | 1.11 | 0.12.2 | +--------+-------+-----------+--------+--------+ | 3.5 | | | 1.11 | 0.12.2 | +--------+-------+-----------+--------+--------+ | 3.6 | | | 1.11 | 0.12.2 | +--------+-------+-----------+--------+--------+ | pypy | 2.0.0 | | 1.11 | 0.12.2 | +--------+-------+-----------+--------+--------+ | pypy3 | | | 1.11 | 0.12.2 | +--------+-------+-----------+--------+--------+

Quickstart

Server (uses Werkzeug <http://werkzeug.pocoo.org/>_)

.. code-block:: python

from werkzeug.wrappers import Request, Response
from werkzeug.serving import run_simple

from jsonrpc import JSONRPCResponseManager, dispatcher


@dispatcher.add_method
def foobar(**kwargs):
    return kwargs["foo"] + kwargs["bar"]


@Request.application
def application(request):
    # Dispatcher is dictionary {<method_name>: callable}
    dispatcher["echo"] = lambda s: s
    dispatcher["add"] = lambda a, b: a + b

    response = JSONRPCResponseManager.handle(
        request.data, dispatcher)
    return Response(response.json, mimetype='application/json')


if __name__ == '__main__':
    run_simple('localhost', 4000, application)

Client (uses requests <http://www.python-requests.org/en/latest/>_)

.. code-block:: python

import requests
import json


def main():
    url = "http://localhost:4000/jsonrpc"

    # Example echo method
    payload = {
        "method": "echo",
        "params": ["echome!"],
        "jsonrpc": "2.0",
        "id": 0,
    }
    response = requests.post(url, json=payload).json()

    assert response["result"] == "echome!"
    assert response["jsonrpc"]
    assert response["id"] == 0

if __name__ == "__main__":
    main()

Competitors

There are several libraries <http://en.wikipedia.org/wiki/JSON-RPC#Implementations>_ implementing JSON-RPC protocol. List below represents python libraries, none of the supports python3. tinyrpc looks better than others.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].