-
Notifications
You must be signed in to change notification settings - Fork 0
4. Public API
SciTechMC edited this page Feb 10, 2025
·
4 revisions
- Script Name: ChatCLI
- Description: Command-line chat application for real-time messaging and account management.
-
Base URLs:
https://chat.puam.be/wss://fortbow.duckdns.org:8765/
- Type: Session Token
- Instructions: After logging in, the server returns a session token that must be sent with each request for secure access.
-
URL:
/verify-connection -
Method:
POST,GET - Description: Verifies server connection and checks client version.
-
Payload:
{ "version": "alpha 0.2.0" } -
Query Parameters:
None
-
Success (200 OK):
{ "response": "Hello World!" } -
Error (400 Bad Request):
{ "error": "Invalid request!" } -
Error (405 Method Not Allowed):
{ "error": "Unsupported HTTP method!" }
-
URL:
/register -
Method:
POST - Description: Registers a new user with a username, password, and email. A verification code is sent to the user's email for confirmation.
-
Payload:
{ "username": "exampleuser", "password": "Password123!", "email": "user@example.com" } -
Query Parameters:
None
-
Success (200 OK):
{ "response": "Email sent successfully" }- The user receives an email with a verification code to complete the registration process.
-
Error (400 Bad Request):
{ "error": "Username and password are required" } -
Error (500 Internal Server Error):
{ "error": "Database error: {error message}" }
-
URL:
/login -
Method:
POST - Description: Logs in a user by validating credentials and generating a session token.
-
Payload:
{ "username": "exampleuser", "password": "Password123!" } -
Query Parameters:
None
-
Success (200 OK):
{ "response": "Login Successful!", "session_token": "randomSessionToken" } -
Error (400 Bad Request):
{ "error": "Invalid password" } -
Error (404 Not Found):
{ "error": "Username not found!" }
-
URL:
/reset-password-request -
Method:
POST - Description: Sends a password reset email with a unique reset token.
-
Payload:
{ "data": "user@example.com" } -
Query Parameters:
None
-
Success (200 OK):
{ "response": "Password reset request initiated. Please check your email." } -
Error (404 Not Found):
{ "error": "User not found" }
-
URL:
/reset-password -
Method:
GET,POST - Description: Resets the user's password using the token received in the reset email.
-
Query Parameters:
-
token: The reset token -
username: The username
-
-
Payload:
{ "password": "NewPassword123!", "confirm_password": "NewPassword123!" }
-
Success (200 OK):
{ "message": "Password reset successfully" } -
Error (400 Bad Request):
{ "error": "Passwords do not match" }
-
URL:
/fetch-chats -
Method:
POST - Description: Retrieves a list of users the current user has active chats with.
-
Payload:
{ "username": "exampleuser", "session_token": "sessionToken123" } -
Query Parameters:
None
-
Success (200 OK):
{ "response": ["user1", "user2"] } -
Error (400 Bad Request):
{ "error": "Unable to verify user!" }
-
URL:
/create-chat -
Method:
POST - Description: Creates a new chat between two users.
-
Payload:
{ "username": "exampleuser", "receiver": "anotheruser", "session_token": "sessionToken123" } -
Query Parameters:
None
-
Success (200 OK):
{ "response": "Chat created successfully!" } -
Error (400 Bad Request):
{ "error": "Sender or receiver not found!" }
-
URL:
/receive-message -
Method:
POST - Description: Stores a message sent from one user to another.
-
Payload:
{ "username": "exampleuser", "receiver": "anotheruser", "session_token": "sessionToken123", "message": "Hello, how are you?" } -
Query Parameters:
None
-
Success (200 OK):
{ "response": "Message sent successfully!" } -
Error (400 Bad Request):
{ "error": "No chat found between users!" }
-
URL:
/subscribe -
Method:
POST - Description: Subscribes the user to receive notifications about future releases.
- Form submission with
emailas the input field.
-
Success (200 OK):
{ "response": "You have successfully subscribed!" } -
Error (400 Bad Request):
{ "error": "Email is required" }
- 400: Bad request (e.g., missing fields)
- 401: Unauthorized (e.g., invalid session token)
- 404: Not found (e.g., username or chat not found)
- 500: Internal server error (unexpected failure)