Skip to content

Latest commit

 

History

History
344 lines (239 loc) · 6.82 KB

API-Documentation.md

File metadata and controls

344 lines (239 loc) · 6.82 KB

API Documentation

This document outlines the API endpoints for the Here app, a location-based AR social app. The API is designed to facilitate the app's core functionalities including authentication message mangement, replies mangement, and user mangemenet.

For access to the API, please reach out to phuc.duong@yale.edu to request the X-API-Key, which is required for authentication and access control.

Our backend services are deployed on Vercel. The data is stored and managed with MongoDB Atlas.

Below you will find detailed descriptions of each endpoint, including the HTTP methods, request URLs, necessary parameters, expected request and examples of use.

Table of Contents

Base URL

  • Base URL: https://here-swe.vercel.app/

Authentication Endpoints

Register

Creates a new user account.

  • Endpoint: POST /auth/register
  • Body:
{
  "userName": "JohnD",
  "firstName": "John",
  "lastName": "Doe",
  "email": "johndoe@yale.edu",
  "password": "secretpassword"
}

Login

Authenticates a user and returns user data if successful.

  • Endpoint: POST /auth/login
  • Body:
{
  "inputLogin": "JohnD",
  "password": "secretpassword"
}

User Endpoints

Search User by Email or Username

Search for a user by their email address or username. Do not need to include both.

  • Endpoint: GET /user/search
  • Body:
{
  "email": "user@yale.edu",
  "userName": "JohnD"
}

Get User by ID

Retrieve a user by their unique identifier.

  • Endpoint: GET /user/:userId

Get User Friends

Retrieve a list of friends for a user.

  • Endpoint: GET /user/:userId/friends

Get User's Messages

Retrieve messages for a user.

  • Endpoint: GET /user/:userId/messages

Add User's Friend by ID

Add a friend to a user's friend list by their user ID. This will also add the user to the friend's friend list.

  • Endpoint: PUT /user/:userId/friends
  • Body:
    {
      "friendId": "friendUserId"
    }
    
    

Add User's Friend by Name

Add a friend to a user's friend list by their username. This endpoint functions similarly to adding by ID, but uses the friend's username instead.

  • Endpoint: PUT /user/:userId/friends_name
  • Body:
    {
      "friendName": "friendUserName"
    }
    

Remove User's Friend by ID

Remove a friend from a user's friend list using the friend's user ID. This also removes the user from the friend's friend list.

  • Endpoint: DELETE /user/:userId/friends
  • Body:
    {
      "friendId": "friendUserId"
    }
    

Remove User's Friend by Name

Remove a friend from a user's friend list using the friend's username. Functions similarly to removing by ID, but targets the friend by their username.

  • Endpoint: DELETE /user/:userId/friends_name
  • Body:
    {
      "friendName": "friendUserName"
    }
    
    

Toggle Notify Friends

Toggle the notification setting for a user's friends.

  • Endpoint: PUT /user/:userId/toggle-notify-friends

Update User's Profile

Update a user's profile information.

  • Endpoint: PUT /user/:userId/update-profile
  • Body:
{
  "userName": "newUserName",
  "password": "newPassword",
  "firstName": "newFirstName",
  "lastName": "newLastName",
  "email": "newEmail@yale.edu",
  "avatar": "urlToAvatar"
}

Delete User

Delete a user and their associated messages.

  • Endpoint: DELETE /user/:userId

Message Endpoints

Get All Messages

Gets all the messages in the database

  • Endpoint: GET /message/get_all_messages

Post Message

Allows a user to post a message.

  • Endpoint: POST /message/post_message
  • Body:
{
  "user_id": "653d51478ff5b3c9ace45c26",
  "text": "Hi, this is a test message - Jane",
  "visibility": "friends",
  "location": {
    "type": "Point",
    "coordinates": [40.7128, -74.0060]
  }
}

Delete Message

Allows a user to delete their message.

  • Endpoint: POST /message/delete_message
  • Body:
{
  "messageId": "653d62a37ce9c61f28dcaa7f"
}

Increment Likes

Increments the number of likes on a message.

  • Endpoint: POST /message/increment_likes
  • Body:
{
  "id": "653d62de7ce9c61f28dcaa87"
}

Change Visibility

Changes the visibility of a user's message.

  • Endpoint: POST /message/change_visibility
  • Body:
{
  "id": "653d62de7ce9c61f28dcaa87",
  "new_visibility": "public"
}

Reply Endpoints

Like Reply

Increments the number of likes on a reply.

  • Endpoint: GET /reply/like_reply
  • Body:
{
  "reply_id": "653d62de7ce9c61f28dcaa87"
}

Add Reply

Add a reply to a message.

  • Endpoint: POST /reply/reply_to_message
  • Body:
{
  "message_id": "653ea4a35b858b2542ea4f13",
  "content": "this is a test reply to a test message"
}

Metrics Endpoints

Create Metrics

Creates a new metrics record.

  • Endpoint: POST /metrics/create-metrics
  • Body:
{
  "toalDistribution": 50
}

Get Metrics by Name

Retrieves a metrics record by its name.

  • Endpoint: POST /metrics/get-metrics
  • Body:
{
  "metricsName": "DailyUserVisits"
}

Increment Clicks

Increments the click count of a specified metrics record by 1.

  • Endpoint: POST /metrics/increment-clicks
  • Body:
{
  "metricsName": "DailyUserVisits"
}

Update Total Distribution

Update total distribution for a metric.

  • Endpoint: POST /metrics/update-total-distribution
  • Body:
{
  "metricsName": "DailyUserVisits",
  "newTotalDistribution": "1000"
}