grapheneapi.grapheneapi module

class grapheneapi.grapheneapi.GrapheneAPI(host, port, username='', password='')

Bases: object


This class serves as an abstraction layer for easy use of the Grapehene API.

  • host (str) – Host of the API server
  • port (int) – Port to connect to
  • username (str) – Username for Authentication (if required, defaults to “”)
  • password (str) – Password for Authentication (if required, defaults to “”)

All RPC commands of the Graphene client are exposed as methods in the class grapheneapi. Once an instance of GrapheneAPI is created with host, port, username, and password, e.g.,

from grapheneapi import GrapheneAPI
rpc = GrapheneAPI("localhost", 8092, "", "")

any call available to that port can be issued using the instance via the syntax rpc.*command*(parameters). Example:


A distinction has to be made whether the connection is made to a witness/full node which handles the blockchain and P2P network, or a cli-wallet that handles wallet related actions! The available commands differ drastically!

If you are connected to a wallet, you can simply initiate a transfer with:

res = client.transfer("sender","receiver","5", "USD", "memo", True);

Again, the witness node does not offer access to construct any transactions, and hence the calls available to the witness-rpc can be seen as read-only for the blockchain.


Manual execute a command on API (internally used)

param str payload: The payload containing the request return: Servers answer to the query rtype: json raises RPCConnection: if no connction can be made raises UnauthorizedError: if the user is not authorized raise ValueError: if the API returns a non-JSON formated answer

It is not recommended to use this method directly, unless you know what you are doing. All calls available to the API will be wrapped to methods directly:

info ->