Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
function addMenu() {
var ui = SpreadsheetApp.getUi();
ui.createMenu('Datanews API')
.addItem('Get News','myFunction')
function myFunction() {
var API_KEY = "your api key";
var url = "" + API_KEY;
var response = UrlFetchApp.fetch(url);
var data = JSON.parse(response.getContentText());
var results = data.hits;
var sheet = SpreadsheetApp.getActiveSheet();
var header = ["Title", "Description", "URL", "Published Date"]
var items = [header];
results.forEach(function (result) {
items.push([result.title, result.description, result.url, result.pubDate]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment