Gage-Web API Documentation¶
API¶
- POST /admin/section/ajax/update/¶
Edits a single column of a record in list view.
- POST /admin/region/ajax/update/¶
Edits a single column of a record in list view.
- POST /admin/sensor/ajax/update/¶
Edits a single column of a record in list view.
- POST /admin/river/ajax/update/¶
Edits a single column of a record in list view.
- POST /admin/user/ajax/update/¶
Edits a single column of a record in list view.
- POST /admin/gage/ajax/update/¶
Edits a single column of a record in list view.
- POST /admin/fileadmin/delete/¶
Delete view method
- GET /admin/fileadmin/rename/¶
Rename view method
- POST /admin/fileadmin/rename/¶
Rename view method
- GET /admin/fileadmin/upload/¶
Upload view method
Parameters: - path – Optional directory path. If not provided, will use the base directory
- POST /admin/fileadmin/upload/¶
Upload view method
Parameters: - path – Optional directory path. If not provided, will use the base directory
- GET /admin/fileadmin/mkdir/¶
Directory creation view method
Parameters: - path – Optional directory path. If not provided, will use the base directory
- POST /admin/fileadmin/mkdir/¶
Directory creation view method
Parameters: - path – Optional directory path. If not provided, will use the base directory
- GET /admin/fileadmin/edit/¶
Edit view method
- POST /admin/fileadmin/edit/¶
Edit view method
- POST /admin/section/action/¶
Mass-model action view.
- POST /admin/section/delete/¶
Delete model view. Only POST method is allowed.
- GET /admin/section/edit/¶
Edit model view
- POST /admin/section/edit/¶
Edit model view
- GET /admin/section/new/¶
Create model view
- POST /admin/section/new/¶
Create model view
- POST /admin/region/action/¶
Mass-model action view.
- POST /admin/region/delete/¶
Delete model view. Only POST method is allowed.
- POST /admin/sensor/action/¶
Mass-model action view.
- POST /admin/sensor/delete/¶
Delete model view. Only POST method is allowed.
- GET /admin/region/edit/¶
Edit model view
- POST /admin/region/edit/¶
Edit model view
- GET /admin/sensor/edit/¶
Edit model view
- POST /admin/sensor/edit/¶
Edit model view
- GET /admin/region/new/¶
Create model view
- POST /admin/region/new/¶
Create model view
- GET /admin/sensor/new/¶
Create model view
- POST /admin/sensor/new/¶
Create model view
- POST /admin/river/action/¶
Mass-model action view.
- POST /admin/river/delete/¶
Delete model view. Only POST method is allowed.
- GET /admin/river/edit/¶
Edit model view
- POST /admin/river/edit/¶
Edit model view
- GET /admin/river/new/¶
Create model view
- POST /admin/river/new/¶
Create model view
- POST /admin/user/action/¶
Mass-model action view.
- POST /admin/user/delete/¶
Delete model view. Only POST method is allowed.
- POST /admin/gage/action/¶
Mass-model action view.
- POST /admin/gage/delete/¶
Delete model view. Only POST method is allowed.
- GET /admin/user/edit/¶
Edit model view
- POST /admin/user/edit/¶
Edit model view
- GET /admin/gage/edit/¶
Edit model view
- POST /admin/gage/edit/¶
Edit model view
- GET /admin/user/new/¶
Create model view
- POST /admin/user/new/¶
Create model view
- GET /admin/gage/new/¶
Create model view
- POST /admin/gage/new/¶
Create model view
- GET /api/0.1/sections/¶
List all sections
Example response:
{ "count": 2, "next": null, "prev": null, "sections": [ { "id": 2, "name": "Bear River", "url": "http://riverflo.ws/api/1.0/sections/2" }, { "id": 1, "name": "Bull Branch", "url": "http://riverflo.ws/api/1.0/sections/1" } ] }
- GET /api/0.1/sensors/¶
List all sensors
Example response:
{ "count": 17, "next": "http://riverflo.ws/api/1.0/sensors/?page=2", "prev": null, "sensors": [ { "id": 2, "type": "voltage", "url": "http://riverflo.ws/api/1.0/sensors/2" }, { "id": 3, "type": "amps", "url": "http://riverflo.ws/api/1.0/sensors/3" } ] }
- GET /api/0.1/samples/¶
List all samples
Example response:
{ "count": 10696, "next": "http://riverflo.ws/api/1.0/samples/?page=2", "prev": null, "samples": [ { "datetime": "Thu, 05 Jun 2014 13:50:27 GMT", "id": 52, "sensor": { "gage": { "id": 2, "location": "Wild River near RT 2 in Gilead Maine", "name": "Wild River at Gilead", "url": "http://riverflo.ws/api/1.0/gages/2" }, "id": 5, "type": "level", "url": "http://riverflo.ws/api/1.0/sensors/5" }, "url": "http://riverflo.ws/api/1.0/samples/52", "value": 24.0 }, { "datetime": "Thu, 05 Jun 2014 13:50:27 GMT", "id": 53, "sensor": { "gage": { "id": 2, "location": "Wild River near RT 2 in Gilead Maine", "name": "Wild River at Gilead", "url": "http://127.0.0.1:5000/api/1.0/gages/2" }, "id": 8, "type": "volts", "url": "http://riverflo.ws/api/1.0/sensors/8" }, "url": "http://riverflo.ws/api/1.0/samples/53", "value": 4.096 } ] }
- GET /api/0.1/regions/¶
List all regions
Example response:
{ "count": 5, "next": "http://riverflo.ws/api/1.0/regions/?page=2", "prev": null, "regions": [ { "html": "http://riverflo.ws/region/mahoosucs/", "id": 1, "name": "Mahoosuc Mountains", "url": "http://riverflo.ws/api/1.0/regions/1" }, { "html": "http://riverflo.ws/region/whites/", "id": 2, "name": "White Mountains", "url": "http://riverflo.ws/api/1.0/regions/2" } ] }
- GET /api/0.1/rivers/¶
List all rivers
Example response:
{ "count": 7, "next": "http://riverflo.ws/api/1.0/sensors/?page=2", "prev": null, "rivers": [ { "id": 1, "name": "Kennebec", "url": "http://riverflo.ws/api/1.0/rivers/1" }, { "id": 2, "name": "Androscoggin", "url": "http://riverflo.ws/api/1.0/rivers/2" } ] }
- GET /api/0.1/gages/¶
List all gages
Example response:
{ "count": 5, "gages": [ { "id": 2, "location": "Wild River near RT 2 in Gilead Maine", "name": "Wild River at Gilead", "url": "http://riverflo.ws/api/1.0/gages/2" }, { "id": 3, "location": "Bear River near RT 2 in Newry Maine", "name": "Bear River at Newry", "url": "http://riverflo.ws/api/1.0/gages/3" } ], "next": "http://riverflo.ws/api/1.0/gages/?page=2", "prev": null }
- GET /admin/fileadmin/¶
Index view method
Parameters: - path – Optional directory path. If not provided, will use the base directory
- GET /admin/section/¶
List view
- GET /admin/region/¶
List view
- GET /admin/sensor/¶
List view
- GET /admin/river/¶
List view
- GET /admin/user/¶
List view
- GET /admin/gage/¶
List view
- GET /api/0.1/¶
GET /api/1.0/
List of basic api routes
- GET /logout¶
View function which handles a logout request.
- GET /change¶
View function which handles a change password request.
- POST /change¶
View function which handles a change password request.
- GET /login¶
View function for login view
- POST /login¶
View function for login view
- GET /api/0.1/sensors/(int: sid)/samples¶
List samples for sensor id
- Parameters:
- id (int): Primary id key of sensor
Example response:
{ "count": 487, "next": null, "prev": null, "samples": [ { "datetime": "Thu, 05 Jun 2014 13:50:27 GMT", "id": 52, "url": "http://riverflo.ws/api/1.0/samples/52", "value": 24.0 }, { "datetime": "Thu, 05 Jun 2014 13:50:42 GMT", "id": 55, "url": "http://riverflo.ws/api/1.0/samples/55", "value": 24.0 } ], "sensor": { "id": 5, "type": "level", "url": "http://riverflo.ws/api/1.0/sensors/5" } }
- POST /api/0.1/gages/(int: gid)/sample¶
Submit new samples to gage id
- Parameters:
- id (int): Primary id key number of a gage
Samples are formatted in body of request as a JSON Web Signature using the Gage.key
Example sample submitter:
from itsdangerous import JSONWebSignatureSerializer import requests payload = {'samples':[ {'type':'level', 'value':16.7, 'datetime': str(datetime.datetime.now()) }, {'type':'amps', 'value':367.3, 'datetime': str(datetime.datetime.now()) }, {'type':'voltage', 'value':14.3, 'datetime': str(datetime.datetime.now()) }, {'type':'discharge', 'value':480, 'datetime': str(datetime.datetime.now()) } ], 'gage':{ 'id':5 }} s = JSONWebSignatureSerializer('<gage.key>') def submit(payload): data = s.dumps(payload) url = "http://riverflo.ws/api/1.0/gages/<gage.id>/sample" r = requests.post(url, data=data) if r.status_code is 200: return True else: return False
If the key matches the stored key for the gage id in the url, the server will iterate over the samples and add them to the database creating new sensors for the gage if a new sample type is found. Then the server will return JSON with a status code of 200.
Example response:
{ 'gage': {u'id': 5, 'location': 'Androscoggin River downstream of I-95 in Auburn ME', 'name': 'Androscoggin River at Auburn', 'url': 'http://riverflo.ws/api/1.0/gages/5'}, 'result': 'created', 'samples': [{'datetime': 'Tue, 04 Nov 2014 20:43:39 GMT', 'id': 10781, 'url': 'http://riverflo.ws/api/1.0/samples/10781', 'value': 16.7}, {'datetime': 'Tue, 04 Nov 2014 20:43:39 GMT', 'id': 10782, 'url': 'http://riverflo.ws/api/1.0/samples/10782', 'value': 367.3}, {'datetime': 'Tue, 04 Nov 2014 20:43:39 GMT', 'id': 10783, 'url': 'http://riverflo.ws/api/1.0/samples/10783', 'value': 14.3}, {'datetime': 'Tue, 04 Nov 2014 20:43:39 GMT', 'id': 10784, 'url': 'http://riverflo.ws/api/1.0/samples/10784', 'value': 480.0}]}
If the signature does not match, the server will return JSON with a status code of 401 - Unauthorized:
{'error': 'unauthorized', 'message': 'bad signature'}
- GET /admin/fileadmin/download/(path: path)¶
Download view method.
Parameters: - path – File path.
- GET /admin/fileadmin/upload/(path: path)¶
Upload view method
Parameters: - path – Optional directory path. If not provided, will use the base directory
- POST /admin/fileadmin/upload/(path: path)¶
Upload view method
Parameters: - path – Optional directory path. If not provided, will use the base directory
- GET /admin/fileadmin/mkdir/(path: path)¶
Directory creation view method
Parameters: - path – Optional directory path. If not provided, will use the base directory
- POST /admin/fileadmin/mkdir/(path: path)¶
Directory creation view method
Parameters: - path – Optional directory path. If not provided, will use the base directory
- GET /admin/fileadmin/b/(path: path)¶
Index view method
Parameters: - path – Optional directory path. If not provided, will use the base directory
- GET /api/0.1/sections/(int: sid)¶
Detailed information about section id
- Parameters:
- id (int): Primary key for section
Example response:
{ "access": null, "description": "Most commonly run from the where Goose Eye Brook", "id": 1, "latitude": 44.517188630525425, "location": "Ketchum, ME", "longitude": -70.93158602714539, "name": "Bull Branch", "regions": [ { "html": "http://riverflo.ws/region/mahoosucs/", "id": 1, "name": "Mahoosuc Mountains", "url": "http://riverflo.ws/api/1.0/regions/1" }, { "html": "http://127.0.0.1:5000/region/whites/", "id": 2, "name": "White Mountains", "url": "http://riverflo.ws/api/1.0/regions/2" }, { "html": "http://riverflo.ws/region/maine/", "id": 4, "name": "Maine", "url": "http://riverflo.ws/api/1.0/regions/4" } ], "url": "http://riverflo.ws/api/1.0/sections/1" }
- GET /api/0.1/sensors/(int: sid)¶
Detailed information about sensor id
- Parameters:
- id (int): Primary id key of sensor
Example response:
{ "description": null, "ended": null, "gage": { "id": 2, "location": "Wild River near RT 2 in Gilead Maine", "name": "Wild River at Gilead", "url": "http://riverflo.ws/api/1.0/gages/2" }, "id": 5, "maximum": null, "minimum": null, "recent_sample": { "datetime": "Mon, 25 Aug 2014 13:11:35 GMT", "id": 1555, "url": "http://riverflo.ws/api/1.0/samples/1555", "value": 25.6666666666667 }, "started": null, "type": "level", "url": "http://riverflo.ws/api/1.0/sensors/5" }
- GET /api/0.1/samples/(int: sid)¶
Detailed information about sample id
- Parameters:
- id (int): Primary id key of sample
Example response:
{ "datetime": "Thu, 05 Jun 2014 13:50:27 GMT", "id": 52, "sensor": { "gage": { "id": 2, "location": "Wild River near RT 2 in Gilead Maine", "name": "Wild River at Gilead", "url": "http://riverflo.ws/api/1.0/gages/2" }, "id": 5, "type": "level", "url": "http://riverflo.ws/api/1.0/sensors/5" }, "url": "http://riverflo.ws/api/1.0/samples/52", "value": 24.0 }
- GET /api/0.1/regions/(int: rid)¶
Detailed information about region id
- Parameters:
- id (int): Primary id key of region
Example response:
{ "description": "The Mahoosuc Mountains are in Maine.", "gages": [ { "id": 3, "location": "Bear River near RT 2 in Newry Maine", "name": "Bear River at Newry", "url": "http://riverflo.ws/api/1.0/gages/3" }, { "id": 1, "location": "Bull Branch at Twin Bridges in Ketchum Maine", "name": "Bull Branch", "url": "http://riverflo.ws/api/1.0/gages/1" } ], "html": "http://riverflo.ws/region/mahoosucs/", "id": 1, "name": "Mahoosuc Mountains", "sections": [ { "id": 2, "name": "Bear River", "url": "http://riverflo.ws/api/1.0/sections/2" }, { "id": 1, "name": "Bull Branch", "url": "http://riverflo.ws/api/1.0/sections/1" } ], "url": "http://riverflo.ws/api/1.0/regions/1" }
- GET /api/0.1/rivers/(int: rid)¶
Detailed information about river id
- Parameters:
- id (int): Primary id key for river
Example response:
{ "downstream": { "id": 1, "name": "Kennebec", "url": "http://riverflo.ws/api/1.0/rivers/1" }, "gages": [ { "id": 5, "location": "Androscoggin River downstream of I-95 in Auburn ME", "name": "Androscoggin River at Auburn", "url": "http://riverflo.ws/api/1.0/gages/5" }, { "id": 4, "location": "Androscoggin River below lower power plant", "name": "Androscoggin River at Rumford", "url": "http://riverflo.ws/api/1.0/gages/4" } ], "id": 2, "name": "Androscoggin", "sections": [], "tributaries": [ { "id": 3, "name": "Sunday River", "url": "http://riverflo.ws/api/1.0/rivers/3" }, { "id": 5, "name": "Wild River (Androscoggin)", "url": "http://riverflo.ws/api/1.0/rivers/5" }, { "id": 6, "name": "Peapody River", "url": "http://riverflo.ws/api/1.0/rivers/6" }, { "id": 7, "name": "Bear River (Androscoggin)", "url": "http://riverflo.ws/api/1.0/rivers/7" } ], "url": "http://riverflo.ws/api/1.0/rivers/2" }
- GET /api/0.1/gages/(int: gid)¶
Detailed information about gage id
- Parameters:
- id (int): Primary id key of a gage
Example response:
{ "html": "http://riverflo.ws/gage/androscoggin-rumford/", "id": 4, "location": null, "name": "Androscoggin River at Rumford", "regions": [ { "html": "http://riverflo.ws/region/maine/", "id": 4, "name": "Maine", "url": "http://riverflo.ws/api/1.0/regions/4" } ], "sensors": [ { "id": 10, "recent_sample": { "datetime": "Mon, 03 Nov 2014 18:15:00 GMT", "id": 5801, "url": "http://riverflo.ws/api/1.0/samples/5801", "value": 4.32 }, "type": "usgs-height", "url": "http://riverflo.ws/api/1.0/sensors/10" }, { "id": 11, "recent_sample": { "datetime": "Mon, 03 Nov 2014 18:15:00 GMT", "id": 5866, "url": "http://riverflo.ws/api/1.0/samples/5866", "value": 3230.0 }, "type": "usgs-discharge", "url": "http://riverflo.ws/api/1.0/sensors/11" } ], "url": "http://riverflo.ws/api/1.0/gages/4" }
- GET /_debug_toolbar/static/(path: filename)¶
Send a static file from the flask-debugtoolbar static directory.