Keeping track of weather evolution nowadays is not that hard. You have access to weather data via the internet, radio including TV. But what about a personalized solution, an application that only informs us about the indicators that we want in the city we want?

We can even combine this with air quality, which is an important topic during these times, especially if you live in San Francisco. This would be interesting, because air quality is not that accessible. There are not that many data providers and this type of data is harder to acquire than weather data.

So let’s build an app for that.

The final output of our application will look like this. Each morning at a certain hour the weather forecast for that day will be sent via email together with the current air quality values.

At the same time, when the air quality decreases below a certain threshold, an alert will be sent with the indicator or indicators that went above that limit.

Let’s Code It

To be able to acquire the type of data that we are interested in, we’ll use the ClimaCell Weather API.

Their API will allow us to collect reliable weather and air quality data.

The first step we need to do before we actually start coding is to set up the project and to create an account on ClimaCell, so we can receive an API key.

1. Setting Up the Project

  1. Run the following command to set up npmand install the required dependencies.

npm init -y && npm i node-fetch nodemailer pug

  • node-fetchwill be used to send requests to ClimaCell API;
  • nodemailerwill be used to send email;
  • pugwill be used to write email templates;

2. Create a config.jsonfile to store your credentials and populate it your data.

{
  "host": "<email server host>",
  "user": "<email_addr>",
  "pass": "<email_pwd>",
  "cc_key": "<climacell_api_key>"
}
  • hostuserand passfields are used to configure nodemailer. I’m sending emails from my email hosting service. If you want to send emails from your Gmail account you can replace the hostproperty with serviceand then follow these instructions from a StackOverflow question.
  • cc_key is your private ClimaCell API Key.

#san-francisco #air-quality #weather-apps #weather-api

I Built a Tool to Monitor San Francisco Air Quality and Alert Any Changes
1.05 GEEK