Skip to content

Latest commit

 

History

History

README.md

Rest API Documentation Chat Viewer

This Documentation was available here for the REST API of Chat Viewer. This Documentation has Two Sections,

User

This API was used to manipulate user details in the chat viewer Application.

To sign up or sign in the user

This API uses the Google sign-in button to get the work done, the token was the token generated by Google Sign In. This API Gives the JWT token for further use of the API

Request

POST {{host}}/api/v1/users/
Body
{
  "token": "xxx"
}

Response

Find the User Details and JWT token in the response

Header

auth-token {{token}}

Body
{
  "userId": 1,
  "name": "Sri Lakshmi Kanthan P",
  "email": "srilakshmikanthan.p@gmail.com",
  "createdAt": "2022-07-23T21:39:46.000Z",
  "updatedAt": "2022-07-23T21:40:34.000Z"
}

To get the user Details

This API was used to get the user details from the Application, None of the user details is public so you must give the JWT token to get the details.

Request

GET {{host}}/api/v1/users/me
Auth
Authorization Bearer <Token>

Response

{
  "userId": 1,
  "name": "Sri Lakshmi Kanthan P",
  "email": "srilakshmikanthan.p@gmail.com",
  "createdAt": "2022-07-23T21:39:46.000Z",
  "updatedAt": "2022-07-23T21:40:34.000Z"
}

To update the User Details

This API was to update the user details currently only updatable field is the Name

Request

PATCH {{host}}/api/v1/users/me
Auth
Authorization Bearer <Token>

Body

{
  "name": "Sri Lakshmi Kanthan P"
}

Response

{
  "userId": 1,
  "name": "Sri Lakshmi Kanthan P",
  "email": "srilakshmikanthan.p@gmail.com",
  "createdAt": "2022-07-23T21:39:46.000Z",
  "updatedAt": "2022-07-23T21:40:34.000Z"
}

To Delete the User Details

This will remove all details of the user, so make correct use of it

Request

DELETE {{host}}/api/v1/users/me
Auth
Authorization Bearer <Token>

Response

{
  "message" : "ok"
}

Chat

This API was used to manipulate the chat details of a user.

Create a New Chat

This API is used to create a new chat for the user.

Request

POST {{host}}/api/v1/chats
Auth
Authorization Bearer <Token>

Body

{
  "base64" :  "Encoded in base64 with mime type",
  "name"   :  "Name of the chat",
}

Response

{
  "blobUrl": "http://localhost:8000/api/v1/chats/2/blob",
  "name": "Chat 1",
  "chatId": 2,
  "userId": 1,
  "createdAt": "2022-07-23T22:16:42.000Z",
  "updatedAt": "2022-07-23T22:16:42.000Z"
}

Get all chats of the User

This API is used to get all chats of the user

Request

GET {{host}}/api/v1/chats
Auth
Authorization Bearer <Token>

Query Parameters

The Query Parameters have been used for paging the results. It returns results with a link header.

  • perPage: Number of chats per page
  • page: Number of Page
  • sortBy: Sort by field either createdAt or updatedAt or name

Response

[
  {
    "blobUrl": "http://localhost:8000/api/v1/chats/2/blob",
    "name": "Chat 1",
    "chatId": 2,
    "userId": 1,
    "createdAt": "2022-07-23T22:16:42.000Z",
    "updatedAt": "2022-07-23T22:16:42.000Z"
  },
  {
    "blobUrl": "http://localhost:8000/api/v1/chats/3/blob",
    "name": "Chat 2",
    "chatId": 3,
    "userId": 1,
    "createdAt": "2022-07-24T07:16:16.000Z",
    "updatedAt": "2022-07-23T22:16:42.000Z"
  }
]

Get the Specific Chat

This API was used to get the Specific chat if the user

Request

GET {{host}}/api/v1/chats/2
Auth
Authorization Bearer <Token>

Response

{
  "blobUrl": "http://localhost:8000/api/v1/chats/2/blob",
  "name": "Chat 1",
  "chatId": 2,
  "userId": 1,
  "createdAt": "2022-07-23T22:16:42.000Z",
  "updatedAt": "2022-07-23T22:16:42.000Z"
}

Update a Chat of the User

This API is used to update the chat of the user, currently, the only updatable field is the Name

Request

PATCH {{host}}/api/v1/chats/2
Auth
Authorization Bearer <Token>

Body

{
  "name": "Chat 1"
}

Response

{
  "blobUrl": "http://localhost:8000/api/v1/chats/2/blob",
  "name": "Chat 1",
  "chatId": 2,
  "userId": 1,
  "createdAt": "2022-07-23T22:16:42.000Z",
  "updatedAt": "2022-07-23T22:16:42.000Z"
}

Delete a Chat of the user

This API is used to delete the chat of the user

Request

DELETE {{host}}/api/v1/chats/3
Auth
Authorization Bearer <Token>

Response

{
  "message" : "ok"
}

Get the BLOB of Chat

This API is used to get the BLOB of the Chat

Request

GET {{host}}/api/v1/chats/2/blob
Auth
Authorization Bearer <Token>

Response

Raw data, identify with the ContentType

Token for a chat of user

This API is used to generate a JWT token for the chat, so it can be shared easily

Request

GET {{host}}/api/v1/chats/2/token
Auth
Authorization Bearer <Token>

Params

  • expiresIn: The valid time for the token (default: 30d)

Response

The header will contain the token

chat-token <Token>

Get the chat with token

You can generate a token for a specific chat with that token, and use this API to get the chat details

Request

GET {{host}}/api/v1/chats/shared/<token>

Response

{
    "blobUrl": "https://url-to-the-blob",
    "name": "Chat 1",
    "chatId": 2,
    "userId": 1,
    "createdAt": "2022-07-23T22:16:42.000Z",
    "updatedAt": "2022-07-23T22:16:42.000Z"
}

Get the Blob with token

You can generate a token for a specific chat with that token, and use this API to get the blob of chat

Request

GET {{host}}/api/v1/chats/shared/<token>/blob

Response

Raw data, identify with the ContentType