Windguru Station JSON API 1.2.22 (25.6.2015)

Table of Contents

Documentation for the Windguru Stations API

URL of the API: https://www.windguru.cz/int/wgsapi.php

Required parameters for all requests:

Parameters
uid | id_stationidentification of the station
  • you must specify at least one of these
  • UID: of the station = usually the MAC address of the station, or
  • id_station: ID of the station
qquery, see list below
passwordpassword of the station, there are more options, either will work:
  • MD5 hash of the API password you set in station admin (RECOMMENDED, especially in any apps where you don't want to reveal your station admin password)
  • API password you set in station admin (plain text)
  • MD5 hash of the station admin password
  • station admin password (plain text)
formatoutput format:
  • json ... JSON (default)
  • jsonpreview ... same as 'json' but sends 'Content-Type: text/html' header - browser will display the JSON (usable for debug)
  • jsonpretty ... same as 'jsonpreview' but with human readable formatting (good for exploring the API and debug)
  • preview ... shows structure of the reply as array (same output as from PHP print_r() function)

Different queries (q) may have other required and/or optional parameters, see below.

DESCRIPTION OF AVAILABLE API METHODS (q parameters):

API method is always called by providing its name as q paramater


q=station_data_current

returns the current measurements of the station, the last that were reported, example:

{
"wind_avg":12.6, --> average wind speed (knots)
"wind_max":20.3, --> maximum wind speed (knots)
"wind_min":8, --> minimum wind speed (knots)
"wind_direction":22, --> wind direction (degrees, 0=north, 90=east...)
"temperature":21.5, --> temperature (celsius)
"rh":43, --> relative humidity (%)
"datetime":"2013-06-11 19:41:10 CEST", --> date and time of the measurement
"unixtime":1370972470 --> unix timestamp of the measurement
}

If some of the reported values are not available they will be "null". The api is also used for stations of other types then "Windguru Station" that's why we have pressure parametr despite WG stations are not able to report this, at least for now... Temperature and humidity will only be reported if your station is equipped with the optional sensor.

q=station_data

Returns measurements for given interval. Data come as arrays of different parameters, see example below

optional parameters:

Parameters
from(string) start time of the interval, the string can actually be anything supported by PHP strtotime function - see http://www.php.net/manual/en/datetime.formats.php for what is possible, (default: time of oldest record)
  • Examples: "2014-01-07 18:11:00", "now", "yesterday noon", "-1 hour" etc..
to(string) end time of the interval, same format as from (default: now)
avg_minutes(int) averaging interval in minutes (default: 10)
  • With this you can set the detail of data output. Station reports data every minute but in many cases you will not need so much detail.
  • wind_avg, wind_direction, rh will then contain average for given period, wind_max will contain maximum value for given period, wind_min minimum value for given period
  • Example: enter 60 to get hourly average, max and min wind speed etc..
  • If you want to report raw data (every single measurent exactly as reported by station) set avg_minutes=0
vars(string) list of variables that you are interested in, separated by comma (default: ALL)
  • Example: "vars=wind_avg,temperature" would only output these 2 variables (note: output always contains datetime and unixtime)
Warning
This method can potentially dump a lot of data and be very heavy on windguru server and database, please be careful when setting the parameters!

Example:

{
"datetime":[
"2014-01-12 10:30:00", --> dates and times (local time)
"2014-01-12 10:40:00",
...
],
"unixtime":[ --> unix timestamps
1389519000,
1389519600,
...
],
"wind_avg":[ --> average wind speeds (knots)
6.1,
7,
...
],
"wind_max":[ --> maximum wind speeds (knots)
9.6,
11.3,
...
],
"wind_min":[ --> minimum wind speeds (knots)
2.6,
3.2,
...
],
"wind_direction":[ --> wind directions (degrees, 0=north, 90=east...)
273,
269,
...
],
"temperature":[ --> temperatures (celsius)
2.3,
2.4,
...
],
"rh":[ --> relative humidity (%)
78,
78,
...
]
}

If some of the reported values are not available they will be "null".

q=station_data_csv

Returns measurements for given interval as CSV file, example output below.

Contents of the output are managed using the same parameters as q=station_data the only difference is the output format.

Note
This query is a little special. As it ouputs data as CSV, the general "format" parameter that determine the API output format will be ignored, server will simply return file that contain the CSV formatted data.
If you want to dump a lot of data, this is the recommeded method as the data are dumped directly from database and much less demanding on server resources.
Warning
This method can potentially dump a lot of data and be very heavy on windguru server and database, please be careful when setting the parameters!

Example:

datetime,wind_avg,wind_max,wind_min,wind_direction,temperature,rh
2013-06-01 21:30:00,4.3,8.7,,338,14.3,96
2013-06-01 21:40:00,5.2,11.3,,338,14.3,96
2013-06-01 21:50:00,6.1,12.1,,326,14.3,96
2013-06-01 22:00:00,4.8,10.4,,315,14.3,96
2013-06-01 22:10:00,6.1,12.1,,315,14.3,96
2013-06-01 22:20:00,5.6,12.1,,338,14.2,97
2013-06-01 22:30:00,5.2,9.5,,338,14.1,97
2013-06-01 22:40:00,6.5,13.0,,326,14.1,96
2013-06-01 22:50:00,4.8,11.3,,326,13.9,97
...

q=station_data_last

Returns measurements for last interval, like for last 1 hour. Data come as arrays of different parameters, see example

optional parameters:

Parameters
hours(int) length of the last interval in hours
avg_minutes(int) averaging interval in minutes (default: 10)
  • With this you can set the detail of data output. Station reports data every minute but in many cases you will not need so much detail.
  • wind_avg, wind_direction, rh will then contain average for given period, wind_max will contain maximum value for given period, wind_min minimum value for given period
  • Example: enter 60 to get hourly average, max and min wind speed etc..
  • If you want to report raw data (every single measurent exactly as reported by station) set avg_minutes=0
back_hours(float) go back in history (default: 0)
  • Example: hours=3, back_hours=1 => would show data from 4 hours ago to 1 hour ago
  • Example: hours=1, back_hours=5.5 => would show all measurements between 6 hr 30 min ago to 5 hr 30 min ago
vars(string) list of variables that you are interested in, separated by comma (default: ALL)
  • Example: "vars=wind_avg,temperature" would only output these 2 variables (note: output always contains datetime and unixtime)
{
"datetime":[
"2014-01-12 10:30:00", --> dates and times (local time)
"2014-01-12 10:40:00",
...
],
"unixtime":[ --> unix timestamps
1389519000,
1389519600,
...
],
"wind_avg":[ --> average wind speeds (knots)
6.1,
7,
...
],
"wind_max":[ --> maximum wind speeds (knots)
9.6,
11.3,
...
],
"wind_min":[ --> minimum wind speeds (knots)
2.6,
3.2,
...
],
"wind_direction":[ --> wind directions (degrees, 0=north, 90=east...)
273,
269,
...
],
"temperature":[ --> temperatures (celsius)
2.3,
2.4,
...
],
"rh":[ --> relative humidity (%)
78,
78,
...
]
}

If some of the reported values are not available they will be "null".

q=station_data_last_csv

Similiar to q=station_data_csv this query will return measurements for last given interval as CSV file, example output below.

Contents of the output are managed using the same parameters as q=station_data_last the only difference is the output format.

Note
This query is a little special. As it ouputs data as CSV, the general "format" parameter that determine the API output format will be ignored, server will simply return file that contain the CSV formatted data.
If you want to dump a lot of data, use this or q=station_data_csv as the data are dumped directly from database and much less demanding on server resources.

Example:

datetime,wind_avg,wind_max,wind_min,wind_direction,temperature,rh
2013-06-01 21:30:00,4.3,8.7,,338,14.3,96
2013-06-01 21:40:00,5.2,11.3,,338,14.3,96
2013-06-01 21:50:00,6.1,12.1,,326,14.3,96
2013-06-01 22:00:00,4.8,10.4,,315,14.3,96
2013-06-01 22:10:00,6.1,12.1,,315,14.3,96
2013-06-01 22:20:00,5.6,12.1,,338,14.2,97
2013-06-01 22:30:00,5.2,9.5,,338,14.1,97
2013-06-01 22:40:00,6.5,13.0,,326,14.1,96
2013-06-01 22:50:00,4.8,11.3,,326,13.9,97
...