Skip to main content
Guides

Weather Forecast Hourly

Estimated reading time: 25 minutes

In this guide you will learn how to get the weather hourly forecast at a desired location, for a specified number of hours.

Setup

First, get an API key token, see the Getting Started guide.

Weather Forecast Hourly entry point

URL: https://weather.magiclaneapis.com/v1/WeatherForecastHourly

EXAMPLE

These are complete working examples in several different languages, showing how to use the weather REST API. You can try them right now.

Linux terminal / Windows command prompt:

curl "https://weather.magiclaneapis.com/v1/WeatherForecastHourly" -X POST -H "Content-Type: application/json" -H "Authorization: YOUR_API_KEY_TOKEN" -d @payload.json

Linux note - do not use @~/payload.json instead of @/home/user/payload.json because ~ does not resolve due to the @ ; use only relative path @payload.json or absolute path @/home/user/payload.json

where

payload.json is a text file containing the following:

complete payload.json file - coords , one or more semicolon ; separated latitude,longitude coordinate pairs - the weather will be returned for each one separately; noHours - Number of hours for which to return the hourly weather forecast. details - 0 returns weather description and temperature (default), 1 - returns all available weather parameters.

{
"coords": "43.0, 2.0; 42.6, 2.5; 42.3, 3.111",
"noHours": 4,
"details": 0
}

In a linux terminal you can also send the request directly from the command line, without a file, like this: (this method does not work on windows)

curl "https://weather.magiclaneapis.com/v1/WeatherForecastHourly" -X POST -H "Content-Type: application/json" -H "Authorization: YOUR_API_KEY_TOKEN" -d \
'{
...
}'

The only difference is the added backslash after -d, and then the filename @/home/user/payload.json is replaced with the contents of the json file, starting with the next line - note that a single quote ‘ is added before the leading curly brace { and after the trailing curly brace } to enclose the file contents in single quotes - no backslashes are needed between the single quotes.

REQUEST PARAMETER DEFINITIONS

Request body schema: application/json

keyvalue
coords
(mandatory
parameter)
A list of ; (semicolon) separated latitude,longitude coordinate pairs - the weather will be returned for each separately. Example: “43,2; 42.6,2.5; 42.3,3.1”
Type: string
noHoursNumber of hours for which to return the hourly weather forecast.
Type: integer
Default value: 48 Maximum value: 240
detailsType: integer
Default value: 0
Possible values - 0:returns weather description and temperature; 1:returns all available weather parameters

RESPONSE

WeatherForecastHourly results

Each result item is given in a JSON block as shown below.

In the above examples, 3 coordinate pairs were requested, and 4 hours of hourly forecast, so the result shows 4 hours of hourly weather forecast for each of the 3 locations specified. The coordinates are latitude, longitude (degrees). The date timestamp field is the UNIX time in seconds since 1 January 1970 at 00:00. WindDirection is in degrees, where 0 is North, 90 is East, 180 is South and 270 is West.

If details is set to 0, then the parameters block contains only Temperature ; otherwise, if details is set to 1, this block contains all parameters as shown below.

{
"Hourly forecast": [
{
"UpdateTime": 1699336800,
"hourlyWeatherParameters": [
{
"WeatherConditions": "Cloudy",
"date": 1699362000,
"daylight": "day",
"parameters": {
"DewPoint": 1,
"FeelsLike": 13,
"Humidity": 49,
"Pressure": 1020,
"Temperature": 13,
"UV": 1,
"WindDirection": 0,
"WindSpeed": 0
}
},
{
"WeatherConditions": "Cloudy",
"date": 1699365600,
"daylight": "day",
"parameters": {
"DewPoint": 1,
"FeelsLike": 13,
"Humidity": 50,
"Pressure": 1018,
"Temperature": 14,
"UV": 0,
"WindDirection": 201,
"WindSpeed": 3
}
},
{
"WeatherConditions": "Cloudy",
"date": 1699369200,
"daylight": "day",
"parameters": {
"DewPoint": 2,
"FeelsLike": 12,
"Humidity": 55,
"Pressure": 1019,
"Temperature": 13,
"UV": 0,
"WindDirection": 173,
"WindSpeed": 3
}
},
{
"WeatherConditions": "Cloudy",
"date": 1699372800,
"daylight": "day",
"parameters": {
"DewPoint": 3,
"FeelsLike": 10,
"Humidity": 65,
"Pressure": 1020,
"Temperature": 11,
"UV": 0,
"WindDirection": 162,
"WindSpeed": 2
}
}
],
"latitude": 43,
"longitude": 2
},
{
"UpdateTime": 1699336800,
"hourlyWeatherParameters": [
{
"WeatherConditions": "Partly cloudy",
"date": 1699362000,
"daylight": "day",
"parameters": {
"DewPoint": 2,
"FeelsLike": 12,
"Humidity": 53,
"Pressure": 1020,
"Temperature": 13,
"UV": 1,
"WindDirection": 315,
"WindSpeed": -1
}
},
{
"WeatherConditions": "Partly cloudy",
"date": 1699365600,
"daylight": "day",
"parameters": {
"DewPoint": 2,
"FeelsLike": 12,
"Humidity": 54,
"Pressure": 1018,
"Temperature": 12,
"UV": 0,
"WindDirection": 258,
"WindSpeed": 3
}
},
{
"WeatherConditions": "Light rain",
"date": 1699369200,
"daylight": "day",
"parameters": {
"DewPoint": 2,
"FeelsLike": 11,
"Humidity": 56,
"Pressure": 1018,
"Temperature": 11,
"UV": 0,
"WindDirection": 230,
"WindSpeed": 3
}
},
{
"WeatherConditions": "Light rain",
"date": 1699372800,
"daylight": "day",
"parameters": {
"DewPoint": 3,
"FeelsLike": 9,
"Humidity": 68,
"Pressure": 1019,
"Temperature": 9,
"UV": 0,
"WindDirection": 189,
"WindSpeed": 2
}
}
],
"latitude": 42.599998474121094,
"longitude": 2.5
},
{
"UpdateTime": 1699336800,
"hourlyWeatherParameters": [
{
"WeatherConditions": "Mostly clear",
"date": 1699362000,
"daylight": "day",
"parameters": {
"DewPoint": 7,
"FeelsLike": 17,
"Humidity": 53,
"Pressure": 1020,
"Temperature": 17,
"UV": 1,
"WindDirection": 0,
"WindSpeed": 0
}
},
{
"WeatherConditions": "Light rain",
"date": 1699365600,
"daylight": "day",
"parameters": {
"DewPoint": 7,
"FeelsLike": 16,
"Humidity": 54,
"Pressure": 1019,
"Temperature": 16,
"UV": 0,
"WindDirection": 346,
"WindSpeed": 7
}
},
{
"WeatherConditions": "Mostly cloudy",
"date": 1699369200,
"daylight": "day",
"parameters": {
"DewPoint": 7,
"FeelsLike": 16,
"Humidity": 54,
"Pressure": 1018,
"Temperature": 16,
"UV": 0,
"WindDirection": 335,
"WindSpeed": 7
}
},
{
"WeatherConditions": "Mostly clear",
"date": 1699372800,
"daylight": "day",
"parameters": {
"DewPoint": 6,
"FeelsLike": 15,
"Humidity": 54,
"Pressure": 1018,
"Temperature": 16,
"UV": 0,
"WindDirection": 334,
"WindSpeed": 6
}
}
],
"latitude": 42.29999923706055,
"longitude": 3.1110000610351562
}
],
"info": {
"copyrights": [
"MagicLane"
]
},
"unit": "metric"
}