API Documentation

GET /db

This is the backend service which populates the database with Users, Threads, Posts and the relations among them.

Status Codes:
POST /login

Logs the user in by providing access and refresh tokens upon successful credentials check.

Form Parameters:
  • username – registered username

  • password – registered password associated to username

Status Codes:
POST /register

Register a new user after some sanity checks. The user is still required to perform a POST to the /login endpoint to login.

Form Parameters:
  • username – username not already present

  • password – password associated to new username

  • age – new user’s age

  • email – new user’s email

Status Codes:
DELETE /logout

Logs the user out by storing the user’s token in the redis db which holds all revoked tokens.

Status Codes:
POST /refresh

Access tokens expires after 1h, in order to get a new one without logging in again the user can make a POST to this endpoint using the refresh token which instead expires after 24h.

Status Codes:
  • 200 OK – extended logged in session

GET /whoami

Simple page to test the effectiveness of login/logout operations.

Status Codes:
GET /threads

This is the Threads Dashboard where the logged user can go through followed threads or recommended ones. The backend service captures a new Thread data and registers it.

Status Codes:
POST /threads

This endpoint captures a new Thread data and registers it.

Form Parameters:
  • title – thread title

  • text – thread text

  • creation date – thread date

Status Codes:
GET /threads/(thread_id)

This is a specific Thread page in which information about it are reported as well as the related comments.

Parameters:
  • thread_id (str) – thread’s unique id

Status Codes:
GET /threads/(thread_id)/followers

This endpoints returns all users following a thread.

Parameters:
  • thread_id (str) – thread’s unique id

Status Codes:
POST /threads/(thread_id)/followers

This endpoints adds the logged user to the list of the threads’ followers.

Parameters:
  • thread_id (str) – thread’s unique id

Status Codes:
DELETE /threads/(thread_id)/followers

This endpoints removes the logged user from the list of the threads’ followers.

Parameters:
  • thread_id (str) – thread’s unique id

Status Codes:
GET /posts/(post_id)

This is a specific Post page in which information about it are reported as well as the related replies.

Parameters:
  • post_id (str) – post’s unique id

Status Codes:
POST /threads/(thread_id)/posts

This endpoint captures a new Post data and registers it.

Form Parameters:
  • text – post text

  • date – post date

Status Codes:
  • 200 OK – post created

  • 400 Bad Request – when text or date parameters are missing, when text is an empty string or when the thread is not found

POST /posts/(post_id)/replies

This endpoint captures a new Reply data to a specific Post and registers it.

Form Parameters:
  • text – post text

  • date – post date

Status Codes:
  • 200 OK – post created

  • 400 Bad Request – when text or date parameters are missing, when text is an empty string or when parent post id not found

PUT /posts/(post_id)

This endpoint captures a update Post data and saves it.

Form Parameters:
  • text – post text

Status Codes:

This is the Search endpoint where the user can search for other users or threads. The backend service captures the query and returns the matched users and threads.

Status Codes:
GET /user

Retrieve the logged-in user’s information.

Status Codes:
GET /user/(username)

Retrieve user information by username.

Parameters:
  • username (str) – The username to be searched.

Status Codes:
POST /user/block/(username)

Block a user by username.

Parameters:
  • username (str) – The username to be blocked.

Status Codes:
POST /user/unblock/(username)

Unblock a user by username.

Parameters:
  • username (str) – The username of the user to be unblocked.

Status Codes:
GET /user/(username)/is_blocked

Check if the logged-in user has blocked the given username.

Parameters:
  • username (str) – The username to be checked.

Status Codes:
GET /user/(username)/is_me

Check if the logged-in user is the given username.

Parameters:
  • username (str) – The username to be checked.

Status Codes: