Re: Pull in a Weather API using a script

397 0
Showing results for 
Search instead for 
Did you mean: 
5 - Automation Enthusiast
5 - Automation Enthusiast

Hi Guys,

Wondering if anyone can help me out with this one.

I want to create a script that incorporates an API to The script will draw the information from the field and the field in Airtable and the result will be the weather forecast for that location on that day into a field called in Airtable.

Im pretty new to all this, so the most descriptive information would be really appreciated!

Thanks guys!


7 Replies 7

Hello James,

Not sure about but if you are familiar with, I have a script that can get their data.

First, head here to to get an api key.

let table = base.getTable('weather_data');
 let url = await fetch('');
let json = await url.json();

    //Name your columns '', 'main.temp', the strings in the double quotes
    //Loop over the json object (key/value pairs)
         recordId = await table.createRecordAsync({
              "main.temp": json.main.temp,
              "main.feels_like": json.main.feels_like,
              "main.pressure": json.main.pressure,
              "main.humidity": json.main.humidity,
              "main.temp_min": json.main.temp_min,
              "main.temp_max": json.main.temp_max,
              "wind.speed": json.wind.speed,
              "wind.deg": json.wind.deg,
              "wind.gust": json.wind.gust,
              "visibility": json.visibility,
              "dt": json.dt,
              "sys.sunset": json.sys.sunset,
              "sys.sunrise": json.sys.sunrise,
              "timezone": json.timezone,  

A few things to note…

  • This example uses my city code. ?id=CITYCODE
  • Looks like you want a daily forecast. This will get current. If you poke around that link you will see many different options. For example, using this url fetch(‘{city ID}&cnt={cnt}&appid=[{API key}’) will get the forecast but the table columns might need to change a bit.

Good luck, If you run into problems let me know. I could share my base that you could copy if needed as well.

Hi Garret,

I know this thread is sleeping since a year. But. I’m trying to pull weather data from openweather, somehow keep running in to problems.
You think you could share your base so I could copy it?
cheers and regards,

Hi Jan.

Peter from Feature Power is my Airtable integrator. We have the weather input working smoothly with our base. I’ve cced in Peter. I’ll leave it to you guys to discuss some options. Thabks. supports pulling in OpenWeatherMap’s weather data very easily, with no coding & no scripts necessary:

Alternatively, if you want to avoid scripting but keep everything in Airtable, you could also use, but that requires technical knowledge of making API calls.

If you have a budget to hire an expert Airtable consultant to help you with any of this, please feel free to contact me through my website: Airtable consulting — ScottWorld

6 - Interface Innovator
6 - Interface Innovator

Hi there Jan, here is the script that James and I are using. It uses weathereapi from, and is driven by a formula and script automation in Airtable. The script writes the formatted weather forecast back into the triggering record in Airtable and decrements a countdown in that same record. The countdown supports our particular needs for triggering the app/script and might not be relevant to you.

Formula for APIcall:

  ''&{Location} & '&dt=' & DATETIME_FORMAT(SET_TIMEZONE(Day,'Australia/Melbourne'),'YYYY-MM-DD')


let trigger = input.config();
let forecastAPIcall = trigger.APIcall;
let recordid =;
let counter = trigger.countdown;
let table = base.getTable('Hire Days');

let apiResponse = await fetch(forecastAPIcall);
let jsonResponse = await apiResponse.json();
counter -= 1;

let forecast = new String (
    `forecast for date: `+jsonResponse.forecast.forecastday[0].date+
    `\nmax temp: `+jsonResponse.forecast.forecastday[0].day.maxtemp_c+
    `\nmin temp: `+jsonResponse.forecast.forecastday[0].day.mintemp_c+
    `\nchance of rain%: `+jsonResponse.forecast.forecastday[0].day.daily_chance_of_rain+
    `\nconditions: `+jsonResponse.forecast.forecastday[0].day.condition.text+
    `\nmax wind (kmph): `+jsonResponse.forecast.forecastday[0].day.maxwind_kph

await table.updateRecordAsync(recordid, {
    "Forecast": forecast.substr(0,forecast.length),
    ".ping counter": counter

To add to Scott’s Data Fetcher recommendation, there is now an easy no-code way to look up the weather forecast in Airtable using Data Fetcher.