What is an Hourly Weather API?
Explore the features and functions of our Hourly Weather API for accurate, localized forecasts.
Updated October 24, 2023.
An Hourly Weather API is a valuable tool that offers a more detailed and localized approach to weather predictions. Unlike traditional API tools that provide a broad overview of weather conditions, an Hourly Weather API allows us to dive into deep insights for specific time periods during the day.
How It Works
Let's look at a basic example of an API request for hourly weather forecasts. The example below is written in JavaScript, but Tomorrow.io offers APIs in approximately 20 different programming languages:
const options = {method: 'GET', headers: {accept: 'application/json'}};
fetch('https://api.tomorrow.io/v4/weather/forecast?location=new%20york×teps=1h&apikey=YOUR_API_KEY', options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));
The code snippet above demonstrates how to make a request to Tomorrow.io's Hourly Weather API for an hourly forecast in New York. We set the query parameter timesteps to hourly by writing timesteps=1h. Upon receiving the response, we convert it to a JSON format using the `.json()` method, which we then print in the console. Here's an example response:
"timelines": {
"hourly": [
{
"time": "2023-08-22T11:00:00Z",
"values": {
"cloudBase": 1.02,
"cloudCeiling": 1.02,
"cloudCover": 73,
"dewPoint": 11.63,
"evapotranspiration": 0.09,
"freezingRainIntensity": 0,
"humidity": 60,
"iceAccumulation": 0,
"iceAccumulationLwe": 0,
"precipitationProbability": 0,
"pressureSurfaceLevel": 1016.77,
"rainAccumulation": 0,
"rainAccumulationLwe": 0,
"rainIntensity": 0,
"sleetAccumulation": 0,
"sleetAccumulationLwe": 0,
"sleetIntensity": 0,
"snowAccumulation": 0,
"snowAccumulationLwe": 0,
"snowDepth": 0,
"snowIntensity": 0,
"temperature": 20.13,
"temperatureApparent": 20.13,
"uvHealthConcern": 0,
"uvIndex": 0,
"visibility": 16,
"weatherCode": 1102,
"windDirection": 54,
"windGust": 3.31,
"windSpeed": 1.88
}
},
{
"time": "2023-08-22T12:00:00Z",
"values": {
"cloudBase": 4.07,
"cloudCeiling": null,
"cloudCover": 62.32,
"dewPoint": 11.79,
"evapotranspiration": 0.113,
"freezingRainIntensity": 0,
"humidity": 60.61,
"iceAccumulation": 0,
"iceAccumulationLwe": 0,
"precipitationProbability": 0,
"pressureSurfaceLevel": 1016.77,
"rainAccumulation": 0,
"rainAccumulationLwe": 0,
"rainIntensity": 0,
"sleetAccumulation": 0,
"sleetAccumulationLwe": 0,
"sleetIntensity": 0,
"snowAccumulation": 0,
"snowAccumulationLwe": 0,
"snowDepth": 0,
"snowIntensity": 0,
"temperature": 19.73,
"temperatureApparent": 19.73,
"uvHealthConcern": 0,
"uvIndex": 0,
"visibility": 16,
"weatherCode": 1102,
"windDirection": 357.01,
"windGust": 11.46,
"windSpeed": 5.33
}
},
As you can see, the JSON response is from the "timelines" section of the Hourly Weather API, containing hourly weather forecast data. For instance, the first entry has a timestamp of "2023-08-22T11:00:00Z", including weather values such as cloud base, cloud cover, wind speed, and more. This response shows the Hourly Weather API's ability to deliver detailed and localized forecasts, allowing developers to integrate precise weather insights into their apps.