How to use Rest Api?

I want to use XYM Rest API to get a balance of any address … from where I can get that api link and Endpoints for that !

The following documentation shows you all available API endpoints: Endpoints - Symbol Developers
More information on how to use the API: REST Gateway — Symbol Documentation

You can send requests to all available API nodes (have a look at the nodes section in the Symbol Block Explorer to see available nodes).

So for example to get information on a specific account you’d send a request to a node of your choosing like this: http://ngl-dual-001.symbolblockchain.io:3000/accounts/NASYMBOLLK6FSL7GSEMQEAWN7VW55ZSZU25TBOA

2 Likes

NDS2WNRTH53LIVX43ZSAQQDVALZJBJTMKERJSD : this is my address and not getting any responce on this .

It looks like your address has a wrong format. Is there a missing character?

To elaborate a bit on this… I’ve noticed that all responses from the API encode the resulting address in a format that isn’t desktop wallet friendly…

I.e. the response from http://ngl-dual-001.symbolblockchain.io:3000/accounts/NASYMBOLLK6FSL7GSEMQEAWN7VW55ZSZU25TBOA is:
{“account”:{“version”:1,“address”:“68258605CB5ABC592FE691190202CDFD6DDEE659A6BB30B8”,“addressHeight”:“1”,“publicKey”:“BE0B4CF546B7B4F4BBFCFF9F574FDA527C07A53D3FC76F8BB7DB746F8E8E0A9F”,“publicKeyHeight”:“1”,“accountType”:0,“supplementalPublicKeys”:{},“activityBuckets”:[],“mosaics”:[],“importance”:“0”,“importanceHeight”:“0”},“id”:“605140C15F62699A1803DDA9”}

How can one translate the address value ‘68258605CB5ABC592FE691190202CDFD6DDEE659A6BB30B8’ back to ‘NASYMBOLLK6FSL7GSEMQEAWN7VW55ZSZU25TBOA’?

Quick follow-up… I bolded the account balance output from the example provided by @thomasoehri - note that it is in satoshis (divide by 1,000,000 to get user-friendly balance) – http://ngl-dual-001.symbolblockchain.io:3000/accounts/NASYMBOLLK6FSL7GSEMQEAWN7VW55ZSZU25TBOA
Response:
{“account”:{“version”:1,“address”:“68258605CB5ABC592FE691190202CDFD6DDEE659A6BB30B8”,“addressHeight”:“1”,“publicKey”:“BE0B4CF546B7B4F4BBFCFF9F574FDA527C07A53D3FC76F8BB7DB746F8E8E0A9F”,“publicKeyHeight”:“1”,“accountType”:0,“supplementalPublicKeys”:{},“activityBuckets”:[],“mosaics”:[{“id”:“6BED913FA20223F8”,“amount”:“9900000”}],“importance”:“0”,“importanceHeight”:“0”},“id”:“605140C15F62699A1803DDA9”}

Also build functions in python (3.7.6) to convert between hex and base32 addresses (i.e. ‘68258605CB5ABC592FE691190202CDFD6DDEE659A6BB30B8’ to ‘NASYMBOLLK6FSL7GSEMQEAWN7VW55ZSZU25TBOA’)

import base64

def hexToAddress(hexKey):
    return base64.b32encode(bytes.fromhex(hexKey)).decode("utf-8").replace("=","")

def addresstoHex(address):
    address.replace("-","")+"="
    return bytes.hex(base64.b32decode(address))
1 Like

It is strongly suggested NOT to use REST layer directly.
Please consider using TS sdk instead.

(well, depends if you’re developing something or if it’s just for your own needs).