Categories
Category List
Returns a list of categories for the specified customer.
URL
http://api.exactraq.net/v1/customers/customer_key/categories.format
Formats
json, xml
Parameters
None
Response
JSON Example:
[{ "category": { "name": "Test Category", "description": "Category Description." "created_at": "2010-03-19T09: 41: 14-06: 00", "updated_at": "2010-03-19T09: 41: 14-06: 00", } }, { "category": { "name": "Another Category", "description": "Description of category." "created_at": "2010-01-23T13:20:36-07:00", "updated_at": "2010-01-23T13:20:36-07:00", } }]
Stations
Station List
Returns a list of stations for the specified customer.
URL
http://api.exactraq.net/v1/customers/customer_key/stations.format
Formats
json, xml
Paramaters
None
Response
JSON Example:
[{ "station": { "name": "Test Station", "latitude": 37.105243, "created_at": "2009-11-10T09:27:15-07:00", "updated_at": "2010-03-05T11:32:57-07:00", "id": 11, "longitude": -113.55736 } }, { "station": { "name": "Another Station", "latitude": null, "created_at": "2010-01-23T13:20:36-07:00", "updated_at": "2010-01-23T13:20:36-07:00", "id": 40, "longitude": null } }]
Sensors
Station Sensor List
Returns a list of sensors (with latest readings for json) for the specified station
URL
http://api.exactraq.net/v1/customers/customer_key/stations/id/sensors.format
Formats
json, xml
Paramaters
None
Response
JSON Example:
[{ "name": "Sensor Name", "created_at": "2009-11-10T14:39:14-07:00", "updated_at": "2009-11-10T15:11:55-07:00", "min": null, "max": null, "normal_min": null, "normal_max": null, "id": 26, "unit": { "name": "Feet", "id": 6, "abbreviation": "Ft" }, "latest_reading": { "sensor_value": { "id":17078, "value":24.8, "recorded_at":"2010-04-30T16:00:00-06:00", "created_at":"2010-04-30T16:17:00-06:00", "updated_at":null, "interval": { "id":1 "name":"Hourly", "data_type":"average", "minutes":60, } } }, "ivr_access_code": null, "precision": 2 } }]
Sensor Values
Returns sensor values for a set of sensors
URL
http://api.exactraq.net/v1/customers/customer_key/sensor_values.format?sensor_ids=1,2,3
Formats
json, xml
Paramaters
-
Required:
- sensor_ids=1,2,3 - Comma separated list of sensor ids to retrieve values for
-
Optional:
- interval_id=1 - Only include values with a specific interval
-
Dates (optional) - If no date range is specified, only the latest reading for each sensor is returned
- since=2010-01-01T00:00:00-07:00 - Only include values created after timestamp
- until=2010-01-02T00:00:00-07:00 - Only include values created before timestamp
- age=86400 - Returns values created in the last 24 hours
Response
JSON Example:
[{ "sensor_id": "98", "unit": { "name": "Feet", "id": 6, "abbreviation": "Ft" }, "sensor_values": [{ "sensor_value": { "interval": { "data_type": "Average", "name": "Hourly", "id": 1, "minutes": 60 }, "recorded_at": "2010-01-20T09:00:00-07:00", "value": 0.07, "updated_at": "2010-01-23T13:42:10-07:00", "id": 1809, "created_at": "2010-01-23T13:42:10-07:00" } }] }, { "sensor_id": "93", "unit": { "name": "deg C", "id": 9, "abbreviation": "C" }, "sensor_values": [{ "sensor_value": { "interval": { "data_type": "Average", "name": "Half Hour", "id": 10, "minutes": 30 }, "recorded_at": "2010-01-23T04:00:00-07:00", "value": 1062.0, "updated_at": "2010-01-23T13:32:35-07:00", "id": 1, "created_at": "2010-01-23T13:32:35-07:00" } }] }]
Intervals
Interval List
Returns a list of intervals for the specified customer.
URL
http://api.exactraq.net/v1/customers/customer_key/intervals.format
Formats
json, xml
Paramaters
None
Response
JSON Example:
[{ "interval": { "data_type": "Average", "name": "Hourly", "id": 1, "minutes": 60 } }, { "interval": { "data_type": "Average", "name": "Daily", "id": 2, "minutes": 1440 } }, { "interval": { "data_type": "Maximum", "name": "Daily", "id": 8, "minutes": 1440 } }, { "interval": { "data_type": "Minimum", "name": "Daily", "id": 9, "minutes": 1440 } }]
Webcams
Webcam List
Returns a list of webcams for the specified customer.
URL
http://api.exactraq.net/v1/customers/customer_key/webcams.format
Formats
json, xml
Paramaters
None
Response
JSON Example:
[{ "webcam": { "name": "Test", "created_at": "2009-12-30T14:00:40-07:00", "updated_at": "2009-12-30T14:51:43-07:00", "id": 1, "latest_image": { "image_file_name": "1262300686.jpg", "created_at": "2009-12-31T16:04:47-07:00", "updated_at": "2009-12-31T16:04:47-07:00", "medium_url": "http://api.exactraq.net/system/images/34/medium/1262300686.jpg", "thumbnail_url": "http://api.exactraq.net/system/images/34/thumb/1262300686.jpg", "large_url": "http://api.exactraq.net/system/images/34/large/1262300686.jpg" } } }, { "webcam": { "name": "Another Webcam", "created_at": "2009-12-30T16:35:30-07:00", "updated_at": "2009-12-30T16:55:54-07:00", "id": 2, "latest_image": { "image_file_name": "now.jpg", "created_at": "2009-12-30T16:49:02-07:00", "updated_at": "2009-12-30T16:49:02-07:00", "medium_url": "http://api.exactraq.net/system/images/11/medium/now.jpg", "thumbnail_url": "http://api.exactraq.net/system/images/11/thumb/now.jpg", "large_url": "http://api.exactraq.net/system/images/11/large/now.jpg" } } }]
Specific Webcam
Returns the latest image for a specific webcam
URL
http://api.exactraq.net/v1/customers/customer_key/webcams/id.format
Formats
json, xml, jpg
Paramaters
-
Optional:
- size=large - Only used for JPG format requests. Possible values are: thumbnail, medium, large. If not specified, the large size will be returned.
Response
If a format of 'jpg' is used, the response will be an HTTP Redirect to the actual image file.
JSON Example:
{ "webcam_image": { "image_file_name": "1262300686.jpg", "created_at": "2009-12-31T16:04:47-07:00", "updated_at": "2009-12-31T16:04:47-07:00", "medium_url": "http://api.exactraq.net/system/images/34/medium/1262300686.jpg", "thumbnail_url": "http://api.exactraq.net/system/images/34/thumb/1262300686.jpg", "large_url": "http://api.exactraq.net/system/images/34/large/1262300686.jpg" } }
Other Information
JSON Callbacks
If you include a 'callback' parameter with any JSON request, the returned JSON will be wrapped in that callback function so you can automatically execute it.
Example
The following example code uses jquery and the datejs library to query the API and insert the latest data in each span with a class of "sensor-data" and an id like "sensor-1".
Code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>API Example</title> <script src="javascripts/jquery.js" type="text/javascript"></script> <script src="javascripts/date.js" type="text/javascript"></script> <script type="text/javascript"> const API_URL = 'http://api.exactraq.com/v1/customers/123YOURAPIKEY'; $(function() { var ids = $('.sensor-data').map(function() {return this.id.match('sensor-([0-9]+)')[1]}).get().join(','); $.getJSON(API_URL + '/sensor_values.json?sensor_ids=' + ids + '&callback=?', function(data) { $.each(data, function(index, value) { var id = value.sensor_id; $.each(value.sensor_values[0], function(index, sensor_value) { html = '' html += " was " + sensor_value.value + " " + value.unit.abbreviation; html += " at " + Date.parse(sensor_value.recorded_at).toString("h:mm tt M/d/yyyy"); $('#sensor-' + id).html(html); }); }); }) }); </script> </head> <body> <div class="sensor"> <span class="sensor-name">Example Sensor</span> <span class="sensor-data" id="sensor-1">Loading...</span> </div> </body> </html>
Result
Example Sensor was 0 cfs at 8:00 AM 11/24/2024