Statistics
Returns minimum, maximum, mean (average) and counts for a defined time period with Synoptic basic and advanced quality control applied. Statistics are available for the entire period of record for all stations.
Request Format
A Statistics request is an HTTP URL with the following form:
https://api.synopticdata.com/v2/stations/statistics
Acquiring data from this web service requires certain parameters. When encoding URLs, all parameters are separated using the ampersand (&) character and their value is indicated by an equal sign (=). Below is a list of accepted parameters.
token
(required), Your application’s API token. This is used to identify who is requesting API data. You are never required to use multiple tokens, but you can use as many as you need. Learn more in our tokens overview.At least one station selection parameter (required):
Either
start
andend
, orrecent
(one is required but not both)start
andend
, Defines time range for statistics to be returned by the request (start and end inclusive).
Ifperiod=day
must be formatted as YYYYmmdd, ifperiod=month
, must be formatted as YYYYmm.recent
, Indicates the integer number of days or months to return, previous to the current date. For example:recent=5&period=day
will return the last 5 days of statistics (note that other data services definerecent
in minutes).
vars
, The statistics service requires users to pass at least one variable. Most variables are supported.
Optional Parameters
period
(day [default], month), The time period represented by returned statistics. For example,start=20250101&end=20250131&period=day
will return daily statistics for January 2025.statistic
(all [default], min, max, mean, count), The type of statistic to return,all
(default) returns all available statistics.obtimezone
(UTC [default], local), Indicates if the time zone of the response is in UTC or the local time zone of the station. Sets the time zone applied to the observation output (input times associated withstart
andend
are always UTC). Example:obtimezone=local
showemptystations
(0 [default], 1), Indicates if stations with no observations will be returned. Setting to1
will return any station meeting the defined time period, variables, and geographic or network parameters, even if there are no observation data available.showemptyvars
(0 [default], 1), Indicates if variables with no observations for the requested time period will be returned. Default behavior is to remove any variables from theSTATISTICS
element if no data is present. Setting to 1 will return keys in theSTATISTICS
element for any requested variables. This guarantees that all keys in theSENSOR_VARIABLES
element will be present in theSTATISTICS
element. Note that if all requested variables are empty you will also need to passshowemptystations=1
to retain the station and variables in the response.units
(metric [default], english, [custom format]), Defines the unit of measure for returned data. For standard measurements used by many in the United Statesenglish
will fill most needs. There is also the ability to support custom unit configurations. This is achieved by accessing the variable group such as “temp” and setting the desired unit using a pipe (|
) character. The following list describes the available units for each variable group.temp
(C, F, K), Temperature: Celsius, Fahrenheit and Kelvin.speed
(mps, mph, kph, kts), Speed/Velocity: Meters per second, miles per hour, kilometers per hour, knots.pres
(pa, mb, inhg), Pressure: Pascals, millibars, inches mercury.height
(m, ft), Height: Meters, feet.precip
(mm, cm, in), Precipitation: Millimeters, centimeters, inches.alti
(pa, inhg), Altimeter: Pascals, inches mercury.
Furthermore, it is possible to modify one of the preset settings (metric/english). This is achieved by appending a variable group and unit to the parameter string with a comma. For example, to use “english” units with any speed variables in mph (instead of default knots) the parameter would be
&units=english,speed|mph
.
The following example will request all daily (period=day
) statistics for air temperature for KSLC (Salt Lake City Airport) for the month of January in 2025:
https://api.synopticdata.com/v2/stations/statistics?stid=kslc&vars=air_temp&period=day&start=20250101&end=20250131&token=YOUR_TOKEN_HERE
Response Format Parameters
timeformat
, Defines a time format that all time stamps in the data response to be formatted to. By default the API will return time values in ISO 8601 format. This behavior can be changed by passing a string with a valid strftime expression. Below are some common examples.timeformat=%m/%d/%Y at %H:%M
would yield “06/22/2017 at 17:06”timeformat=%b%20%d%20%Y%20-%20%H:%M
would yield “Jun 22 2017 - 17:06”timeformat=%s
returns Unix/POSIX time in terms of seconds (this parameter cannot be used withobtimezone
). This is a special function in addition to the supported strftime arguments.
output
(json [default], xml), Indicates the response format of the request. It’s recommended to use the JSON format which there are well supported parsing libraries in all major languages.
Request Response
JSON Format
The Statistics service will return its results in a single organized and self describing JSON object. At a minimum, every request will return a JSON object with a SUMMARY
field.
An example JSON response would be:
{
STATION: [
{
ID: "1",
STID: "WBB",
NAME: "U of U William Browning Building",
ELEVATION: "4806.0",
LATITUDE: "40.76623",
LONGITUDE: "-111.84755",
STATUS: "ACTIVE",
MNET_ID: "153",
STATE: "UT",
TIMEZONE: "America/Denver",
ELEV_DEM: "4727.7",
PERIOD_OF_RECORD: {
start: "1997-01-01T00:00:00Z",
end: "2025-02-19T05:55:00Z"
},
UNITS: {
position: "m",
elevation: "ft"
},
SENSOR_VARIABLES: {
air_temp: {
air_temp_set_1: {}
}
},
STATISTICS: {
air_temp_set_1: [
{
min: -3.58,
max: 28.72,
mean: 12.87,
count: 44638.0,
min_time: "2023-10-29T13:53:00Z",
max_time: "2023-10-09T22:53:00Z",
time_period: {
type: "month",
value: "2023-10",
timezone: "Etc/UTC"
}
},
{
min: -4.48,
max: 20.83,
mean: 6.37,
count: 43125.0,
min_time: "2023-11-27T11:35:00Z",
max_time: "2023-11-04T22:21:00Z",
time_period: {
type: "month",
value: "2023-11",
timezone: "Etc/UTC"
}
}
]
},
RESTRICTED: false,
RESTRICTED_METADATA: false
}
],
SUMMARY: {
NUMBER_OF_OBJECTS: 1,
RESPONSE_CODE: 1,
RESPONSE_MESSAGE: "OK",
METADATA_PARSE_TIME: "0.2 ms",
METADATA_DB_QUERY_TIME: "5.1 ms",
DATA_QUERY_TIME: "9.4 ms",
DATA_PARSING_TIME: "0 ms",
TOTAL_DATA_TIME: "10 ms",
VERSION: "v2.25.2"
},
UNITS: {
air_temp: "Celsius"
}
}
SUMMARY{}
NUMBER_OF_OBJECTS
, is a integer value of the number of stations returned.RESPONSE_CODE
, is a numerical code indicating the status of the request.“1” = “OK”
“2” = “Zero Results”
“200” = “Authentication failure”
“400” = “Violates a rule of the API”
RESPONSE_MESSAGE
, is a string explaining theRESPONSE_CODE
.VERSION
, is the API’s current version number.METADATA_PARSE_TIME
, is the amount of time it took for the API to parse the metadata.METADATA_QUERY_TIME
, is the amount of time it took for the API to query the metadata.DATA_QUERY_TIME
, is the amount of time it took for the API to query the data from the database.DATA_PARSING_TIME
, is the amount of time it took for the API to format the queried data into output.TOTAL_DATA_TIME
, is the amount of time if took for the API to query and parse the data.
STATION[]
SENSOR_VARIABLES[]
, summary of variables in the STATISTICS element.STATISTICS[]
, contains all the station’s statistics over the specified period.
UNITS{}
A list of the units of each variable in the
STATISTICS
element.