Skip to main content

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/api

In 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 NameWho Can Call It?What It Does
REGISTER_SESSIONEveryoneTells the server: "This browser tab is now the active one."
FETCH_METRICSEveryoneFetches the newest speed, battery, and temperature readings.
FETCH_STATEEveryoneFetches whether the battery is currently on or the vehicle is running.
SEND_CONTROLAdmin / EngineerSends physical commands to the vehicle: Enable Battery, Launch, or Emergency Stop.
LOG_EVENTEveryoneSaves a permanent record when a test run starts or stops.
LIST_USERSAdmin onlyLists all registered user accounts.
GET_USER_GROUPSAdmin onlyChecks 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 the sessionId).
  • 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.