Weather Forecast API
Introduction
NextBillion.ai's Weather Forecast API provides point-based weather forecast data for any location worldwide. The service offers two methods:
- Hourly Weather Forecast: returns hour-by-hour forecast information for up to the next 24 hours, including temperature, precipitation, wind, humidity, pressure, and UV index.
- Daily Weather Forecast: returns day-by-day forecast information for up to the next 14 days, including minimum and maximum temperature, precipitation, wind, UV index, and sun and moon timing.
Both methods share a common authentication scheme and accept a single (lat, lon) point as input. They are designed to support a wide range of use cases such as trip planning, fleet routing, field operations, and weather-aware delivery scheduling.
Hourly Weather Forecast
The Hourly Weather Forecast method returns hour-by-hour forecast information for the location specified by lat and lon. Forecast entries begin at the current hour and extend up to 24 hours into the future. Each entry includes both a UTC timestamp (dateTime) and the equivalent local time (dateTimeLocal).
Request Parameters
Loading..Response Schema
Loading..Example
The following query retrieves a 3-hour weather forecast for Amsterdam.
Sample API Request
Sample API Response
Daily Weather Forecast
The Daily Weather Forecast method returns day-by-day forecast information for the location specified by lat and lon. Forecast entries begin on the current day (in the station's local time) and extend up to 14 days into the future.
Request Parameters
Loading..Response Schema
Loading..Example
The following query retrieves a 3-day weather forecast for Amsterdam.
Sample API Request
Sample API Response
Weather Codes
The weatherCode field is a 9-character string that encodes the weather condition in a structured form: {T}_{XX}_{PPP}{L}. The components are described below.
| Component | Position | Meaning | Allowed Values |
|---|---|---|---|
{T} | 1 | Time of day | D (day), N (night) |
{XX} | 3–4 | Sky / cloud condition | CS (clear sky), MI (mist), FO (fog), SA (sand or dust storm), HZ (hazy), SC (some clouds), PC (partly cloudy), CL (cloudy), OC (overcast), ST (storm), CY (cyclone) |
{PPP} | 6–8 | Precipitation type (optional; ___ if none) | DRI (drizzle), RAI (rain), RAS (rain showers), RAT (thunderstorm with rain), SNO (snow), SNS (snow showers), SNT (snow with thunderstorm), SLE (sleet), SLS (sleet showers), SLT (sleet with thunderstorm), ICR (ice rain), HAI (hail), HAS (hail showers), HAT (hail with thunderstorm) |
{L} | 9 | Precipitation level (optional; _ if none) | 1 (light), 2 (moderate), 3 (heavy) |
The weatherDescription field provides a pre-decoded, human-readable English description of the same condition. The table below shows a few examples.
| weatherCode | weatherDescription |
|---|---|
| D_CS_____ | Clear sky (day) |
| N_PC_____ | Partly cloudy (night) |
| D_CL_RAI2 | Cloudy with moderate rain (day) |
| D_OC_SNO3 | Overcast with heavy snow (day) |
API Query Limits
- The maximum value for
forecastHoursis 24. - The maximum value for
forecastDaysis 14. - NextBillion.ai allows a maximum rate limit of 6000 queries per minute or 100 queries per second for continuous requests.
Note: We can increase the quota if needed on request. Contact support@nextbillion.ai for more details.
API Error Codes
| Response code | Description | Additional notes |
|---|---|---|
| 200 | Normal success case. | Normal success case. |
| 400 | Input validation failed. | There is a missing or an invalid parameter or a parameter with an invalid value type is added to the request. |
| 401 | APIKEY not supplied or invalid | This error occurs when the wrong API key is passed in the request or the key is missing altogether. |
| 403 | APIKEY is valid but does not have access to requested resources | You might be querying for a geographical region which is not valid for your account or requesting a service which is not enabled for you. |
| 404 | Requested host/path not found | This error occurs when a malformed hostname is used. |
| 422 | Could not process the request | A feasible solution could not be generated for the given set of locations or parameter configuration. |
| 429 | Too many requests | QPM reached or API request count quota reached. |
| 500 | Internal Service error. | There was an internal issue with NextBillion.ai services. You can reach out to support@nextbillion.ai for an explanation. |