How to get the correct XPath for Google Sheets formula ImportXML
Solution 1:
Create a custom function by:
- Opening Script Editor (Tools > Script Editor or Extensions > Apps Scripts)
And then enter the following within the script:
/**
* @return Specific value out of the value of different fields
* @customfunction
*/
function PARSEVALUE(Url,itemKey) {
var res = UrlFetchApp.fetch(Url);
var content = res.getContentText();
var jsonObject = JSON.parse(content);
return jsonObject[0][itemKey];
}
In your spreadsheet, use the function like:
=PARSEVALUE("https://api-osmosis.imperator.co/tokens/v1/DSM","price")
There are different values for different keys, as in price
,symbol
,name
,liquidity
,volume_24h
e.t.c. you can grab using this function.