To fetch NUM balance on Mainnet for a specific wallet, you can use the following API
API Endpoint: https://eoodjeosrg20qti.m.pipedream.netCost:0, free to usePOST/Description:This endpoint allows you fetch NUM balance on Numbers MainnetHeaders:Content-Type: application/jsonRequest Body:{"wallet": "0x1234567890abcdef1234567890abcdef12345678"}Examples:curl -XPOST https://eoodjeosrg20qti.m.pipedream.net \-H"Content-Type: application/json" \-d '{"wallet": "0x1234567890abcdef1234567890abcdef12345678"}'
In the API call, the Request body needs to have a key-value pair as "wallet" and a valid wallet address as value. More examples can be found below:
Replace the wallet in the examples to any wallet address you prefer.
Source code with nodejs14.x:
import { providers, BigNumber } from"ethers";asyncfunctiongetUserNumBalance(userWallet) {// Create a provider to connect to the Ethereum networkconstnumProvider=newproviders.JsonRpcProvider("https://mainnetrpc.num.network" );// Get the balance of the wallet as a BigNumber objectconstuserNumBalanceObj=awaitnumProvider.getBalance(userWallet);// Convert the balance from wei to EtherconstweiPerEther=BigNumber.from(10).pow(14);constbalanceInEther=userNumBalanceObj.div(weiPerEther)/10000;// Convert the balance to a string and return itconstuserNumBalance=balanceInEther.toFixed(4);return userNumBalance;}exportdefaultdefineComponent({asyncrun({ steps, $ }) {// Get the user address from the previous stepconstuserAddress=steps.trigger.event.body.wallet;// Call the getUserNumBalance() function with the user addressconstbalance=awaitgetUserNumBalance(userAddress);// Return the balance to use it in future stepsawait$.respond({ status:200, headers: {}, body: {"balance": balance}, }) },});
On All Networks
To fetch NUM balance on ALL NETWORKS for a specific wallet, you can use the following API with your Capture Token:
API Endpoint: https://eoiu9t1jdjlxx5l.m.pipedream.netCost:0.01NUMPOST/Description:This endpoint allows you to create a new wallet with the given address.Headers:Content-Type: application/jsonAuthorization: token YOUR_CAPTURE_TOKENAuthentication:The API requires a valid token for Authorization. You can pass it in the headers of the request usingthe following format:"Authorization: token YOUR_CAPTURE_TOKEN"RequestBody:{"wallet":"0x1234567890abcdef1234567890abcdef12345678"}Examples:curl -XPOSThttps://eoiu9t1jdjlxx5l.m.pipedream.net \ -H"Content-Type: application/json" \ -H"Authorization: token YOUR_CAPTURE_TOKEN" \ -d'{"wallet": "0x1234567890abcdef1234567890abcdef12345678"}'
In the API call, the Request body needs to have a key-value pair as "wallet" and a valid wallet address as value. The API will return the NUM balance for the specified wallet. Please note, this API requires authorization with your Capture Token. Follow the instructions to register and acquire it.