Importing Abstra data to Google Sheets
Sometimes, you want to have access to your data on google sheets, so operational teams can work on top of it. With Abstra APIs, you can easily access them.
After reading Calling Connectors or Tables from outside Abstra. You will be able to have a query to be executed.
Google sheets allow javascript-like scripting using their Google Scripts product. You can easily one script on your spreadsheet by clicking on "Apps Scripts" on the "Extensions" menu.

Apps script allows you to fetch your data from Abstra APIs
After you click in "Apps Script", you should be redirected to a code editor like this

You can reutilize your scripts across all spreadsheets
Here is an example of a script for inserting the result of one query into the spreadsheet
function getDataFromAbstra() {
const response = UrlFetchApp.fetch(
"https://tables.abstra.cloud/execute/{{{ QUERY ID TO BE EXECUTED }}",
{
headers: {
"Content-Type" : "application/json",
"Authorization": "Bearer {{YOUR TOKEN SHOULD COME HERE}}",
},
method: "post"
}
);
const records = JSON.parse(response.getContentText());
const columns = Object.keys(records[0]);
const rows = records.map(record => columns.map(column => record[column]));
Logger.log(columns);
Logger.log(rows);
const sheet = SpreadsheetApp.getActiveSheet();
sheet.clear();
sheet.getRange(1, 1, 1, columns.length).setValues([columns]);
sheet.getRange(2, 1, rows.length, columns.length).setValues(rows);
}
Notice that this script will replace the active sheet with the data you fetched. Make sure to adapt this script to your needs
Last modified 1yr ago