History Weather API
Closed this issue · 1 comments
anabellaspinelli commented
Update to get historic data
On branch hack-the-planet
Request
The /weather
endpoint will receive:
- location: a string the user has search for, which will be passed to the Visual Crossings Weather API
It will call the weather API to get the "historical" weather of:
- the current date
- 10, 20, 30, 40 years ago
- and the same day but in 1973 (which seems to be the lowest year available)
The endpoint to call to get that data is:
https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/barcelona/2021-2-21?unitGroup=metric&key={{WEATHER_API_KEY}}&include=obs
Additionally, there's a query builder provided by the API docs:
https://www.visualcrossing.com/weather/weather-data-services#/timeline (login required)
Response
After getting all the data, the endpoint will return a response such as (or whatever's easier).
In the FE will we use the datetime
, the resolvedAddress
and the values.tempmax
and tempmin
*
- might be better to just use
temp
{
"latitude": 41.388,
"longitude": 2.17001,
"resolvedAddress": "Barcelona, Catalunya, Espanya",
"address": "barcelona",
"timezone": "Europe/Madrid",
"days": [
{
"datetime": "2021-02-21",
"datetimeEpoch": 1613862000,
"tempmax": 19.2,
"tempmin": 8,
"temp": 12,
"feelslikemax": 19.2,
"feelslikemin": 6.8,
"feelslike": 11.5,
"dew": 9.4,
"humidity": 84.23,
"precip": 0,
"precipprob": null,
"precipcover": 0,
"preciptype": null,
"snow": 0,
"snowdepth": 0,
"windgust": 57.6,
"windspeed": 29.2,
"winddir": 101.3,
"pressure": 1016.5,
"cloudcover": 70.6,
"visibility": 9.9,
"solarradiation": 123.5,
"solarenergy": 1.8,
"sunrise": "07:37:47",
"sunriseEpoch": 1613889467,
"sunset": "18:32:39",
"sunsetEpoch": 1613928759,
"moonphase": 0.33,
"conditions": "Partially cloudy",
"icon": "partly-cloudy-day",
"stations": [
"LEBL",
"LEGE",
"LELL",
"V7DJ5"
],
"source": "obs",
"hours": null
},
{
"datetime": "2011-02-21",
"datetimeEpoch": 1613862000,
"tempmax": 19.2,
"tempmin": 8,
"temp": 12,
"feelslikemax": 19.2,
"feelslikemin": 6.8,
"feelslike": 11.5,
"dew": 9.4,
"humidity": 84.23,
"precip": 0,
"precipprob": null,
"precipcover": 0,
"preciptype": null,
"snow": 0,
"snowdepth": 0,
"windgust": 57.6,
"windspeed": 29.2,
"winddir": 101.3,
"pressure": 1016.5,
"cloudcover": 70.6,
"visibility": 9.9,
"solarradiation": 123.5,
"solarenergy": 1.8,
"sunrise": "07:37:47",
"sunriseEpoch": 1613889467,
"sunset": "18:32:39",
"sunsetEpoch": 1613928759,
"moonphase": 0.33,
"conditions": "Partially cloudy",
"icon": "partly-cloudy-day",
"stations": [
"LEBL",
"LEGE",
"LELL",
"V7DJ5"
],
"source": "obs",
"hours": null
},
// ...etc
]
}"
albarin commented
❤️