Random Number Generator (RNG)
Other Documentation
Popular API Calls

Overview

Some of the most interesting API calls for exchanges and gateways are listed in this document.
We will now take a look at some sample outputs for some of the API calls.

API Calls

list_account_balances

List the balances of an account. Each account can have multiple balances, one for each type of asset owned by that account. The returned list will only contain assets for which the account has a nonzero balance.
1
vector<asset> graphene::wallet::wallet_api::list_account_balances(
2
const string &id)
Copied!
Parameters
Return
Script
Result
  • id: the name or id of the account whose balances you want
A list of the given account’s balances.
1
import json
2
from grapheneapi import GrapheneAPI
3
client = GrapheneAPI("localhost", 8092, "", "")
4
res = client.list_account_balances("dan")
5
print(json.dumps(res,indent=4))
Copied!
1
[
2
{
3
"asset_id": "1.3.0",
4
"amount": "331104701530"
5
},
6
{
7
"asset_id": "1.3.511",
8
"amount": 3844848635
9
},
10
{
11
"asset_id": "1.3.427",
12
"amount": 8638
13
},
14
{
15
"asset_id": "1.3.536",
16
"amount": 31957981
17
}
18
]
Copied!

transfer

Transfer an amount from one account to another.
1
signed_transaction graphene::wallet::wallet_api::transfer(
2
string from,
3
string to,
4
string amount,
5
string asset_symbol,
6
string memo,
7
bool broadcast = false)
Copied!
Parameters
Return
Script
Result
  • from: the name or id of the account sending the funds
  • to: the name or id of the account receiving the funds
  • amount: the amount to send (in nominal units to send half of a BTS, specify 0.5)
  • asset_symbol: the symbol or id of the asset to send
  • memo: a memo to attach to the transaction. The memo will be encrypted in the transaction and readable for the receiver. There is no length limit other than the limit imposed by maximum transaction size, but transaction increase with transaction size
  • broadcast: true to broadcast the transaction on the network
The final parameter True states that the signed transaction will be broadcast. If this parameter is False the transaction will be signed but not broadcast, hence not executed.
The signed transaction transferring funds.
1
import json
2
from grapheneapi import GrapheneAPI
3
client = GrapheneAPI("localhost", 8092, "", "")
4
res = client.transfer("fromaccount","toaccount","10", "USD", "$10 gift", True);
5
print(json.dumps(res,indent=4))
Copied!
1
{
2
"ref_block_num": 18,
3
"ref_block_prefix": 2320098938,
4
"expiration": "2015-10-13T13:56:15",
5
"operations": [[
6
0,{
7
"fee": {
8
"amount": 2089843,
9
"asset_id": "1.3.0"
10
},
11
"from": "1.2.17",
12
"to": "1.2.7",
13
"amount": {
14
"amount": 10000000,
15
"asset_id": "1.3.0"
16
},
17
"memo": {
18
"from": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
19
"to": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
20
"nonce": "16430576185191232340",
21
"message": "74d0e455e2e5587b7dc85380102c3291"
22
},
23
"extensions": []
24
}
25
]
26
],
27
"extensions": [],
28
"signatures": [
29
"1f147aed197a2925038e4821da54bd7818472ebe25257ac9a7ea66429494e7242d0dc13c55c6840614e6da6a5bf65ae609a436d13a3174fd12f073550f51c8e565"
30
]
31
}
Copied!

transfer2

This method works just like transfer, except it always broadcasts and returns the transaction ID (hash) along with the signed transaction.
1
pair<transaction_id_type, signed_transaction> graphene::wallet::wallet_api::transfer2(
2
string from,
3
string to,
4
string amount,
5
string asset_symbol,
6
string memo)
Copied!
Parameters
Return
Script
Result
  • from: the name or id of the account sending the funds
  • to: the name or id of the account receiving the funds
  • amount: the amount to send
  • asset_symbol: the symbol or id of the asset to send
  • memo: a memo to attach to the transaction. The memo will be encrypted in the transaction and readable for the receiver. There is no length limit other than the limit imposed by maximum transaction size, but transaction increase with transaction size
The transaction ID (hash) along with the signed transaction transferring funds
1
import json
2
from grapheneapi import GrapheneAPI
3
client = GrapheneAPI("localhost", 8092, "", "")
4
res = client.transfer2("fromaccount","toaccount","10", "USD", "$10 gift");
5
print(json.dumps(res,indent=4))
Copied!
1
[b546a75a891b5c51de6d1aafd40d10e91a717bb3,{
2
"ref_block_num": 18,
3
"ref_block_prefix": 2320098938,
4
"expiration": "2015-10-13T13:56:15",
5
"operations": [[
6
0,{
7
"fee": {
8
"amount": 2089843,
9
"asset_id": "1.3.0"
10
},
11
"from": "1.2.17",
12
"to": "1.2.7",
13
"amount": {
14
"amount": 10000000,
15
"asset_id": "1.3.0"
16
},
17
"memo": {
18
"from": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
19
"to": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
20
"nonce": "16430576185191232340",
21
"message": "74d0e455e2e5587b7dc85380102c3291"
22
},
23
"extensions": []
24
}
25
]
26
],
27
"extensions": [],
28
"signatures": [
29
"1f147aed197a2925038e4821da54bd7818472ebe25257ac9a7ea66429494e7242d0dc13c55c6840614e6da6a5bf65ae609a436d13a3174fd12f073550f51c8e565"
30
]
31
}
32
]
Copied!

get_account_history

Returns the most recent operations on the named account.
This returns a list of operation history objects, which describe activity on the account.
1
vector<operation_detail> graphene::wallet::wallet_api::get_account_history(
2
string name,
3
int limit)const
Copied!
Parameters
Return
Script
Result
  • name: the name or id of the account
  • limit: the number of entries to return (starting from the most recent)
A list of operation_history_objects.
1
import json
2
from grapheneapi import GrapheneAPI
3
client = GrapheneAPI("localhost", 8092, "", "")
4
res = client.get_account_history("dan", 1)
5
print(json.dumps(res,indent=4))
Copied!
1
[
2
{
3
"description": "fill_order_operation dan fee: 0 CORE",
4
"op": {
5
"block_num": 28672,
6
"op": [
7
4,
8
{
9
"pays": {
10
"asset_id": "1.3.536",
11
"amount": 20000
12
},
13
"fee": {
14
"asset_id": "1.3.0",
15
"amount": 0
16
},
17
"order_id": "1.7.1459",
18
"account_id": "1.2.21532",
19
"receives": {
20
"asset_id": "1.3.0",
21
"amount": 50000000
22
}
23
}
24
],
25
"id": "1.11.213277",
26
"trx_in_block": 0,
27
"virtual_op": 47888,
28
"op_in_trx": 0,
29
"result": [
30
0,
31
{}
32
]
33
},
34
"memo": ""
35
}
36
]
Copied!

get_object

Returns the blockchain object corresponding to the given id.
This generic function can be used to retrieve any object from the blockchain that is assigned an ID. Certain types of objects have specialized convenience functions to return their objects e.g., assets have get_asset(), accounts have get_account(), but this function will work for any object.
1
variant graphene::wallet::wallet_api::get_object(
2
object_id_type id)const
Copied!
Parameters
Return
Script
Result
  • id: the id of the object to return
The requested object.
1
import json
2
from grapheneapi import GrapheneAPI
3
client = GrapheneAPI("localhost", 8092, "", "")
4
res = client.get_object("1.11.213277")
5
print(json.dumps(res,indent=4))
Copied!
1
{
2
"trx_in_block": 0,
3
"id": "1.11.213277",
4
"block_num": 28672,
5
"op": [
6
4,
7
{
8
"fee": {
9
"asset_id": "1.3.0",
10
"amount": 0
11
},
12
"receives": {
13
"asset_id": "1.3.0",
14
"amount": 50000000
15
},
16
"pays": {
17
"asset_id": "1.3.536",
18
"amount": 20000
19
},
20
"account_id": "1.2.21532",
21
"order_id": "1.7.1459"
22
}
23
],
24
"result": [
25
0,
26
{}
27
],
28
"op_in_trx": 0,
29
"virtual_op": 47888
30
}
Copied!

get_asset

Returns information about the given asset.
1
extended_asset_object graphene::wallet::wallet_api::get_asset(
2
string asset_name_or_id)const
Copied!
Parameters
Return
Script
Result
  • asset_name_or_id: the symbol or id of the asset in question
The information about the asset stored in the block chain.
1
import json
2
from grapheneapi import GrapheneAPI
3
client = GrapheneAPI("localhost", 8092, "", "")
4
res = client.get_asset("USD")
5
print(json.dumps(res,indent=4))
Copied!
1
{
2
"symbol": "USD",
3
"issuer": "1.2.1",
4
"options": {
5
"description": "1 United States dollar",
6
"whitelist_authorities": [],
7
"flags": 0,
8
"extensions": [],
9
"core_exchange_rate": {
10
"quote": {
11
"asset_id": "1.3.536",
12
"amount": 11
13
},
14
"base": {
15
"asset_id": "1.3.0",
16
"amount": 22428
17
}
18
},
19
"whitelist_markets": [],
20
"max_supply": "1000000000000000",
21
"blacklist_markets": [],
22
"issuer_permissions": 79,
23
"market_fee_percent": 0,
24
"max_market_fee": "1000000000000000",
25
"blacklist_authorities": []
26
},
27
"dynamic_asset_data_id": "2.3.536",
28
"bitasset_data_id": "2.4.32",
29
"id": "1.3.536",
30
"precision": 4
31
}
Copied!