Utilisation des données de Weather Underground (toutes stations confondues…)

octobre 22, 2020

Mon titre est un peu pompeux car apparemment récupérer des datas via l’API de Weather Undeground n’est pas plus une bonne idée.

FBI : Fausse bonne idée ? 

il y a quelques mois de cela , j’avais lu sur pas mal de forums spécialisés sur la météo « amateure » ou « personnelle » , que l’API de WU (Weather Underground) allait disparaitre/ devenir payante / enfin bref inutilisable. Ces annonces remontent à 2018 et sur ce post ici https://weather.station.software/blog/weather-underground-closes-its-doors-to-individual-users/ vous retrouverez un article complet de  Pierre Lannoy auteur de l’excellent plugin WordPress « Weather Station » : https://wordpress.org/plugins/live-weather-station/ qui résume bien la situation.

Mais….. Il semblerait que les stations « PWS », pour « Personal Weather Station », continuent  de fonctionner depuis cette annonce.  J’ai un  compte sur WU datant de Mai  2017 et mes deux stations sont toujours en  ligne aujourd’hui  :

une WMR200 de chez Oregon Scientifics  (avec un pluvio et une sonde UV HS)  :

https://www.wunderground.com/dashboard/pws/IBRETAGN140

Une WH-6000 de chez Froggit ( toute neuve ^^) :

https://www.wunderground.com/dashboard/pws/IPONTS4

 

Alors Happy des API ?

Dans la liste des stations sur mon compte Weather Undeground il y a un onglet  API :

et apparemment un  lien vers des documentations 

Un simple appel comme ceci :
ou XXX est ma clef API générée :

https://api.weather.com/v2/pws/observations/current?stationId=IPONTS4&format=json&units=m&apiKey=XXXXXX
// 20201015125118
// https://api.weather.com/v2/pws/observations/current?stationId=IPONTS4&format=json&units=m&apiKey=XXX

{
  "observations": [
    {
      "stationID": "IPONTS4",
      "obsTimeUtc": "2020-10-15T10:51:11Z",
      "obsTimeLocal": "2020-10-15 12:51:11",
      "neighborhood": "Pont-Scorff",
      "softwareType": null,
      "country": "FR",
      "solarRadiation": null,
      "lon": -3.422823,
      "realtimeFrequency": null,
      "epoch": 1602759071,
      "lat": 47.831679,
      "uv": 3.3,
      "winddir": 33,
      "humidity": 73,
      "qcStatus": 1,
      "metric": {
        "temp": 13,
        "heatIndex": 13,
        "dewpt": 8,
        "windChill": 13,
        "windSpeed": 2,
        "windGust": 2,
        "pressure": 1043.01,
        "precipRate": 0.00,
        "precipTotal": 0.00,
        "elev": 46
      }
    }
  ]
}

Il suffit ensuite une petite mise en forme pour récupérer les datas intéressantes :

Date de relevé : 2020-10-15 12:55:48
Nom de la station : IPONTS4
Direction du vent : 68

Vitesse du vent : 3
Température extérieure : 13
Température ressentie : 13

 

Autre exemple : récupération de données en tableau sur les 7 derniers jours 

https://api.weather.com/v2/pws/dailysummary/7day?stationId=IPONTS4&format=json&units=m&apiKey=XXX

 

// 20201015130759
// https://api.weather.com/v2/pws/dailysummary/7day?stationId=IPONTS4&format=json&units=m&apiKey=XXX

{
"summaries": [
{
"stationID": "IPONTS4",
"tz": "Europe/Paris",
"obsTimeUtc": "2020-10-09T21:59:58Z",
"obsTimeLocal": "2020-10-09 23:59:58",
"epoch": 1602280798,
"lat": 47.831679,
"lon": -3.422823,
"solarRadiationHigh": null,
"uvHigh": 6.6,
"winddirAvg": 294,
"humidityHigh": 99,
"humidityLow": 57,
"humidityAvg": 84,
"qcStatus": 1,
"metric": {
"tempHigh": 18,
"tempLow": 9,
"tempAvg": 13,
"windspeedHigh": 9,
"windspeedLow": 0,
"windspeedAvg": 0,
"windgustHigh": 17,
"windgustLow": 0,
"windgustAvg": 1,
"dewptHigh": 15,
"dewptLow": 8,
"dewptAvg": 10,
"windchillHigh": 18,
"windchillLow": 9,
"windchillAvg": 13,
"heatindexHigh": 18,
"heatindexLow": 9,
"heatindexAvg": 13,
"pressureMax": 1047.07,
"pressureMin": 1040.98,
"pressureTrend": 0.25,
"precipRate": 1.78,
"precipTotal": 1.78
}
},
{
"stationID": "IPONTS4",
"tz": "Europe/Paris",
"obsTimeUtc": "2020-10-10T21:59:50Z",
"obsTimeLocal": "2020-10-10 23:59:50",
"epoch": 1602367190,
"lat": 47.831679,
"lon": -3.422823,
"solarRadiationHigh": null,
"uvHigh": 5.9,
"winddirAvg": 357,
"humidityHigh": 99,
"humidityLow": 53,
"humidityAvg": 82,
"qcStatus": 0,
"metric": {
"tempHigh": 15,
"tempLow": 5,
"tempAvg": 10,
"windspeedHigh": 9,
"windspeedLow": 0,
"windspeedAvg": 1,
"windgustHigh": 16,
"windgustLow": 0,
"windgustAvg": 1,
"dewptHigh": 10,
"dewptLow": 5,
"dewptAvg": 7,
"windchillHigh": 15,
"windchillLow": 5,
"windchillAvg": 10,
"heatindexHigh": 15,
"heatindexLow": 5,
"heatindexAvg": 10,
"pressureMax": 1049.78,
"pressureMin": 1046.06,
"pressureTrend": 0.11,
"precipRate": 0.00,
"precipTotal": 0.00
}
},
{
"stationID": "IPONTS4",
"tz": "Europe/Paris",
"obsTimeUtc": "2020-10-11T21:59:49Z",
"obsTimeLocal": "2020-10-11 23:59:49",
"epoch": 1602453589,
"lat": 47.831679,
"lon": -3.422823,
"solarRadiationHigh": null,
"uvHigh": 5.9,
"winddirAvg": 341,
"humidityHigh": 98,
"humidityLow": 65,
"humidityAvg": 87,
"qcStatus": 0,
"metric": {
"tempHigh": 16,
"tempLow": 7,
"tempAvg": 11,
"windspeedHigh": 14,
"windspeedLow": 0,
"windspeedAvg": 1,
"windgustHigh": 23,
"windgustLow": 0,
"windgustAvg": 1,
"dewptHigh": 12,
"dewptLow": 6,
"dewptAvg": 9,
"windchillHigh": 16,
"windchillLow": 7,
"windchillAvg": 11,
"heatindexHigh": 16,
"heatindexLow": 7,
"heatindexAvg": 11,
"pressureMax": 1049.78,
"pressureMin": 1048.09,
"pressureTrend": -0.04,
"precipRate": 0.51,
"precipTotal": 0.51
}
},
{
"stationID": "IPONTS4",
"tz": "Europe/Paris",
"obsTimeUtc": "2020-10-12T21:59:56Z",
"obsTimeLocal": "2020-10-12 23:59:56",
"epoch": 1602539996,
"lat": 47.831679,
"lon": -3.422823,
"solarRadiationHigh": null,
"uvHigh": 2.6,
"winddirAvg": 178,
"humidityHigh": 99,
"humidityLow": 84,
"humidityAvg": 96,
"qcStatus": 1,
"metric": {
"tempHigh": 13,
"tempLow": 2,
"tempAvg": 9,
"windspeedHigh": 10,
"windspeedLow": 0,
"windspeedAvg": 0,
"windgustHigh": 12,
"windgustLow": 0,
"windgustAvg": 0,
"dewptHigh": 13,
"dewptLow": 2,
"dewptAvg": 8,
"windchillHigh": 13,
"windchillLow": 2,
"windchillAvg": 9,
"heatindexHigh": 13,
"heatindexLow": 2,
"heatindexAvg": 9,
"pressureMax": 1049.78,
"pressureMin": 1036.91,
"pressureTrend": -0.49,
"precipRate": 1.52,
"precipTotal": 4.32
}
},
{
"stationID": "IPONTS4",
"tz": "Europe/Paris",
"obsTimeUtc": "2020-10-13T21:24:54Z",
"obsTimeLocal": "2020-10-13 23:24:54",
"epoch": 1602624294,
"lat": 47.831679,
"lon": -3.422823,
"solarRadiationHigh": null,
"uvHigh": 6.6,
"winddirAvg": 340,
"humidityHigh": 99,
"humidityLow": 73,
"humidityAvg": 91,
"qcStatus": 0,
"metric": {
"tempHigh": 14,
"tempLow": 6,
"tempAvg": 10,
"windspeedHigh": 11,
"windspeedLow": 0,
"windspeedAvg": 0,
"windgustHigh": 17,
"windgustLow": 0,
"windgustAvg": 1,
"dewptHigh": 11,
"dewptLow": 6,
"dewptAvg": 8,
"windchillHigh": 14,
"windchillLow": 6,
"windchillAvg": 10,
"heatindexHigh": 14,
"heatindexLow": 6,
"heatindexAvg": 10,
"pressureMax": 1036.91,
"pressureMin": 1031.83,
"pressureTrend": -0.17,
"precipRate": 0.51,
"precipTotal": 1.02
}
},
{
"stationID": "IPONTS4",
"tz": "Europe/Paris",
"obsTimeUtc": "2020-10-14T21:59:54Z",
"obsTimeLocal": "2020-10-14 23:59:54",
"epoch": 1602712794,
"lat": 47.831679,
"lon": -3.422823,
"solarRadiationHigh": null,
"uvHigh": 5.9,
"winddirAvg": 59,
"humidityHigh": 99,
"humidityLow": 56,
"humidityAvg": 87,
"qcStatus": 1,
"metric": {
"tempHigh": 15,
"tempLow": 4,
"tempAvg": 9,
"windspeedHigh": 10,
"windspeedLow": 0,
"windspeedAvg": 1,
"windgustHigh": 15,
"windgustLow": 0,
"windgustAvg": 1,
"dewptHigh": 10,
"dewptLow": 4,
"dewptAvg": 6,
"windchillHigh": 15,
"windchillLow": 4,
"windchillAvg": 9,
"heatindexHigh": 15,
"heatindexLow": 4,
"heatindexAvg": 9,
"pressureMax": 1040.98,
"pressureMin": 1031.83,
"pressureTrend": 0.34,
"precipRate": 0.25,
"precipTotal": 0.25
}
},
{
"stationID": "IPONTS4",
"tz": "Europe/Paris",
"obsTimeUtc": "2020-10-15T11:05:00Z",
"obsTimeLocal": "2020-10-15 13:05:00",
"epoch": 1602759900,
"lat": 47.831679,
"lon": -3.422823,
"solarRadiationHigh": null,
"uvHigh": 5.2,
"winddirAvg": 18,
"humidityHigh": 94,
"humidityLow": 72,
"humidityAvg": 88,
"qcStatus": 1,
"metric": {
"tempHigh": 13,
"tempLow": 7,
"tempAvg": 9,
"windspeedHigh": 9,
"windspeedLow": 0,
"windspeedAvg": 1,
"windgustHigh": 13,
"windgustLow": 0,
"windgustAvg": 1,
"dewptHigh": 9,
"dewptLow": 6,
"dewptAvg": 7,
"windchillHigh": 13,
"windchillLow": 7,
"windchillAvg": 9,
"heatindexHigh": 13,
"heatindexLow": 7,
"heatindexAvg": 9,
"pressureMax": 1043.01,
"pressureMin": 1040.98,
"pressureTrend": 0.16,
"precipRate": 0.00,
"precipTotal": 0.00
}
}
]
}

 

Cette solution fonctionne ! mais fonctionnera-t-elle dans la durée ? est-elle stable ? :

A vrai dire , je n’en sais trop rien pour l’instant  , mais pour faire cet article j ‘ai du procéder à la régénération d’une nouvelle clef API et quand nous regardons les dates d’expiration :

Ca voudrait dire que ma clef est valide 6 mois seulement.

Concernant la stabilité la aussi  j’ai vraiment un doute car pour faire cet article et prendre des copies d’écran , l’api ne répond pas tout le temps et sa stabilité ne m’a pas l’air top !

 Pas content ? Pas d’API ? comment pouvons-nous faire alors ? 

Une astuce est d’utiliser un autre moyen pour  récupérer ces infos : L’utilisation de la console de Chrome et de son outil Google Développer. Je m’explique si vous connaissez un peu Google Chrome, il est possible d’utiliser la partie intégrante de ce navigateur « Google Web developper » (en appuyant sur la touche F12 ou CTRL maj i).

Dans l’onglet « Network » on peut retrouver également des appels via des API 

https://api.weather.com/v2/pws/observations/current?apiKey=XXX&stationId=IPONTS4&numericPrecision=decimal&format=json&units=m

// 20201022204351
// https://api.weather.com/v2/pws/observations/current?apiKey=XXX&stationId=IPONTS4&numericPrecision=decimal&format=json&units=m

{
"observations": [
{
"stationID": "IPONTS4",
"obsTimeUtc": "2020-10-22T18:43:36Z",
"obsTimeLocal": "2020-10-22 20:43:36",
"neighborhood": "Pont-Scorff",
"softwareType": null,
"country": "FR",
"solarRadiation": null,
"lon": -3.422823,
"realtimeFrequency": null,
"epoch": 1603392216,
"lat": 47.831679,
"uv": 0.0,
"winddir": 129,
"humidity": 94.0,
"qcStatus": 1,
"metric": {
"temp": 13.3,
"heatIndex": 13.3,
"dewpt": 12.3,
"windChill": 13.3,
"windSpeed": 0.0,
"windGust": 0.0,
"pressure": 1031.83,
"precipRate": 0.00,
"precipTotal": 1.78,
"elev": 46.0
}
}
]
}

 

Pour conclure 

Il existe pour l’instant des  moyens via des API (soit générées, soit récupérées via la console de Google Developper) mais rien de stable et surtout assez compliqué a mettre en oeuvre.

Nous allons donc nous tourner vers autre chose … 

A suivre !