Import data from Firebase to Glide

Hello everyone, everything good?
For those who need to import data from Firebase into the spreadsheet in Glide, I am providing a Script that you can edit according to your need.
I hope they help!

Good studies!


url=“Your Firebase bank URL.json?auth=API KEY”
xpath =“NAME DATABASE”

function addProduct() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(“TAB NAME”);
sheet.appendRow([IMPORTJSON()]);
}
function IMPORTJSON(){
try{
var res = UrlFetchApp.fetch(url);
var content = res.getContentText();
var json = JSON.parse(content);
var patharray = xpath.split("/");

for (var i=0;i<patharray.length;i++){
  json = json[patharray[i]];

  }

if(typeof(json) === "undefined"){
  return "Node Not Availabe";
} else if(typeof(json) === "object"){
  var tempArr = [];

  for(var obj in json){
    tempArr.push([obj.json[obj]]);
  }
  return tempArr;
} else if(typeof(json) !== "object") {
  return json;
}

}
catch(err){
return “Error getting data”;
}
}


This script connects to your Firebase Database and collects the information by saving it in the spreadsheet in the first column that was defined in this case.

See you later.

4 Likes

Super !

1 Like