Tomorrow.io Just Successfully Captured Precipitation Scans from Our Space Radars. Learn More

X

Weather Forecast API: Predict, Plan, and Prepare

Access ultra-accurate, hyperlocal data up to 14 days in the future for any location on the globe with a Weather Forecast API.

Weather Forecast API

The weather forecast has a profound impact on the way we live, work, and run our businesses. That’s why weather forecasting data is so powerful in optimizing business decisions. For many industries, though, organizations don’t realize the power of weather data until they begin experimenting with what it can do. That’s where a Weather Forecast API can help.

Advance Operations With a Weather Forecast API Across All Industries

The importance of weather forecasting is well known in some industries. For example, if the weather is bad in certain cities, it delays airline arrivals and causes rerouting of planes so that they can avoid stormy areas. Consumers and businesses are aware of airline delays due to bad weather conditions, but weather conditions impact so much more than just consumer habits. While businesses are aware of the impact of weather affecting airline schedules, they are often unaware of the many ways weather directly affects revenue in their own industries.

 Tomorrow.io’s Weather Forecast API can be integrated into existing systems to improve employee safety, reduce asset losses, and more. Using weather forecasts, warehouses, for example, can help employees avoid hazardous weather conditions and prevent product loss by building equipment and infrastructure to withstand severe weather (e.g., floods and hurricanes). By knowing when severe weather conditions are on the way from a Weather Forecast API, operators can advise employees to seek shelter, safeguard outdoor equipment, and reroute deliveries. 

API Image 1.1
API Image 2.1

Weather Forecast APIs aren’t only helpful for safety and operational efficiency — weather also directly impacts revenue in sectors like retail. Demand for many retail products is often seasonal, but severe weather events can cause unexpected fluctuations.

In areas where hurricane season lasts several months, for example, items like water and non-perishable goods may be in high demand for an extended period of time. Likewise, extreme heat can prompt an increase in water and clothing sales.

Whatever your industry, a Weather Forecast API can enable you to translate future conditions into actionable business strategies to better protect employees, improve operational efficiency, and drive targeted revenue.

Businesses Across All Industries Benefit From Weather Forecasting, Including:

Help customers reduce costs and build more smart energy systems by using weather forecasts to predict when HVAC must be used the most and when it can be powered down to preserve energy.

Predict when severe weather conditions will possibly destroy city infrastructure so that workers can take necessary precautions to secure it from physical damage.

Severe weather affects air quality, which in turn can increase hospital visits and impact population health (e.g., asthma attacks).

Any restaurant with outdoor seating uses weather forecasting to determine if it’s too windy, cold, or hot to interest diners eating outdoors.

Hotels and travel agencies can predict consumer interests in specific locations based on common seasonal weather conditions within a geographic region.

Know when and how to protect plants from severe weather conditions and manage irrigation systems based on weather forecasting.

Help insured homeowners and car owners by helping them prepare for severe weather during targeted seasons, which also lowers the chance of claims and reduces insurance costs.

Most modern automobiles and trucks have systems to help warn drivers of hazardous conditions. A weather forecast API can improve these systems’ accuracy and can be used to warn drivers so that they can take alternative safer routes.

Severe weather conditions affect roads and city expansion projects, so a forecasting API can be used to predict when repairs will be needed and construction will be delayed. It also warns construction companies to suspend work during serious weather to keep employees and contractors safe from harm.

Weather API Capabilities

Learn more about the Tomorrow.io Weather API’s enterprise-grade capabilities:

Code Examples Using a Weather Forecast API

There are endless use cases for incorporating weather data from a Weather Forecast API into your operations, including in the context of heatwaves. Extreme heat causes safety risks, operational disruptions, and revenue loss.

To build weather forecasting and alerts into applications, you have two primary ways to approach the problem. The first is using the Tomorrow.io’s Weather API’s Timelines endpoint. The Timeline endpoint is more flexible in allowing you to create your own alerts and determine when heat is too high (or too low) and when your applications will send alerts to employees. You can retrieve temperature values (in metric or imperial units) along with other factors in the Weather API’s core data layers to calculate events to help employees plan for them. With the Timeline API, you can then pull weather data and use it in any way that fits your business needs.

The second option is to use Tomorrow.io’s Insights or Events endpoints. These two endpoints contain severe weather events and can be used in your applications to determine when several events could affect your area. In the context of heatwaves, the “Fires” insight would be beneficial. The main difference between Insights and Events is that Insights can be customized to only pull events based on your own parameters. The Events endpoint is a more simplistic way to get alerts for upcoming severe weather. With Events, you can rely on Tomorrow.io’s alerts system to determine if an event will impact your area.

Using Timelines to Get Temperature by the Hour

For developers who prefer to collect data and use it in their own algorithms, the Timelines endpoint is the best approach to add forecasting to your applications. With this endpoint, you can set a “time step” parameter that lets you gather data for every minute, five minutes, 15 minutes, 30 minutes, hour, or one day. You set the start and end date for collection, and use this data to build your own weather alerts.

Here is an example of a Python call to the Timeline endpoint to retrieve hourly temperature data for several days in May.

				
					import requests

url = "https://api.tomorrow.io/v4/timelines?location=607f3e4188a6a60007947b82&fields=temperature&units=imperial&timesteps=1h&startTime=2022-05-12T14%3A09%3A50Z&endTime=2022-05-15T14%3A09%3A50Z&apikey=YOUR_API_KEY"

headers = {
"Accept": "application/json",
"Accept-Encoding": "gzip"
}

response = requests.get(url, headers=headers)
print(response.text)
				
			

The above call only retrieves temperature, but you can retrieve numerous other core weather data. Here is an example of retrieving data for temperature and temperature apparent values. The “temperature apparent” data point is the perceived temperature by humans.

				
					import requests

url = "https://api.tomorrow.io/v4/timelines?location=607f3e4188a6a60007947b82&fields=temperature&fields=temperatureApparent&units=imperial×teps=1h&startTime=2022-05-12T14%3A09%3A50Z&endTime=2022-05-15T14%3A09%3A50Z&apikey=YOUR_API_KEY"

headers = {
    "Accept": "application/json",
    "Accept-Encoding": "gzip"
}

response = requests.get(url, headers=headers)
print(response.text)
				
			

The results are given to you in JSON format. The following results are snipped for brevity, but you can see the data returned hour by hour from the above request.

				
					{
  "data": {
    "timelines": [
      {
        "timestep": "1h",
        "endTime": "2022-05-13T14:00:00Z",
        "startTime": "2022-05-12T14:00:00Z",
        "intervals": [
          {
            "startTime": "2022-05-12T14:00:00Z",
            "values": {
              "temperature": 70.94,
              "temperatureApparent": 70.94
            }
          },
          {
            "startTime": "2022-05-12T15:00:00Z",
            "values": {
              "temperature": 75.43,
              "temperatureApparent": 75.43
            }
          },
          {
            "startTime": "2022-05-12T16:00:00Z",
            "values": {
              "temperature": 78.65,
              "temperatureApparent": 78.65
            }
          },
          {
            "startTime": "2022-05-12T17:00:00Z",
            "values": {
              "temperature": 81.29,
              "temperatureApparent": 80.42
            }
          },
          {
            "startTime": "2022-05-12T18:00:00Z",
            "values": {
              "temperature": 83.12,
              "temperatureApparent": 81.59
            }
          },
          {
            "startTime": "2022-05-12T23:00:00Z",
            "values": {
              "temperature": 82.18,
              "temperatureApparent": 80.99
            }
          },
          {
            "startTime": "2022-05-13T09:00:00Z",
            "values": {
              "temperature": 62.81,
              "temperatureApparent": 62.81
            }
          }
          }
        ]
      }
    ]
  }
}
				
			

As you can see from the above JSON, every data point has a date and time stamp, so you can calculate the time at which the temperature will rise and when to alert users. For example, if a restaurant chooses to limit outdoor dining after temperatures reach 80F, your application could alert management that 5/12/2022 will have temperatures over the threshold at 17:00 UTC and 18:00 UTC. Management can then make a revenue-impacting decision to determine what to do next.

Severe Heat Conditions

Using Events and Insights to Get Severe Heat Conditions (Fires)

Dry heat often leads to severe weather conditions like wildfires. The Events endpoint lets you leverage Tomorrow.io’s data collection from official sources where severe events trigger warnings, advisories, watches, and statements. These alerts are the same ones you see on news stations warning residents to safeguard their homes or evacuate. Official sources publish triggers (parameter name “title” in the Tomorrow.io Weather Forecast API) based on their own weather data, and these triggers define the alerts sent to the general public. 

You can use the Tomorrow.io Weather API to build applications using the same advisories published by official news sources. Note that this is different from the previous example where data is collected and your algorithms determine when to send alerts based on your own criteria. In this example, you’re publishing alerts using the Tomorrow.io Weather API but using thresholds based on official sources.

Using a simple Python script, you can retrieve any alerts for fires at the location you define in your account settings.

				
					import requests

url = "https://api.tomorrow.io/v4/events?location=607f3e4188a6a60007947b82&insights=fires&buffer=1&apikey=YOUR_API_KEY"

headers = {
    "Accept": "application/json",
    "Accept-Encoding": "gzip"
}

response = requests.get(url, headers=headers)
print(response.text)

//From the above query, here is an example JSON response:

{
  "data": {
    "events": [
      {
        "insight": "fires",
        "startTime": "2020-10-13T18:12:00Z",
        "endTime": "2020-10-14T15:06:26.261668224Z",
        "updateTime": "2020-10-13T18:12:00Z",
        "severity": "Unknown",
        "certainty": "Likely",
        "urgency": "Unknown",
        "eventValues": {
          "origin": "VIIRS",
          "title": "Active Fire",
          "radiativePower": 0.9,
          "location": {
            "type": "Point",
            "coordinates": [
              130.191162109,
              47.230289459
            ]
          },
          "distance": 0.156,
          "direction": -7.481822
        }
      },
      {
        "insight": "38f689d83c264eb0b084ba095f2ea772",
        "startTime": "2020-05-10T07:49:34+0000",
        "endTime": "2020-05-10T07:49:34+0000",
        "eventValues": {
          "precipitationIntensity": 1,
          "mepIndex": 300
        }
      },
      "..."
    ]
  }
}

				
			

Instead of receiving temperature information, the Events endpoint tells you that severe fires are likely to occur between the given start and end time.

Note that you can also create your own custom insight using the Insights endpoint. Several operators and conditional statements can be used to retrieve data on the Tomorrow.io Weather API and use it to build your own severe weather predictions so that you can use them in your applications.

Using Forecasts to Drive Business Decisions

The Tomorrow.io Weather Forecast API provides reliable, accurate data that allows you to build data-driven applications for forecasts up to 14 days in the future. You can customize your application triggers using the Timeline endpoint to collect data and determine your own severe weather conditions and alerts, or you can leverage our Insights and Events endpoints to get official weather notifications from our sources. Regardless of the direction you choose to go with weather forecasts, the Tomorrow.io Weather API is a powerful tool that can build revenue-impacting application features.

Get The World's Most Advanced Weather Intelligence

Try our Weather API for Free!

Predict, automate, and solve your biggest weather challenges with Tomorrow.io