Author Topic: history file with apiv2  (Read 466 times)

0 Members and 1 Guest are viewing this topic.

Offline Cocute

  • Member
  • *
  • Posts: 22
history file with apiv2
« on: April 09, 2020, 03:01:56 PM »
is possible with apiv2 obtain history file of day by hours similar old format apiv1?:
Quote
Time,TemperatureC,DewpointC,PressurehPa,WindDirection,WindDirectionDegrees,WindSpeedKMH,WindSpeedGustKMH,Humidity,HourlyPrecipMM,Conditions,Clouds,dailyrainMM,SolarRadiationWatts/m^2,SoftwareType,DateUTC
2019-11-06 00:00:22,7.9,6.6,1004.0,WSW,251,10.5,12.2,91,0.0,,,0.0,0.00,EasyWeatherV1.4.4,2019-11-05 23:00:22,
2019-11-06 00:05:10,7.8,6.5,1004.2,West,266,15.1,20.1,91,0.0,,,0.0,0.00,EasyWeatherV1.4.4,2019-11-05 23:05:10,
2019-11-06 00:10:35,7.8,6.5,1004.2,WNW,293,18.7,20.1,91,0.0,,,0.0,0.00,EasyWeatherV1.4.4,2019-11-05 23:10:35,
2019-11-06 00:15:18,7.8,6.5,1004.2,NNW,330,16.3,20.1,91,0.0,,,0.0,0.00,EasyWeatherV1.4.4,2019-11-05 23:15:18,
2019-11-06 00:20:06,7.8,6.5,1004.2,NW,313,19.8,24.1,91,0.0,,,0.0,0.00,EasyWeatherV1.4.4,2019-11-05 23:20:06,
2019-11-06 00:25:10,7.8,6.5,1004.3,West,265,28.0,32.3,91,0.0,,,0.0,0.00,EasyWeatherV1.4.4,2019-11-05 23:25:10,
2019-11-06 00:30:14,7.9,6.6,1004.3,West,262,22.7,24.1,91,0.0,,,0.0,0.00,EasyWeatherV1.4.4,2019-11-05 23:30:14,
2019-11-06 00:35:18,7.8,6.5,1004.4,WSW,258,30.2,36.4,91,0.0,,,0.0,0.00,EasyWeatherV1.4.4,2019-11-05 23:35:18,
2019-11-06 00:40:31,7.8,6.5,1004.3,WSW,254,21.6,24.1,91,0.0,,,0.0,0.00,EasyWeatherV1.4.4,2019-11-05 23:40:31,

i try with this:
https://api.weather.com/v2/pws/history/hourly?stationId=MIID&format=1&units=m&date=20200401&numericPrecision=decimal&apiKey=
but not works
Quote
{"metadata":{"transaction_id":"1429140092945:1801695336","status_code":400},"success":false,"errors":[{"code":"EAE:PDM-0000","message":"Parameter format  does not match required pattern"}]}
« Last Edit: April 09, 2020, 03:03:45 PM by Cocute »

Offline WSWeather

  • Forecaster
  • *****
  • Posts: 483
Re: history file with apiv2
« Reply #1 on: April 09, 2020, 05:49:06 PM »
No, the new API has a new data format.

The call for one day's data is:

https://api.weather.com/v2/pws/history/hourly?stationId=yourStationID&format=json&units=m&date=20200401&numericPrecision=decimal&apiKey=yourApiKey

Note that the only data format is "json".

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9279
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: history file with apiv2
« Reply #2 on: April 09, 2020, 05:56:53 PM »
You can use the WXDailyHistory.php script (see https://github.com/ktrue/WU-History ) to fetch/cache the JSON and return what the old WXDailyHistory.asp page on the (defunct) wunderground site.

Note that Day, Month, and Year queries are supported, but not the 7-Day/Week or Custom formats.  For Yearly queries, you should pre-load the monthly cache files (see the README.md on the github page for how to do that).

Hope this helps...
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

 

anything