Last active
April 20, 2021 19:10
-
-
Save woodwardtw/4f5300309749dcf8455e38eb2f9066c4 to your computer and use it in GitHub Desktop.
Example function in Google Script using https://openweathermap.org/current API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function otherWeather(){ | |
| const ss = SpreadsheetApp.getActiveSpreadsheet();//gets your spreadsheet | |
| const sheet = ss.getSheetByName('APIData');//gets the sheet in your spreadsheet with this name | |
| const apiUrl = 'http://api.openweathermap.org/data/2.5/weather?zip=05753,us&appid=YOUR_API_KEY&units=imperial';//goes to the API | |
| const response = UrlFetchApp.fetch(apiUrl);//gets the API data | |
| const json = JSON.parse(response.getContentText());//treat it as json | |
| const data = [json.dt,json.weather[0].main, json.main.temp, json.wind.speed];//get the data we want from the API | |
| sheet.appendRow(data);//write it to the sheet | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment