.. rubric:: :doc:`index`
jsonrpcclient Examples
**********************
Showing how to send JSON-RPC requests using various frameworks and transport
protocols.
.. contents::
:local:
aiohttp
=======
``aiohttpClient`` uses the `aiohttp `__
library::
$ pip install 'jsonrpcclient[aiohttp]'
.. literalinclude:: ../examples/aiohttp_client.py
Requests
========
``HTTPClient`` uses the `Requests `__ library.
::
$ pip install 'jsonrpcclient[requests]'
.. literalinclude:: ../examples/http_client.py
Tornado
=======
``TornadoClient`` uses `Tornado `__ to send an
asynchronous request.
::
$ pip install 'jsonrpcclient[tornado]'
.. literalinclude:: ../examples/tornado_client.py
Note the ``async``/``await`` syntax requires Python 3.5+. Prior to that use
`@gen.coroutine and yield
`__.
::
$ python client.py
INFO:jsonrpcclient.client.request:{"jsonrpc": "2.0", "method": "ping", "id": 1}
INFO:jsonrpcclient.client.response:{"jsonrpc": "2.0", "result": "pong", "id": 1}
pong
See `blog post `__.
Websockets
==========
``WebSocketsClient`` uses the `websockets `__
library::
$ pip install 'jsonrpcclient[aiohttp]'
.. literalinclude:: ../examples/aiohttp_client.py
ZeroMQ
======
``ZeroMQClient`` uses `pyzmq `__ for comms with
a ZeroMQ server.
::
$ pip install 'jsonrpcclient[pyzmq]'
.. literalinclude:: ../examples/zeromq_client.py
See `blog post `__.