Weather API
Our free weather API is open for anyone to use. We will provide you with a 10 day forecast for a given city. We will provide both metric and imperial system in our data. We are using SMHI (The Swedish Meteorological and Hydrological Institute) as our base for getting the forecasts.
Anything missing or can be improved? Send us an email here and we will fix it!
Consume it
For this API, we have three endpoints. One for getting the forecast for a city, one for getting forecast for a specific id and city and one for getting all our supported cities.
GET /forecast
Let's start with the city forecast endpoint. In below example we will fetch the forecast for London, England.
const response = await fetch( "https://weather.algobook.info/forecast/london" );
Response
The response consists of two objects in the array. city with city information, and forecast with the 10 day forecast.
{ "city": { "id": 2643741, "name": "City of London", "population": 8799800, "lat": 51.51279, "lon": -0.09184, "country": "England" }, "forecast": [ { "day": "2023-05-08T00:00:00.000Z", "formattedDay": "Today", "minTempCelsius": 13, "minTempFarenheit": 55, "maxTempCelsius": 15, "maxTempFarenheit": 59, "windAverageMs": 5, "windAverageKmh": 18, "windAverageMph": 11, "windDirection": 206, "symbol": "18", "forecastText": "Light rain" }, { "day": "2023-05-09T00:00:00.000Z", "formattedDay": "Tomorrow", "minTempCelsius": 11, "minTempFarenheit": 52, "maxTempCelsius": 19, "maxTempFarenheit": 66, "windAverageMs": 3, "windAverageKmh": 10.8, "windAverageMph": 7, "windDirection": 251, "symbol": "6", "forecastText": "Overcast" }, { "day": "2023-05-10T00:00:00.000Z", "formattedDay": "Wed", "minTempCelsius": 10, "minTempFarenheit": 50, "maxTempCelsius": 15, "maxTempFarenheit": 59, "windAverageMs": 5, "windAverageKmh": 18, "windAverageMph": 11, "windDirection": 277, "symbol": "1", "forecastText": "Clear sky" }, { "day": "2023-05-11T00:00:00.000Z", "formattedDay": "Thu", "minTempCelsius": 13, "minTempFarenheit": 55, "maxTempCelsius": 9, "maxTempFarenheit": 48, "windAverageMs": 2, "windAverageKmh": 7.2, "windAverageMph": 4, "windDirection": 188, "symbol": "3", "forecastText": "Variable cloudiness" }, { "day": "2023-05-12T00:00:00.000Z", "formattedDay": "Fri", "minTempCelsius": 13, "minTempFarenheit": 55, "maxTempCelsius": 8, "maxTempFarenheit": 46, "windAverageMs": 4, "windAverageKmh": 14.4, "windAverageMph": 9, "windDirection": 25, "symbol": "1", "forecastText": "Clear sky" }, { "day": "2023-05-13T00:00:00.000Z", "formattedDay": "Sat", "minTempCelsius": 14, "minTempFarenheit": 57, "maxTempCelsius": 10, "maxTempFarenheit": 50, "windAverageMs": 4, "windAverageKmh": 14.4, "windAverageMph": 9, "windDirection": 103, "symbol": "6", "forecastText": "Overcast" }, { "day": "2023-05-14T00:00:00.000Z", "formattedDay": "Sun", "minTempCelsius": 15, "minTempFarenheit": 59, "maxTempCelsius": 10, "maxTempFarenheit": 50, "windAverageMs": 3, "windAverageKmh": 10.8, "windAverageMph": 7, "windDirection": 230, "symbol": "6", "forecastText": "Overcast" }, { "day": "2023-05-15T00:00:00.000Z", "formattedDay": "Mon", "minTempCelsius": 10, "minTempFarenheit": 50, "maxTempCelsius": 13, "maxTempFarenheit": 55, "windAverageMs": 6, "windAverageKmh": 21.6, "windAverageMph": 13, "windDirection": 337, "symbol": "9", "forecastText": "Moderate rain showers" }, { "day": "2023-05-16T00:00:00.000Z", "formattedDay": "Tue", "minTempCelsius": 13, "minTempFarenheit": 55, "maxTempCelsius": 5, "maxTempFarenheit": 41, "windAverageMs": 3, "windAverageKmh": 10.8, "windAverageMph": 7, "windDirection": 271, "symbol": "9", "forecastText": "Moderate rain showers" }, { "day": "2023-05-17T00:00:00.000Z", "formattedDay": "Wed", "minTempCelsius": 11, "minTempFarenheit": 52, "maxTempCelsius": 12, "maxTempFarenheit": 54, "windAverageMs": 6, "windAverageKmh": 21.6, "windAverageMph": 13, "windDirection": 294, "symbol": "19", "forecastText": "Moderate rain" } ] }
GET /city/suggestions
Our other endpoint let you search for a city with a partial search string.
const response = await fetch( "https://weather.algobook.info/city/suggestions?query=New%20yo" );
Response
And then we return all the matching cities
[ { "id": 5128581, "name": "New York", "population": 8008278, "lat": 40.7142691, "lon": -74.0059729, "country": "USA" }, { "id": 5115985, "name": "East New York", "population": 173198, "lat": 40.66677, "lon": -73.88236, "country": "USA" }, { "id": 5106292, "name": "West New York", "population": 49708, "lat": 40.78788, "lon": -74.01431, "country": "USA" } ]
GET /forecast/:city/:id
If you find yourself in a situation where you want to get the forecast for a city that has a duplicated name as another city that is getting higher "rank" from the suggestion API, you can call our suggestion endpoint, and retrieve the ID of the city you are interested in, and then call our endpoint with the name and id of the entity.
const response = await fetch( "https://weather.algobook.info/forecast/New York/5115985" );
And this will get forecast for East New York.
Response
{ "city": { "id": 5115985, "name": "East New York", "population": 173198, "lat": 40.66677, "lon": -73.88236, "country": "USA" }, "forecast": [ { "day": "2023-05-07T22:00:00.000Z", "formattedDay": "Today", "minTempCelsius": 21, "minTempFarenheit": 70, "maxTempCelsius": 24, "maxTempFarenheit": 75, "windAverageMs": 5, "windAverageKmh": 18, "windAverageMph": 11, "windDirection": 317, "symbol": "1", "forecastText": "Clear sky" }, { "day": "2023-05-08T22:00:00.000Z", "formattedDay": "Tomorrow", "minTempCelsius": 10, "minTempFarenheit": 50, "maxTempCelsius": 10, "maxTempFarenheit": 50, "windAverageMs": 3, "windAverageKmh": 10.8, "windAverageMph": 7, "windDirection": 209, "symbol": "19", "forecastText": "Moderate rain" }, { "day": "2023-05-09T22:00:00.000Z", "formattedDay": "Wed", "minTempCelsius": 11, "minTempFarenheit": 52, "maxTempCelsius": 10, "maxTempFarenheit": 50, "windAverageMs": 2, "windAverageKmh": 7.2, "windAverageMph": 4, "windDirection": 285, "symbol": "1", "forecastText": "Clear sky" }, { "day": "2023-05-10T22:00:00.000Z", "formattedDay": "Thu", "minTempCelsius": 14, "minTempFarenheit": 57, "maxTempCelsius": 10, "maxTempFarenheit": 50, "windAverageMs": 3, "windAverageKmh": 10.8, "windAverageMph": 7, "windDirection": 259, "symbol": "1", "forecastText": "Clear sky" }, { "day": "2023-05-11T22:00:00.000Z", "formattedDay": "Fri", "minTempCelsius": 13, "minTempFarenheit": 55, "maxTempCelsius": 26, "maxTempFarenheit": 79, "windAverageMs": 2, "windAverageKmh": 7.2, "windAverageMph": 4, "windDirection": 265, "symbol": "1", "forecastText": "Clear sky" }, { "day": "2023-05-12T22:00:00.000Z", "formattedDay": "Sat", "minTempCelsius": 16, "minTempFarenheit": 61, "maxTempCelsius": 28, "maxTempFarenheit": 82, "windAverageMs": 3, "windAverageKmh": 10.8, "windAverageMph": 7, "windDirection": 287, "symbol": "8", "forecastText": "Light rain showers" }, { "day": "2023-05-13T22:00:00.000Z", "formattedDay": "Sun", "minTempCelsius": 15, "minTempFarenheit": 59, "maxTempCelsius": 19, "maxTempFarenheit": 66, "windAverageMs": 4, "windAverageKmh": 14.4, "windAverageMph": 9, "windDirection": 65, "symbol": "6", "forecastText": "Overcast" }, { "day": "2023-05-14T22:00:00.000Z", "formattedDay": "Mon", "minTempCelsius": 13, "minTempFarenheit": 55, "maxTempCelsius": 17, "maxTempFarenheit": 63, "windAverageMs": 3, "windAverageKmh": 10.8, "windAverageMph": 7, "windDirection": 56, "symbol": "2", "forecastText": "Nearly clear sky" }, { "day": "2023-05-15T22:00:00.000Z", "formattedDay": "Tue", "minTempCelsius": 13, "minTempFarenheit": 55, "maxTempCelsius": 14, "maxTempFarenheit": 57, "windAverageMs": 2, "windAverageKmh": 7.2, "windAverageMph": 4, "windDirection": 307, "symbol": "19", "forecastText": "Moderate rain" }, { "day": "2023-05-16T22:00:00.000Z", "formattedDay": "Wed", "minTempCelsius": 16, "minTempFarenheit": 61, "maxTempCelsius": 16, "maxTempFarenheit": 61, "windAverageMs": 3, "windAverageKmh": 10.8, "windAverageMph": 7, "windDirection": 224, "symbol": "1", "forecastText": "Clear sky" }, { "day": "2023-05-17T22:00:00.000Z", "formattedDay": "Thu", "minTempCelsius": 21, "minTempFarenheit": 70, "maxTempCelsius": 21, "maxTempFarenheit": 70, "windAverageMs": 4, "windAverageKmh": 14.4, "windAverageMph": 9, "windDirection": 261, "symbol": "8", "forecastText": "Light rain showers" } ] }
Feedback
Is something missing? Just email us, we love to improve our software. Email can be found here.