Weather from openweathermap API

Hey guys,
has someone experience with the openweathermap API?
I’ve already a script in google that gives me the weather data from the city I select in my app.
This workarround unfortunately is not key because I get the weather just after I added a new row.
So my questions is: how can I get the weather directly in the app by just selecting the City? Any Ideas?

This is the code i already produced for google:
When you wann use it, just change [KEY] to your API-Key and change the names of the spreadsheets:

function appendWeather() {

var Wetter = getWeatherData() // 1) this will execute the function getWeatherData and put the result in weatherData

saveRecordInSheet(Wetter) // 11) We use the result to save it using saveRecordInSheet function.

//This gets the date from the openweathermap api and parses it to a record.
function getWeatherData() {

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var Stadt = sheet.getSheetValues(1,4,1,1); //cell with the value of the city

var url = “” + Stadt + “,de&appid=[KEY]&units=metric”;
var response = UrlFetchApp.fetch(url, { // 4) call the URL
headers: {
‘Content-Type’: ‘application/json’, // 5) Make sure we use JSON as transport
‘Accept’: ‘application/json’
var json = response.getContentText(); // 6) Get the content of the API call (this gets the response as TEXT(string)
var Datum = JSON.parse(json); // 7) Parse the TEXT to JSON (make objects out of it)
var Wetter =[0].main // 8) Get the weather variable
var Temperatur = Datum.main.temp // 9) get the temperature variable
return [new Date(), Wetter, Temperatur] // 10) add the date and Return them (as a record)

// Save a record in the spreadsheet
function saveRecordInSheet(record) {
var currentSheet = SpreadsheetApp.getActiveSheet(); // 12) This gets the current Sheet in
currentSheet.appendRow(record); // 13) Append the record at the bottom of the current Sheet

@Peter - quick question about the community. Do you want a tag for Google App Script, or should that go to the new google app script community?!forum/google-apps-script-community

I am not a fan of their new forum, but was wondering if you want scripting addressed here as well. I heavily use gSheet as my data source so I would like it, but it’s not the only back end, and don’t want to dilute the focus on Appsheets.

Up to you guys but maybe we should do a poll? Or… at least a tag for Apps Script GAS)?

1 Like

Hey @Mike, this is an important question, thanks for bringing it up. I’m inclined to say that we would like to focus just on AppSheet level functionality for now, but let me discuss with the team.


I can imagine wanting to keep this community focused on Appsheet and not the back ends (as there are many choices). The thing I struggle with is the two together make a very powerful partnership. Anyway… would hate to dilute the focus of this growing community. Thanks for listening.

1 Like

Hey @Mike,
thank you for this interessting discousion and I definately understand the point.
But the main quastion was not about using google, the question was about using an API directly in Appsheet. The googel scrpit was just the idea to give to community my knowledge back, not just taking.
So is there a way to implement it directly in Appsheet or any other idea?

Apologies @Open_YourEyes. I did not intend to hijack your thread. Should have opened another thread. I don’t work with openweathermap API so cannot advise.

1 Like