RaiBlocks Python RPC client for rai_node
Project description
# RaiBlocks Python RPC client for rai_node
[](https://travis-ci.org/dourvaris/raiblocks-py)
[](https://travis-ci.org/dourvaris/raiblocks-py)
A python wrapper for the [RaiBlocks RPC server](https://github.com/clemahieu/raiblocks)
which tries to make it a little easier to work with by converting RPC responses
to native python ones and exposing a pythonic api for making RPC calls.
Note: This library is still new so there may be bugs and api changes, PRs are welcome.
## Install
```
pip install raiblocks
```
## Usage
```python
>>> from raiblocks import RPCClient
>>> rpc = RPCClient('http://localhost:7076')
>>> rpc.version()
{'rpc_version': 1, 'store_version': 10, 'node_vendor': 'RaiBlocks 9.0'}
>>> rpc.peers()
{
'[::ffff:75.171.168.5]:7075': 4,
'[::ffff:108.44.38.183]:1032': 4
}
```
The client exposes the methods that can be found here: https://github.com/clemahieu/raiblocks/wiki/RPC-protocol
At the moment the client replicates the RPC API which means there are some
instances where the same method will return different types eg:
```
# Returns a list
>>> rpc.pending(
... "xrb_1111111111111111111111111111111111111111111111111117353trpda")
[
'3342AEE6ED02A3ED8D84A2EEE4808157C35EB536D464C7EAD66CFFA23232F14C',
'1AAE335A94C5DA1E4E1D0B45C3B100CCA241CC5BC557E24BB367C779D55E3A0C',
'20D5D6EA5CA355B11A0E3C11A74FBB4E91D126F4B3FD97232945D451A621E6F7'
]
```
```
# Returns a dict
>>> rpc.pending(
... "xrb_1111111111111111111111111111111111111111111111111117353trpda",
... threshold=10e30)
{
'3342AEE6ED02A3ED8D84A2EEE4808157C35EB536D464C7EAD66CFFA23232F14C': 100000000000000000000000000000000,
'1AAE335A94C5DA1E4E1D0B45C3B100CCA241CC5BC557E24BB367C779D55E3A0C': 95000000000000000000000000000000,
'20D5D6EA5CA355B11A0E3C11A74FBB4E91D126F4B3FD97232945D451A621E6F7': 36968007000000000000000000000000
}
```
## Development
```
virtualenv venv
source venv/bin/activate
pip install -r requirements.txt -r test-requirements.txt
```
### Tests
Regular
```
pytest
```
Coverage:
```
./coverage
```
[](https://travis-ci.org/dourvaris/raiblocks-py)
[](https://travis-ci.org/dourvaris/raiblocks-py)
A python wrapper for the [RaiBlocks RPC server](https://github.com/clemahieu/raiblocks)
which tries to make it a little easier to work with by converting RPC responses
to native python ones and exposing a pythonic api for making RPC calls.
Note: This library is still new so there may be bugs and api changes, PRs are welcome.
## Install
```
pip install raiblocks
```
## Usage
```python
>>> from raiblocks import RPCClient
>>> rpc = RPCClient('http://localhost:7076')
>>> rpc.version()
{'rpc_version': 1, 'store_version': 10, 'node_vendor': 'RaiBlocks 9.0'}
>>> rpc.peers()
{
'[::ffff:75.171.168.5]:7075': 4,
'[::ffff:108.44.38.183]:1032': 4
}
```
The client exposes the methods that can be found here: https://github.com/clemahieu/raiblocks/wiki/RPC-protocol
At the moment the client replicates the RPC API which means there are some
instances where the same method will return different types eg:
```
# Returns a list
>>> rpc.pending(
... "xrb_1111111111111111111111111111111111111111111111111117353trpda")
[
'3342AEE6ED02A3ED8D84A2EEE4808157C35EB536D464C7EAD66CFFA23232F14C',
'1AAE335A94C5DA1E4E1D0B45C3B100CCA241CC5BC557E24BB367C779D55E3A0C',
'20D5D6EA5CA355B11A0E3C11A74FBB4E91D126F4B3FD97232945D451A621E6F7'
]
```
```
# Returns a dict
>>> rpc.pending(
... "xrb_1111111111111111111111111111111111111111111111111117353trpda",
... threshold=10e30)
{
'3342AEE6ED02A3ED8D84A2EEE4808157C35EB536D464C7EAD66CFFA23232F14C': 100000000000000000000000000000000,
'1AAE335A94C5DA1E4E1D0B45C3B100CCA241CC5BC557E24BB367C779D55E3A0C': 95000000000000000000000000000000,
'20D5D6EA5CA355B11A0E3C11A74FBB4E91D126F4B3FD97232945D451A621E6F7': 36968007000000000000000000000000
}
```
## Development
```
virtualenv venv
source venv/bin/activate
pip install -r requirements.txt -r test-requirements.txt
```
### Tests
Regular
```
pytest
```
Coverage:
```
./coverage
```
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
raiblocks-1.0.0rc3.tar.gz
(3.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file raiblocks-1.0.0rc3.tar.gz.
File metadata
- Download URL: raiblocks-1.0.0rc3.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f2acecceeffa1b8728ea5cb3c885dad3f32e6961c132772b915482ed4df58af4
|
|
| MD5 |
9675b135f299b3cd470fb69d925de157
|
|
| BLAKE2b-256 |
3f480399f9ce74c711c00756c8678505bd9b07186cfe78e02c7ffdff19663881
|
File details
Details for the file raiblocks-1.0.0rc3-py2.py3-none-any.whl.
File metadata
- Download URL: raiblocks-1.0.0rc3-py2.py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dbc36187e1047eaf86e45fb109ac9157ac06ef70563e73208faf3fdc6812c60b
|
|
| MD5 |
da13bcc8e2b542209b92994565f6c458
|
|
| BLAKE2b-256 |
6a0a5c7118bcfebb6dbc3d74430196dee98870b1fc3e9075ac94c5e44f877c92
|