Weather Forecast API
Request accessPurpose
The Weather Forecast API delivers current and forecasted point-based weather conditions.
Request data for Hourly Forecasts
HTTPS method: GET
- Constants and parameters enclosed in curly brackets must be replaced with their values.
- Please see the following Request parameters section with the required and optional parameters tables for their values. The generic request format is as follows.
URL format
https://{baseURL}/weatherforecast/{version}/hourly?lat={latitude}&lon={longitude}&forecastHours={number_of_hours}&key={Your_API_Key}Example
https://api.tomtom.com/weatherforecast/v1/hourly?lat=40.7911106&lon=-73.8525824&forecastHours=5&key={Your_API_Key}curl command example
curl 'https://api.tomtom.com/weatherforecast/v1/hourly?lat=40.7911106&lon=-73.8525824&forecastHours=5&key={Your_API_Key}'Request parameters
Required parameters | Description |
|---|---|
string | The base URL for calling the API. Value: |
string | Service version. Value: |
string | An API Key valid for the requested service. Value: Your valid |
double | Longitude. Value: between -180 and 180. |
double | Latitude. Value: between -90 and 90. |
Optional parameters | Description |
|---|---|
integer | Number of hours from now for which the forecast is needed. Default value: |
Response data
Response body
The following JSON code block demonstrates a successful response from the API server.
{ "metadata": { "version": "1.0", "lastUpdatedTime": "2022-05-10T09:59:07.526391Z" }, "data": { "stationCoordinates": { "lat": 52.45, "lon": 4.83 }, "hourlyWeatherInfo": [ { "dateTime": "2022-05-10T09:00:00Z", "dateTimeLocal": "2022-05-10T11:00:00", "temperature": 19, "feelsLike": 19, "weatherCode": "D_OC_____", "windSpeed": 6.4, "windDirection": "SW", "sunProbability": 0, "precipitationProbability": 13, "thunderProbability": 0, "precipitation": 0.0, "pressure": 1016, "relativeHumidity": 64, "uvIndex": 2 } ] }}Response fields
The following table describes all of the response fields.
Primary fields | |
|---|---|
Field | Description |
object | Metadata about the rendered response. |
object | Weather forecast information. |
object | Co-ordinates of the weather station where the weather data was recorded. |
array | Array of weather data, one per hour. |
metadata object | |
| Field | Description |
string | Version of the data model. |
string (date-time) | UTC Timestamp of the response generated in ISO8601 format. |
stationCoordinates object | |
| Field | Description |
double | Latitude of the weather station. |
double | Longitude of the weather station. |
hourlyWeatherInfo object | |
| Field | Description |
string (data-time) | The time that applies to the forecast. |
string | The time that applies to the forecast in the local time zone. |
integer | The temperature in degrees celsius with a 1° precision. |
integer | Feels like temperature in degrees celsius with a 1° precision. |
string | Weather code. See the weatherCode values table for possible values. |
double | The expected wind speed in m/s. |
string | The expected direction of the wind, in up to three characters. |
integer | The probability of sunshine (value between 0 & 100 with a precision of 1). |
integer | The probability of getting some form of precipitation (value between 0 & 100 with a precision of 1). |
integer | The probability of having a thunderstorm (value between 0 & 100 with a precision of 1). |
integer | The total precipitation (in mm) with a precision of 0.1. |
integer | The barometric pressure (in hPa) with a precision of 1hPa. |
integer | The ambient relative humidity (value between 0 & 100 with a precision of 1). |
integer | The UV index. |
Response codes
Code | Meaning & possible causes |
| OK |
|---|---|
| Unauthorized : The supplied API Key is not valid for this request (or missing). |
| Not Found : The specified path was not valid. At least one of the path parameters was omitted or not entered correctly. |
| Bad request : One of the supplied parameters has a wrong format. |
| Internal Server Error |
Examples
Get the weather forecast for the next 2 hours in Amsterdam Central station (lat: 52.37971857640887, lon: 4.900282722759855)
https://api.tomtom.com/weatherforecast/v1/hourly?lat=52.37971857640887&lon=4.900282722759855&forecastHours=2&key={Your_API_Key}{ "metadata": { "version": "1.0", "lastUpdatedTime": "2022-05-12T09:01:09.154814Z" }, "data": { "stationCoordinates": { "lat": 52.37, "lon": 4.9 }, "hourlyWeatherInfo": [ { "dateTime": "2022-05-12T08:00:00Z", "dateTimeLocal": "2022-05-12T10:00:00", "temperature": 15, "feelsLike": 15, "weatherCode": "D_CS_____", "windSpeed": 4.7, "windDirection": "W", "sunProbability": 95, "precipitationProbability": 2, "thunderProbability": 0, "precipitation": 0.0, "pressure": 1018, "relativeHumidity": 68, "uvIndex": 2 }, { "dateTime": "2022-05-12T09:00:00Z", "dateTimeLocal": "2022-05-12T11:00:00", "temperature": 16, "feelsLike": 16, "weatherCode": "D_CS_____", "windSpeed": 5.2, "windDirection": "W", "sunProbability": 100, "precipitationProbability": 2, "thunderProbability": 0, "precipitation": 0.0, "pressure": 1018, "relativeHumidity": 59, "uvIndex": 3 } ] }}Request data for Daily Forecasts
HTTPS method: GET
- Constants and parameters enclosed in curly brackets must be replaced with their values.
- Please see the following Request parameters section with the required and optional parameters tables for their values. The generic request format is as follows.
URL format
https://{baseURL}/weatherforecast/{version}/daily?lat={latitude}&lon={longitude}&forecastHours={number_of_hours}&key={Your_API_Key}Example
https://api.tomtom.com/weatherforecast/v1/daily?lat=40.7911106&lon=-73.8525824&forecastHours=5&key={Your_API_Key}curl command example
curl 'https://api.tomtom.com/weatherforecast/v1/daily?lat=40.7911106&lon=-73.8525824&forecastHours=5&key={Your_API_Key}'Required parameters | Description |
|---|---|
string | The base URL for calling the API. Value: |
string | Service version. Value: |
string | An API Key valid for the requested service. Value: Your valid |
double | Longitude. Value: between -180 and 180. |
double | Latitude. Value: between -90 and 90. |
Optional parameters | Description |
|---|---|
integer | Number of days from now for which the forecast is needed. Default: |
Response data
Response body
The following JSON code block demonstrates a successful response from the API server.
{ "metadata": { "version": "1.0", "lastUpdatedTime": "2022-07-28T09:00:06.318191Z" }, "data": { "stationCoordinates": { "lat": 10.12, "lon": 9.83 }, "dailyWeatherInfo": [ { "date": "2022-07-28", "minTemperature": 21, "maxTemperature": 28, "weatherCode": "D_OC_RAT2", "windSpeed": 1.4, "windDirection": "W", "sunProbability": 3, "precipitationProbability": 96, "thunderProbability": 57, "precipitation": 21.7, "uvIndex": 7, "sunRise": "06:09:00", "sunSet": "18:44:00", "moonRise": "05:48:00", "moonSet": "18:49:00", "moonPhase": 360 } ] }}Response fields
The following table describes all of the response fields.
Primary fields | |
|---|---|
Field | Description |
object | Metadata about the rendered response. |
object | Weather forecast information. |
object | Co-ordinates of the weather station where the weather data was recorded. |
array | Array of weather data, one per day. |
metadata object | |
| Field | Description |
string | Version of the data model. |
string (date-time) | UTC Timestamp of the response generated in ISO8601 format. |
stationCoordinates object | |
| Field | Description |
double | Latitude of the weather station. |
double | Longitude of the weather station. |
dailyWeatherInfo object | |
| Field | Description |
string (data) | The day that applies to the forecast. |
string | The temperature in degrees celsius with a 1° precision. |
integer | The temperature in degrees celsius with a 1° precision. |
integer | Feels like temperature in degrees celsius with a 1° precision. |
string | Weather code. See the weatherCode values table for possible values. |
double | The expected wind speed in m/s. |
string | The expected direction of the wind, in up to three characters. |
integer | The probability of sunshine (value between 0 & 100 with a precision of 1). |
integer | The probability of getting some form of precipitation (value between 0 & 100 with a precision of 1). |
integer | The probability of having a thunderstorm (value between 0 & 100 with a precision of 1). |
integer | The total precipitation (in mm) with a precision of 0.1. |
integer | The UV index. |
integer | Time of the sunrise in local time. |
integer | Time of the sunset in local time. |
integer | Time of the moonrise in local time. |
integer | Time of the moonset in local time. |
integer | Moon phase in degrees between 0° and 360° with 1° precision. |
Response codes
Code | Meaning & possible causes |
|---|---|
| OK |
| Unauthorized : The supplied API Key is not valid for this request (or missing). |
| Not Found : The specified path was not valid. At least one of the path parameters was omitted or not entered correctly. |
| Bad request : One of the supplied parameters has a wrong format. |
| Internal Server Error |
Examples
Get the weather forecast for the next 2 days for the Amsterdam Central station (lat: 52.37971857640887, lon: 4.900282722759855).
https://api.tomtom.com/weatherforecast/v1/daily?lat=52.37971857640887&lon=4.900282722759855&forecastHours=2&key={Your_API_Key}{ "metadata": { "version": "1.0", "lastUpdatedTime": "2022-07-28T13:00:08.257660Z" }, "data": { "stationCoordinates": { "lat": 52.37, "lon": 4.9 }, "dailyWeatherInfo": [ { "date": "2022-07-28", "minTemperature": 14, "maxTemperature": 22, "weatherCode": "D_CL_____", "windSpeed": 5.0, "windDirection": "E", "sunProbability": 18, "precipitationProbability": 6, "thunderProbability": 0, "precipitation": 0.3, "uvIndex": 5, "sunRise": "05:53:00", "sunSet": "21:39:00", "moonRise": "04:53:00", "moonSet": "22:11:00", "moonPhase": 360 }, { "date": "2022-07-29", "minTemperature": 14, "maxTemperature": 24, "weatherCode": "D_PC_____", "windSpeed": 4.4, "windDirection": "N", "sunProbability": 31, "precipitationProbability": 19, "thunderProbability": 0, "precipitation": 0.0, "uvIndex": 6, "sunRise": "05:55:00", "sunSet": "21:37:00", "moonRise": "06:04:00", "moonSet": "22:33:00", "moonPhase": 10 } ] }}Weather codes
The weather codes are defined as a 9-character string with the following basic structure:
{T}_{XX}_{PPP}{L}The single parts have the following meaning:
{T}- single-letter time-of-day specifier: “D” or “N” for day and night respectively.{XX}- 2-letter sky/cloud status specifier.{PPP}- 3-letter precipitation type specifier.{L}- 1-digit precipitation level specifier.
Valid code values
The following tables summarize the allowed values for the single parts and their interpretations:
Code | Time of day |
|---|---|
| Day |
| Night |
Code | Sky/cloud status |
|---|---|
| Clear sky |
| Mist |
| Fog |
| Sand/dust storm |
| Hazy |
| Some clouds |
| Partly cloudy |
| Cloudy |
| Overcast |
| Storm |
| Cyclone |
Code | Precipitation type |
|---|---|
| Drizzle |
| Rain |
| Rain Showers |
| (Rain &) Thunderstorm |
| Snow |
| Snow showers |
| Snow & thunderstorm |
| Sleet |
| Sleet showers |
| Sleet & thunderstorm |
| Ice rain |
| Hail |
| Hail showers |
| Hail & thunderstorm |
Code | Precipitation level |
|---|---|
| Light |
| Moderate |
| Heavy |
Combination Rules
- Both day and night codes can be combined with any other (valid) combination of the other parts.
- The cloud/sky status codes PC, CL, OC, ST, and CY can be combined with all precipitation codes. All other codes are followed by 5 underscores to fill up the entire code to 9 characters.
- If no precipitation is present, the weather code is also filled up with 5 underscores after the cloud/sky status.
- If precipitation is present, both type and level must be specified.
- All supported precipitation types can be combined with any valid value for the precipitation level.
Examples
The following codes are valid:
D_CS\_\_\_\_\_- Day, clear sky - Berlin in summerD_OC_RAI2- Day, overcast, moderate rain - Bielefeld in summerN_PC_RAT1- Night, partly cloudy, light thunderstorm - the occasional summer thunderstormD_OC\_\_\_\_\_- Day, overcast - lucky day for BielefeldD_CY_SNO3- Day, cyclone, heavy snow - blizzardN_PC_SNO1- Night, partly cloudy, light snow - white Christmas
The WindDirection enum
The WindDirection enum provides all possible values for the windDirection parameter of a _ WeatherInfo_. It defines 16 equally distributed compass directions plus one value for “variable” and one value for “unknown”:
Value | Description |
|---|---|
| Variable/changing wind directions. |
| Wind from the North. |
| Wind from the North-North-East. |
| Wind from the North-East. |
| Wind from the East-North-East. |
| Wind from the East. |
| Wind from the East-South-East. |
| Wind from the South-East. |
| Wind from the South-South-East. |
| Wind from the South. |
| Wind from the South-South-West. |
| Wind from the South-West. |
| Wind from the West-South-West. |
| Wind from the West. |
| Wind from the West-North-West. |
| Wind from the North-West. |
| Wind from the North-North-West. |
| Wind direction unknown. |