Home > Enterprise >  How do I use a wildcard in Binance API to return all quote assets for a particular base asset
How do I use a wildcard in Binance API to return all quote assets for a particular base asset

Time:05-29

I'm using Binance to Google Sheets which is coded in Google Apps Script to get data from Binance API into a Google Sheet. (enter image description here

and the following script

function getDataJSON(url, xpath) {
  let resultat = [];
  function getData(elem, list) {
    var prov = []
    list.forEach(function (path) { prov.push(elem[path]) })
    resultat.push(prov)
  }
  try {
    var json = JSON.parse(UrlFetchApp.fetch(url).getContentText())
    var list = xpath.join().split(",")
    if (json.length) { json.forEach(function (elem) { getData(elem, list) }) } else { getData(json, list) }
    return resultat
  }
  catch (e) {
    return ('No data !');
  }
}

you can add a dummy parameter in getDataJSON in third position (as a checkbox) to refresh.

CodePudding user response:

I combined the solution above with the Binance to Google Sheets function I got from https://github.com/diegomanuel/binance-to-google-sheets. This is the formula which produces exactly what I need:

=query(BINANCE("prices"),"where Col1 like '%USDT'")
  • Related