Backend API Overview
📌 What is this for? (Quick Summary for New Interns)​
In Simple Words:
When the dashboard in your browser needs to fetch the latest speed or send a Start command, it talks to our cloud server using a REST API.Instead of having 20 different web addresses for different tasks, we use one single endpoint:
POST https://npig3gpgck.execute-api.ap-south-1.amazonaws.com/apiIn the request, we include an action name (like
"FETCH_METRICS"or"SEND_CONTROL"). Our cloud code reads that action and does the work. This page explains how that single entry point works.
1. How a Request Looks​
Every request sent to our API follows this simple JSON format:
{
"action": "<NAME_OF_ACTION>",
"payload": {
"sessionId": "<TAB_ID>",
"...": "Any extra numbers or settings needed for this action"
}
}
And in the HTTP headers, you include your Cognito login token:
Authorization: Bearer <your_login_token>
Content-Type: application/json
2. Request Lifecycle Step-by-Step​
3. List of Available Actions​
| Action Name | Who Can Call It? | What It Does |
|---|---|---|
REGISTER_SESSION | Everyone | Tells the server: "This browser tab is now the active one." |
FETCH_METRICS | Everyone | Fetches the newest speed, battery, and temperature readings. |
FETCH_STATE | Everyone | Fetches whether the battery is currently on or the vehicle is running. |
SEND_CONTROL | Admin / Engineer | Sends physical commands to the vehicle: Enable Battery, Launch, or Emergency Stop. |
LOG_EVENT | Everyone | Saves a permanent record when a test run starts or stops. |
LIST_USERS | Admin only | Lists all registered user accounts. |
GET_USER_GROUPS | Admin only | Checks what permissions a specific user has. |
4. Common Status Codes​
200 OK: Everything worked as expected.400 Bad Request: You forgot a required parameter (like omitting thesessionId).401 Unauthorized: Your login token is expired, or you logged in from another tab.403 Forbidden: You tried to perform an action you don't have permission for (e.g. a Manager trying to launch the vehicle).500 Server Error: An unexpected crash or database connection timeout in the backend code.