- Error Handling
- User Management
- 3.1 Authentication
- 3.1.1 register User
- 3.1.2 login user
- 3.1.3 Get Logged in User Profile
- 3.1.4 Logout User
- 3.1 Authentication
- User Interraction
- Authors
- Conclusion
Welcome to the API documentation for our user and event management system. This API documentation provides detailed information about the endpoints. It includes information on how to use each endpoint, expected input data, success responses, and HTTP status codes.
temporarily hosted for live testing on https://spitfire-interractions.onrender.com ....
The API handles errors gracefully and returns JSON responses with appropriate status codes and error messages. Here are some common error responses:
- Status Code: 400
- Response:
{
"error": "Bad Request",
"message": "Invalid input data."
}
- Status Code: 400
- Response:
{
"error": "Bad Request",
"message": [
{
"error": "ensure this value has at least 2 characters",
"field": "name"
},
{
"error": "Passwords do not match",
"field": "confirm_password"
}
]
}
- Status Code: 402
- Response:
{
"error": "Subscription Required",
"message": "You do not have enough credits"
}
- Status Code: 405
- Response:
{
"error": "Method Not Allowed",
"message": "The HTTP method used is not allowed for this endpoint."
}
- Status Code: 413
- Response:
{
"error": "Payload Too Long",
"message": "The request body is too long"
}
- Status Code: 422
- Response:
{
"error": "Unprocessable Entity",
"message": "The server cannot process the request due to invalid data."
}
- Status Code: 429
- Response:
{
"error": "Too Many Requests",
"message": "Rate limit exceeded. Please try again later."
}
- Status Code: 500
- Response:
{
"error": "Internal Server Error",
"message": "It's not you, it's us. We encountered an internal server error."
}
-
Session based Authentication is used
-
A Session Cookie is sent in response headers and is to be stored on client after athenticating
-
subsequent requests should come with the cookie in the request headers
-
session cookies expire after 30 days
-
Endpoint: POST /api/auth/register
-
Description: Register new user account.
-
Request Body:
- Input: JSON with the following.
{ "name": "name", "email":"[email protected]", "password": "password", "confirm_password": "password" }
-
Success Response:
- Status Code: 201 (CREATED)
- Response:
{ "message": "User Created Succesfully", "data": { "name": "name", "email": "[email protected]", "id": "1" }, }
-
Endpoint: POST /api/auth/login
-
Description: login user account.
-
Request Body:
- Input: JSON with the following.
{ "email":"[email protected]", "password": "password", }
-
Success Response:
- Status Code: 200 (OK)
- Response:
{ "message": "success", "data": { "name": "name", "email": "[email protected]", "id": "1" }, }
- Endpoint: GET /api/auth/@me
- Description: Get user details of the currently logged in user
- Success Response:
- Status Code: 200 (OK)
- Response:
{ "message": "success", "data":{ "id": "user_id", "name": "user display name", "email": "user email", } }
- Endpoint: GET/POST
/api/auth/logout
- Description: log out user session
- Success Response:
- Status Code: 200 (OK)
- Response:
{ "message": "success", }
The API receives user Requests(both the chat history stored on the mobile and the current user input) and acts as a bridge to gracefully transfer the requests to GPT-3.5-turbo mode and the AI response is converted to JSON by the API, which is then sent to the user with appropriate status codes. The current user prompt and the AI response is then stored in the chat history on the mobile device.
-
Endpoint: /api/chat/completions
-
Description Generates a chat completion using the GPT-3.5-turbo model from OpenAI.
-
Request Body:
- Input: JSON with the following.
{ "history": [ "user: Hello!", "AI: Hi! How can I help you today?", "user: I'm looking for information on the latest trends in artificial intelligence.", "AI: Sure, here are some of the latest trends in artificial intelligence" ], "user_input": "what is today's date" }
- Input: JSON with the following.
-
Success Response: - Status Code: 201 (Created)
-
Response:
{ "message": "Today's date is October 2, 2023." }
-
Endpoint: /api/chat/
-
Description Generates a chat completion using the GPT-3.5-turbo model from OpenAI.
-
Request Body:
- Input: JSON with the following.
{ "user_input": "what is today's date" }
- Input: JSON with the following.
-
Success Response: - Status Code: 201 (Created)
-
Response:
{ "message": "Today's date is October 2, 2023." }