Skip to content

Instantly share code, notes, and snippets.

@hartsick
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hartsick/6f03d95e3d0aed17547a to your computer and use it in GitHub Desktop.
Save hartsick/6f03d95e3d0aed17547a to your computer and use it in GitHub Desktop.
reveaLA-API documentation
API documentation
Open to all
POST /session
logs user into session
params:
{
'session': {
'email': ...
'password': ...
}
}
response:
(with successful email + password)
status: 200
body: {
'access_token': ...
'token_type': 'bearer'
}
POST /user
creates a user
params:
{
'user': {
'name': ...
'username': ...
'email': ...
'password': ...
'password_confirmation': ...
}
}
response:
on successful create:
status: 201
body: {
'name': ...
'username': ...
'email': ...
'spots': [...]
}
on failed create:
status: 422
body (example): {
'email': 'is invalid'
}
GET /spots
show all spots of interest
response
[
{
'spot_id': ...
'name': ...
'tag': ...
'addresss': ...
'latitude': ...
'longitude': ...
},
{
'spot_id': ...
'name': ...
'tag': ...
'addresss': ...
'latitude': ...
'longitude': ...
},
{
'spot_id': ...
'name': ...
'tag': ...
'addresss': ...
'latitude': ...
'longitude': ...
},
...
]
POST /closest
gets next closest spot. if spot found and user logged in, saves found spot to user
params:
takes user current lat & lon, plus found spot_id (if any)
{
'latitude': ...
'longitude': ...
'spot_id': ...
'found_spots': [...]
}
response:
responds with next closest spot to user
{
'spot_id': ...
'name': ...
'tag': ...
'address': ...
'latitude': ...
'longitude': ...
}
Requires Access Token for all listed past this point
GET /user
get logged in user's info
response: {
'name': ...
'username': ...
'email': ...
'spots': [...]
}
PUT or PATCH /user
update logged in user info
params:
{ 'user': {
'first_name': ...
'last_name': ...
'email': ...
'password': ...
'password_confirmation': ...
}
}
response:
on successful update:
status: 204
no body
on failed update:
status: 422
body (example): {
'email': 'is invalid'
}
DELETE /user
delete currently logged in user
response:
status: 200
body: none
POST /spots
create a new spot
params:
{
"spot": {
TO DO
}
}
response:
{
TO DO
}
EVERYTHING ELSE
@hartsick
Copy link
Author

create new user:
curl -i -X POST -H "Content-Type:application/json" -d '{ "user": { "username": "username", "name": "this is my name", "email": "email@email.com", "password": "password1234", "password_confirmation": "password1234"}}' http://107.170.214.225/user

@hartsick
Copy link
Author

update existing user:
curl -i -X PATCH -H "Content-Type:application/json," -H "Authorization: Token authorization_token1234" -d '{ "user": { "username": "minor"}}' http://107.170.214.225/user

@hartsick
Copy link
Author

create new session:
curl -i -X POST -H "Content-Type:application/json" -d '{ "session": { "email": "master@user.com", "password": "masterpassword"}}' http://107.170.214.225/session

@hartsick
Copy link
Author

query for closest point based on user location:
curl -i -X POST -H "Content-Type:application/json" -d '{"spot_id":"1","latitude":"100", "longitude":"30"}' http://107.170.214.225/closest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment