https://friend-finder-levi.herokuapp.com/api (All CRUD calls will be made to this url + /[listed endpoint])
Listed endpoint:
POST /auth/register
Creates a new user.
Example request body:
{
"name": "Levi",
"email": "levi@email.com",
"password": "lambda4ever",
"dob": "1994-09-21"
}
Email must be unique/cannot already exist in database.
"dob" = "Date of Birth
Successful status (201): Responds with newly created User object.
Listed endpoint:
POST /auth/login
Logs user in and provides Authentication token to be stored client-side.
Example request body:
{
"email": "levi@email.com",
"password": "lambda4ever"
}
Successful status (200): Responds with:
{
message: "Welcome {user's name}!",
user_id: {user's user_id},
token: ${auth_token}
}
Be sure to save the
Listed endpoint:
GET /user
Gets list of all users in the database.
Successful status (200): Responds with array of users from the database.
Listed endpoint:
GET /user/:user_id
Gets an individual user by their user id.
Successful status (200): Responds with array containing the specific user object.
ie:
{
"user_id": "6",
"name": "Levi",
"email": "levi@email.com",
"password": "lambda4ever",
"dob": "1994-09-21",
"gender": "Male",
"coordinates": NULL,
"location": NULL,
"profile_img": NULL,
"bio": NULL
}
Listed endpoint:
GET /user/hobbies/:user_id
Gets a list of all hobbies added under the user's id.
Successful status (200): Responds with array containing the user's hobbies.
ie:
[
{
"hobby_id": "1",
"name": "Reading"
}
]
Listed endpoint:
POST /user/hobbies/:user_id
Adds a hobby to the hobbies table under the user's id.
Example request body:
{
"name": "Skydiving"
}
Successful status (201): Responds with the newly added hobby.
ie:
{
"hobby_id": "9",
"name": "Skydiving"
}
Listed endpoint:
DELETE /user/hobbies/:user_id/:hobby_id
Removes a hobby from the user's list of hobbies.
Successful status (200): Responds with:
{
message: "Hobby removed."
}
Listed endpoint:
PUT /survey/:user_id
Updates a user's information via survey. (No auth required)
Example request body:
{
"updated_key": "updated_value"
}
Successful status (201): Responds with:
{
message: "User updated successfully."
}
Listed endpoint:
DELETE /user/:user_id
Deletes a user from the database.
Successful status (200): Responds with:
{
message: "User with id: ${user_id} successfully deleted."
}
Listed endpoint:
GET /user/:user_id/swipeable
Returns a list of users who have not been swiped by the active user (useful for presenting new users for the user to swipe on).
Successful status (200): Responds with either:
[
{
"user_id": "1",
"name": "Levi",
"dob": "1994-09-21",
"gender": "Male",
"coordinates": NULL,
"location": NULL,
"profile_img": NULL,
"bio": "This is your friend's bio"
}, ...
]
or:
{
message: "You've swiped on all available users!"
}
if there are no more swipeable users.
Listed endpoint:
GET /user/:user_id/requests
Returns a list of users who have swiped on you and have requested your friendship.
Successful status (200): Responds with either:
[
{
"user_id": "1",
"name": "Levi",
"dob": "1994-09-21",
"gender": "Male",
"coordinates": NULL,
"location": NULL,
"profile_img": NULL,
"bio": "This is your friend's bio"
}, ...
]
or:
{
message: "You have no requests currently."
}
if there are no requests.
Listed endpoint:
POST /messages/:user_id/:friend_id
Sends a message from the user (indicated by the user_id) to a friend (indicated by the friend_id).
Example request body:
{
"message": "Hello friend!"
}
Successful status (201): Responds with:
{
message: "Message created."
}
Listed endpoint:
GET /messages/:user_id/:friend_id
Gets an array of all messages between two users sorted by when the messages were posted.
Successful status (200): Responds with:
[
{
"message_id": "1",
"from_id": "1",
"to_id": "2",
"message": "Hello friend!"
}, ...
]
Listed endpoint:
GET /friends/:user_id
Gets an array of all the user's friends.
Successful status (200): Responds with:
[
{
"user_id": "1",
"name": "Levi",
"dob": "1994-09-21",
"gender": "Male",
"coordinates": NULL,
"location": NULL,
"profile_img": NULL,
"bio": "This is your friend's bio"
}, ...
]
Listed endpoint:
DELETE /friends/:user_id/:friend_id
Removes the given users from your friends list, deletes all previous swipes you had on the given user, and adds a new decline swipe to the Swipes database so that the user will no longer show up in your swipeable users list.
Successful status (200): Responds with:
{
message: "You'll never see that guy again."
}
Listed endpoint:
POST /swipe/:swiper_id/:swiped_id/decline
Creates a "decline swipe" which denotes that the active/swiping user (denoted by swiper_id) does not want to be friends with the user being swiped on (denoted by swiped_id).
Successful status (201): Responds with:
{
message: "Decline swipe added."
}
Listed endpoint:
POST /swipe/:swiper_id/:swiped_id/request
Creates a "request swipe" which denotes that the active/swiping user (denoted by swiper_id) wants to be friends with the user being swiped on (denoted by swiped_id).
After the swipe is posted to the database, the API will automatically check if the swiped user has also requested the swiper. If so, the friendship is added to the Friends database and the users will show up in each other's friend lists. Else it will simply add the request swipe.
Successful status (201): Responds with:
{
message: "Request sent! You might be friends already!"
}
Status 400:
Bad Request (Request body is missing required information)
Status 401:
Unauthorized (Usually in reference to something already in use or data that already exists but that the user doesn't have access to)
Status 404:
Not Found (The data requested doesn't exist)
Status 500:
Internal Server Error (Either I messed up or the server is currently down)