4

I'm trying to just get the SOL balance, but I get returned a full list of tokens.

https://public-api.solscan.io/account/tokens?account=34qHtfUqxgsnTDewwoXEXuhknymJ1sqoXD7H38aKADEw

I'm using solscan public api's. But should I be using something else to get SOL balance of an address?

1

2 Answers 2

5

You can use Solana JSON RPC API by calling getBalance request example

Or @solana/web3.js using connection.getBalance example

6
  • i want to do it without installing a library. mainly want to just fetch this info from an REST api call using curl. Commented Aug 25, 2022 at 15:57
  • Yeah already told you the way to do it. You can use Solana JSON RPC API by calling getBalance request example :)
    – vicyyn
    Commented Aug 25, 2022 at 19:20
  • curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' {"jsonrpc":"2.0", "id":1, "method":"getBalance", "params":["83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri"]} '
    – vicyyn
    Commented Aug 25, 2022 at 19:20
  • I'm trying to do it with: public-api.solscan.io --- i don't want to install anything on my server or local. Commented Aug 29, 2022 at 16:01
0

You can use Shyft's get_balance REST API, to get the sol balance of any account address on Solana:

https://documenter.getpostman.com/view/18419720/UzQvt5Kf#76235c33-1f0e-4724-ad09-ed46d1da7323

Here is the link to the documentation: https://docs.shyft.to/start-hacking/wallet#get-balance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.