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.
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.
npm
and install the required dependencies.npm init -y && npm i node-fetch nodemailer pug
node-fetch
will be used to send requests to ClimaCell API;nodemailer
will be used to send email;pug
will be used to write email templates;2. Create a config.json
file to store your credentials and populate it your data.
{
"host": "<email server host>",
"user": "<email_addr>",
"pass": "<email_pwd>",
"cc_key": "<climacell_api_key>"
}
host
, user
and pass
fields 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 host
property with service
and then follow these instructions from a StackOverflow question.cc_key
is your private ClimaCell API Key.#san-francisco #air-quality #weather-apps #weather-api