This repository has been archived by the owner on Jul 12, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Getting Started with the API
Tyler Hampton edited this page Nov 28, 2015
·
1 revision
How to make requests against the existing staging API.
Here is the current staging server. It is running on an micro server in AWS so it may not be the most stable application at the moment but it should do for serving requests.
- Click on the 'Register' button
- Enter your name and email address and password and click 'Create Account'.
- Once your account is created click 'Log in'.
Currently there are no existing API clients for Calidrought (boo) so the authentication process is somewhat tedious.
Go to your Dashboard and get your client secret id and client secret key and use those to make a request for an OAuth bearer token. This example is done in httpie but curl is fine as well.
⋊> ~ http --auth <client secret id>:<client secret key> 'http://ec2-54-167-131-100.compute-1.amazonaws.com/oauth/token' grant_type=client_credentials
HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 354
Content-Type: application/json; charset=utf-8
Date: Sat, 28 Nov 2015 19:45:46 GMT
ETag: W/"162-vZRerJV+m4I4P3SOotxnhA"
X-Powered-By: Express
{
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIyWkMzMDU4OUxDODdDTlM0NUVKUUlaR05PIiwiaXNzIjoiaHR0cHM6Ly9hcGkuc3Rvcm1wYXRoLmNvbS92MS9hcHBsaWNhdGlvbnMvWXNyQUhXdnd4NmhlVXp0eWxlUjJUIiwiaWF0IjoxNDQ4NzM5OTQ3LCJleHAiOjE0NDg3NDM1NDcsInNjb3BlIjoiIn0.P7dLE_TSkFtk22SD6YLwKLUQJWkmk9rjNN1GTgXt4m8",
"expires_in": 3600,
"scope": "",
"token_type": "bearer"
}
Then use that access token to authenticate against protected routes (read: /api
).
⋊> ~ http GET http://ec2-54-167-131-100.compute-1.amazonaws.com/api/stations 'Authorization:Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIyWkMzMDU4OUxDODdDTlM0NUVKUUlaR05PIiwiaXNzIjoiaHR0cHM6Ly9hcGkuc3Rvcm1wYXRoLmNvbS92MS9hcHBsaWNhdGlvbnMvWXNyQUhXdnd4NmhlVXp0eWxlUjJUIiwiaWF0IjoxNDQ4NjcxMjk2LCJleHAiOjE
0NDg2NzQ4OTYsInNjb3BlIjoiIn0.wyW3aQTZ0c7R0jZ22l_nyclIvp51MfGRo9QDxuM6NZ8'
HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 186
Content-Type: application/json; charset=utf-8
Date: Sat, 28 Nov 2015 00:53:05 GMT
ETag: W/"ba-EliylC93WA4U7SaKnCCVRw"
X-Powered-By: Express
[
{
"County": "State of Arizona",
"Elevation": "3700' ft",
"Hydrologic Area": "COLORADO RIVER",
"River Basin": "COLORADO R",
"Station ID": "MEA",
"stationID": "ce2f7f14-ca1c-48e0-815c-23639298f89c"
}
]
Currently, the only resource available is stations taken from the California Data Exchange Center's website.