Thirsty, Los Angeles?

This is an API around some realtime LADWP water sensors in the Owens Valley, including the Los Angeles Aqueduct.

The data is being scraped from a perhaps abandoned website which seems to have come out of one of the LADWP/Owens Valley settlements.

There are several sensor sites available and an example plot, so you can get an idea of the available data.

Do you have access to more LADWP data? I'd love to compile it here. Are you interested in more #opendata in Los Angeles? Please let us know!

Api

Sensor Sites

Each sensor represents a particular physical location where samples of a particular metric (e.g. flow rate or elevation) are taken.

GET /sites.json
curl -X GET api.thirsty.la/sites.json

Get list of available sites.

[
   {
      "created_at" : "2012-08-13T18:03:00-07:00",
      "updated_at" : "2012-08-13T18:03:00-07:00",
      "last_sampled_at" : "2012-08-13T16:58:55-07:00",
      "measurement_type" : "Elevation",
      "id" : 511525,
      "site_name" : "Mono Lk."
   },
   {
      "created_at" : "2012-08-13T18:03:01-07:00",
      "updated_at" : "2012-08-13T18:03:01-07:00",
      "last_sampled_at" : "2012-08-13T16:58:56-07:00",
      "measurement_type" : "Elevation",
      "id" : 901125,
      "site_name" : "Fairmont Reservoir"
   },
   ...
]
GET /sites/<id>.json
curl -X GET api.thirsty.la/sites/490.json

Get an individual site.

{
   "created_at" : "2012-08-13T18:01:42-07:00",
   "updated_at" : "2012-08-13T18:01:42-07:00",
   "last_sampled_at" : "2012-08-13T16:58:56-07:00",
   "measurement_type" : "Flow",
   "id" : 490,
   "site_name" : "LAA at Alabama"
}

Sensor Samples

A sample is a measurement taken at a particular time from a particular Sensor Site.

GET /sites/<id>/samples.json
curl -X GET api.thirsty.la/sites/490/samples.json

Get the samples for an individual site.

{ "samples": [{
      "created_at" : "2012-08-13T18:01:42-07:00",
      "value" : 480,
      "updated_at" : "2012-08-13T18:01:42-07:00",
      "site_id" : 490,
      "id" : 121,
      "sampled_at" : "2012-08-13T16:58:56-07:00"
   },
   {
      "created_at" : "2012-08-13T18:01:42-07:00",
      "value" : 478,
      "updated_at" : "2012-08-13T18:01:42-07:00",
      "site_id" : 490,
      "id" : 122,
      "sampled_at" : "2012-08-13T16:44:15-07:00"
   },
   ...
  ],
  "sampled_after": null,
  "sampled_before": null
}

You can filter samples by date using the sampled_before and/or sampled_after parameters. The parameter should be formatted as a JSON serialized date.

GET /sites/<id>/samples.json?sampled_after=<date>&sampled_before=<date>
curl -X GET api.thirsty.la/sites/490/samples.json?sampled_after=%222012-07-15T06%3A42%3A37.573Z%22

Get all samples for site 490 after July 15, 2012.

{ "samples": [
   {
      "created_at" : "2012-08-13T18:01:42-07:00",
      "value" : 480,
      "updated_at" : "2012-08-13T18:01:42-07:00",
      "site_id" : 490,
      "id" : 121,
      "sampled_at" : "2012-07-16T16:58:56-07:00"
   },
   {
      "created_at" : "2012-08-13T18:01:42-07:00",
      "value" : 478,
      "updated_at" : "2012-08-13T18:01:42-07:00",
      "site_id" : 490,
      "id" : 122,
      "sampled_at" : "2012-07-16T16:44:15-07:00"
   },
   ...
  ],
  "sampled_after": "2012-07-15",
  "sampled_before":"2013-03-15"
}
/* One way to get a date in the appropriate format, using Javascript */
var sampled_after_date = new Date(2012, 06, 15);
var sampled_after_date_param = encodeURI(
                                  JSON.stringify(
                                    sampled_after_date));