GetTokenBalance()
Summary
Route | Type | Example |
---|---|---|
/monitor/gettokenbalance | POST | http://apinode.credits.com/api/monitor/gettokenbalance |
Description
Gets the token balance of a wallet.
Request
Request Structure
x
{
// Parameters common for all request
// Wallet address
"PublicKey": "base58_string",
“tokens”: “string” // List of tokens separated by a comma
}
Request Parameters
string: PublicKey - Wallet address (public key) in Base58
string: tokens - List of tokens separated by a comma (“aaa, bbb, ddd”). If not specified, a list of all stored tokens will be displayed
Response
JSON output depends on the request type and its success.
If there’s an error, request returns to the node basic Result:
- Success: False
- Message:
If successful, requested information is returned.
Response Structure
{
“tokens”: [
“name” : “string_value”,
“balance”: “string_value”]
}
Example Code
import requests
import json
def gettokenbalance():
url = 'http://apinode.credits.com/api/monitor/gettokenbalance'
headers = {
'Content-type': 'application/json'
, 'Accept': 'application/json'
, 'Content-Encoding': 'utf-8'
}
data = {
"authKey": ""
, "networkAlias":"Mainnet"
, "PublicKey":"HhhRGwgA3W5qcNFrLC3odC4GmbkQnhdEc5XPqBiRW3Wx"
, "tokens": "BNX"
}
answer = requests.post(url, data=json.dumps(data), headers=headers)
response = answer.json()
print(response)
gettokenbalance()