Ogundiran Ayobami
youTooCanCode

youTooCanCode

Maximize Business Efficiency with Weather APIs

Maximize Business Efficiency with Weather APIs

Ogundiran Ayobami's photo
Ogundiran Ayobami
·Nov 21, 2021·

4 min read

Subscribe to my newsletter and never miss my upcoming articles

trent-haaland-MVYsbIAgV68-unsplash.jpg Photo by Trent Haaland on Unsplash

Whether you're a business owner or you’re an employed software developer in a company, this article will give you excellent insight into how to measure the impacts of weather on your business activities. Doing so will help you adapt to changing weather conditions so you can get better results to move your company forward.

In this article, we are going to explore keeping records of your business activities alongside records of weather in relation to your customers, clients, and business. Why do we have to keep records of weather alongside business activities? Sometimes, your sales just increase for no apparent reason. Other times, it decreases, but you don’t know why it happened. Even your team may perform excellently sometimes but woefully another time. Some of these changes can be attributed to weather phenomena, even if your work isn’t directly related to the weather.

This article is meant to bring your attention to keeping records of weather alongside your business activities to measure its impacts on your business and seek improvement. There are many business activities to keep records of alongside weather conditions. Some of them are:

  1. Recording transportation of goods.
  2. Recording daily weather and the overall performance of employees.
  3. Recording sales and many other business activities.

In this article, we are going to focus on keeping records of weather alongside sales records for a company. To do this, we need to integrate a service that provides daily weather forecasts, such as Tomorrow.io, with sales records. Here, we will combine these two components using Tomorrow.io’s weather API.

Features of Tomorrow.io API

Tomorrow.io offers an effective weather API that provides a wide range of solutions for intelligent weather forecasting challenges. They provide reliable weather forecasting information tailored to specific needs and a meaningful interpretation of this data to solve business challenges. They also make it easy to integrate data into your products through their easy-to-use API. They have several features that are useful for different business purposes. Some of them are listed below:

  1. Weather forecasts for upcoming days
  2. Setting up severe weather alerts around a geofence
  3. Setting up alerts with custom weather conditions
  4. Periodically logging real-time weather for data science and climatology
  5. Visualizing global precipitation on a map
  6. Minimizing road risk with weather along a route
  7. Monitoring forecasted weather events with an insights dashboard

In short, they are providing fast data access for unique data points, such as wave height, soil moisture/temperature, solar irradiance, and more. It is also possible to customize the features by setting custom rules, getting alerts, and monitoring custom weather events.

Each of these features can be very useful depending on the use case. However, for this article, we are going to use the “weather forecasts for upcoming days” feature to get some daily records of weather and pair them with daily sales to see the correlation between weather and sales. So let’s get started!

Tutorial

First, we have to sign up for a free account on Tomorrow.io. Then, we have to log in and navigate to “Development” to locate the ApiKey and the weather API we want to use.

Developer button.PNG

We will call Tomorrow API to get the weather forecast with the Javascript code below.

url='https://api.tomorrow.io/v4/timelines?location=-73.98529171943665,40.75872069597532&fields=temperature&timesteps=1h&units=metric&apikey=86PGGYogeq2v6oXb6NlYhbC8vzitjlJS'


fetch(url)
.then(response => response.json())
.then(data => {
  const results = data['data']['timelines'][0]['intervals']
  console.log(results)
  results.forEach( dailyResult => {
  const date = dailyResult['startTime']
  const temp = Math.round(dailyResult['values']['temperature'])
  console.log(date,"has temprature", temp,"F");
   })
});

Note: You can call the API with any language of your choice.

In this case, we log the weather forecast for every hour in the console, but we can store it in the database instead, if necessary. That means we can display the temperature for every hour with the number of sales made during the hour.

It is not compulsory to check it hourly. You can do it daily or just check the weather forecast for the current moment. That can be done by changing the timesteps in the URL to “1h, 1d, or current”. The “h” in “1h” stands for an hour; the “d” in “1d” stands for day. You can also check Tomorrow.io’s documentation for more information.

Keeping the record of sales alongside the weather forecast at points of sales helps you figure out the impact of weather on sales. It can also be used for other business activities.

Conclusion

Keeping records of sales alongside the weather condition at the point of sales can be very useful in making critical business decisions, and Tomorrow.io provides several features that make it easy to get reliable and intelligent weather forecasting data. It offers features like upcoming weather forecasts, timelines, events, and alerts that can be very useful in your next application that needs intelligent data on weather.

 
Share this