So I'm totally new at using Google Apps Script, basically just started a few hours ago. Also new to stackoverflow so excuse my formatting. For the life of me, I cant seem to find how to run Bored API to get 20 unique suggested activities.
I am also wondering how to code an If statement within the same cell column , if accessibility is less than or equal to 0.3, then it is Easy If accessibility is between 0.3 and 0.6, then it is Medium If it is 0.6 or more, then it is Hard. (Since google excel doesnt seem to support a cell holding two values at the same time)
Lastly, for the Day column how do I write a snippet that randomly suggests a day to do the suggested activity.
Questions:
- How to run 20 Unique suggested activities using same API?
- How do I code an if statement for Accessibility?
- How to write a snippet that randomly suggest a day to do the suggested activity?
Pls help :'(
Here's the link to the API I used. https://www.boredapi.com/documentation
Here's my current code in Apps Script,
function myFunction() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var mainSheet = ss.getSheetByName("MAIN");
var URL_STRING = "http://www.boredapi.com/api/activity/";
var response = UrlFetchApp.fetch(URL_STRING);
var json = response.getContentText();
var data = JSON.parse(json);
var Activity = data.activity;
var Accessibility = data.accessibility;
var Type = data.type;
var Price = data.price;
var Link = data.link;
var Key = data.key;
mainSheet.getRange('B2').setValue([Activity]);
mainSheet.getRange('C2').setValue([Accessibility]);
mainSheet.getRange('D2').setValue([Type]);
mainSheet.getRange('E2').setValue([Price]);
mainSheet.getRange('G2').setValue([Link]);
mainSheet.getRange('H2').setValue([Key]);
}
Here's the SS of what it looks like, Excel SS