https://github.com/bitaps-com/aiojsonrpc
Python asyncio client for JSON-RPC API
https://github.com/bitaps-com/aiojsonrpc
Last synced: about 1 year ago
JSON representation
Python asyncio client for JSON-RPC API
- Host: GitHub
- URL: https://github.com/bitaps-com/aiojsonrpc
- Owner: bitaps-com
- Created: 2017-07-09T15:26:34.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2024-09-06T09:57:43.000Z (almost 2 years ago)
- Last Synced: 2025-04-19T11:55:04.250Z (about 1 year ago)
- Language: Python
- Homepage:
- Size: 10.7 KB
- Stars: 3
- Watchers: 1
- Forks: 9
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# aiojsonrpc
Python asyncio client interface fo JSON-RPC 2.0
#### Example
```angular2html
import asyncio
import aiojsonrpc
async def test(loop):
t = aiojsonrpc.rpc("http://user:password@host:port", loop)
while 1:
p = await t.getinfo()
print(p)
await asyncio.sleep(10)
loop = asyncio.get_event_loop()
loop.create_task(test(loop))
loop.run_forever()
```
```angular2html
python3 test.py
{'timeoffset': 0, 'version': 140200, 'relayfee': 1e-05, 'connections': 18, 'difficulty': 708659466230.332, 'proxy': '', 'testnet': False, 'errors': '', 'blocks': 475003, 'protocolversion': 70015}
```
```angular2html
import asyncio
import aiojsonrpc
async def test(loop):
t = aiojsonrpc.rpc("http://user:password@host:port ", loop)
while 1:
p = await t.batch([["net_peerCount"],
["net_peerCount"],
["eth_getTransactionByHash",
"0xbcad8332d6d68344389f69ec547ecea4a838a2a2cab50407cf7d082531a7c058"]])
print(p)
await asyncio.sleep(10)
loop = asyncio.get_event_loop()
loop.create_task(test(loop))
loop.run_forever()
```
```angular2html
python3 test.py
[{'jsonrpc': '2.0', 'id': 1, 'result': '0x19'}, {'jsonrpc': '2.0', 'id': 2, 'result': '0x19'}, {'jsonrpc': '2.0', 'id': 3, 'result': None}]
```