Home > database >  Importing data on website using ImportXML with google sheets
Importing data on website using ImportXML with google sheets

Time:04-23

Trying to import the balance on this website

enter image description here

CodePudding user response:

You can use debank's own API and use this custom function:

Custom Function:

function getTotalBalance(user_id) {
  // replace key if you created your own account 
  var key = 'cee6f36d707cf3dfb48e8d857408ef14ec707efa'; 
  var url_balance = `https://pro-openapi.debank.com/v1/user/total_balance?id=${user_id}`;
  var params = {
    'muteHttpExceptions': true,
    'headers': {
      'accept': 'application/json',
      'AccessKey': key
    }
  };

  return JSON.parse(UrlFetchApp.fetch(url_balance, params).getContentText()).total_usd_value;
}

Formula:

=getTotalBalance("0x4e2a7d0e465d8d38aa5a1852d438e60b5832c1b4", B1)

Where the parameters are the user_id andB1 is a checkbox that would refresh the total balance if toggled.

Output:

output

Note:

  • Simply go to https://open.debank.com/ and register an email to get 10000 units for free.
  • Every balance fetch will cost you a specific number of units
  • If your units get exhausted, you can register another mail and use its new key if you dont want to spend money, or pay for additional units if you want.
  • You can use my key until it is exhausted. Note that the custom function won't automatically refresh, but you can use the checkbox method to refresh the value, or install a time trigger to refresh it on a specific time (I recommend using the checkbox method above since doing it on trigger and refresh it on intervals might exhaust your units faster than refreshing it manually when needed)

Reference:

  • Related