bhiveapi.graphenerpc module¶
graphennewsrpc.
-
class
bhiveapi.graphenerpc.
GrapheneRPC
(urls, user=None, password=None, **kwargs)¶ Bases:
object
This class allows to call API methods synchronously, without callbacks.
It logs warnings and errors.
- Parameters
urls (str) – Either a single Websocket/Http URL, or a list of URLs
user (str) – Username for Authentication
password (str) – Password for Authentication
num_retries (int) – Try x times to num_retries to a node on disconnect, -1 for indefinitely (default is 100)
num_retries_call (int) – Repeat num_retries_call times a rpc call on node error (default is 5)
timeout (int) – Timeout setting for https nodes (default is 60)
autoconnect (bool) – When set to false, connection is performed on the first rpc call (default is True)
use_condenser (bool) – Use the old condenser_api rpc protocol on nodes with version 0.19.4 or higher. The settings has no effect on nodes with version of 0.19.3 or lower.
custom_chains (dict) – custom chain which should be added to the known chains
Available APIs:
database
network_node
network_broadcast
Usage:
from bhiveapi.graphenerpc import GrapheneRPC ws = GrapheneRPC("wss://hived.pevo.science","","") print(ws.get_account_count()) ws = GrapheneRPC("https://api.hive.blog","","") print(ws.get_account_count())
Note
This class allows to call methods available via websocket. If you want to use the notification subsystem, please use
GrapheneWebsocket
instead.-
property
error_cnt
¶
-
property
error_cnt_call
¶
-
get_network
(props=None)¶ Identify the connected network. This call returns a dictionary with keys chain_id, core_symbol and prefix
-
get_request_id
()¶ Get request id.
-
get_use_appbase
()¶ Returns True if appbase ready and appbase calls are set
-
is_appbase_ready
()¶ Check if node is appbase ready
-
next
()¶ Switches to the next node url
-
property
num_retries
¶
-
property
num_retries_call
¶
-
request_send
(payload)¶
-
rpcclose
()¶ Close Websocket
-
rpcconnect
(next_url=True)¶ Connect to next url in a loop.
-
rpcexec
(payload)¶ Execute a call by sending the payload.
- Parameters
payload (json) – Payload data
- Raises
ValueError – if the server does not respond in proper JSON format
RPCError – if the server returns an error
-
rpclogin
(user, password)¶ Login into Websocket
-
version_string_to_int
(network_version)¶
-
ws_send
(payload)¶
-
class
bhiveapi.graphenerpc.
SessionInstance
¶ Bases:
object
Singelton for the Session Instance
-
instance
= None¶
-
-
bhiveapi.graphenerpc.
create_ws_instance
(use_ssl=True, enable_multithread=True)¶ Get websocket instance
-
bhiveapi.graphenerpc.
set_session_instance
(instance)¶ Set session instance
Get session instance