-
Notifications
You must be signed in to change notification settings - Fork 0
API.md
Table of Contents
- Rovers
/api/rovers - Paths
/api/paths - Images
/api/images - Detections
/api/detections - Logs
/api/rovers/[id]/logs
GET /api/rovers
Retrieve a list of all rovers.
-
200 OK: Returns an object with aroversDataarray.-
Example Response Body:
{ "roversData": [ { "id": 1, "name": "Rover 1", "ipAddress": "192.168.1.10" }, { "id": 2, "name": "Rover 2", "ipAddress": "192.168.1.11" } ] }
-
-
500 Internal Server Error: An error occurred on the server.
Example using curl:
curl -X GET http://localhost:5173/api/roversPOST /api/rovers
Create a new rover.
-
name(string, required): The name of the rover. -
ipAddress(string, required): The IP address of the rover.
-
201 Created: Rover successfully created. Returns the created rover object.-
Example Response Body:
{ "rover": { "id": 3, "name": "Test Rover", "ipAddress": "192.168.1.100" } }
-
-
400 Bad Request: Missing required fields. -
500 Internal Server Error: An error occurred on the server.
Example using curl:
curl -X POST http://localhost:5173/api/rovers \
-H "Content-Type: application/json" \
-d '{"name": "Test Rover", "ipAddress": "192.168.1.100"}'GET /api/rovers/[id]
Retrieve a specific rover by its ID.
-
200 OK: Returns the rover object.-
Example Response Body:
{ "id": 1, "name": "Rover 1", "ipAddress": "192.168.1.10" }
-
-
400 Bad Request: Invalid ID format. -
404 Not Found: Rover not found. -
500 Internal Server Error: An error occurred on the server.
Example using curl:
curl -X GET http://localhost:5173/api/rovers/1DELETE /api/rovers/[id]
Delete a specific rover by its ID.
-
200 OK: Rover successfully deleted. Returns a success message.-
Example Response Body:
{ "message": "Rover deleted successfully" }
-
-
400 Bad Request: Invalid ID format. -
404 Not Found: Rover not found. -
500 Internal Server Error: An error occurred on the server.
Example using curl:
curl -X DELETE http://localhost:5173/api/rovers/1Paths are special because they use the unsupported data type which is LineString. This means that you will need to use raw SQL queries to interact with this table. Luckily, the endpoints take care of this for you as they will be parsed in the GeoJSON format.
GET /api/paths
Retrieve a list of all paths.
-
200 OK: Returns an array of path objects.-
Example Response Body:
[ { "id": 2, "rover_id": 2, "timestamp": "2025-09-14 17:51:45.658099+00", "route": { "type": "LineString", "coordinates": [ [ -73.55, 45.49 ], [ -73.54, 45.48 ] ] } }, { "id": 1, "rover_id": 1, "timestamp": "2025-09-14 17:51:45.658099+00", "route": { "type": "LineString", "coordinates": [ [ -73.57, 45.5 ], [ -73.58, 45.51 ] ] } } ]
-
-
500 Internal Server Error: An error occurred on the server.
Example using curl:
curl -X GET http://localhost:5173/api/pathsPOST /api/paths
Create a new path. Will return the created path object.
-
rover_id(integer, required): The ID of the rover associated with the path. -
route(GeoJSON LineString, required): The route of the path in GeoJSON LineString format.
-
201 Created: Path successfully created. Returns the created path object.-
Example Response Body:
{ "id": 3, "rover_id": 1, "timestamp": "2023-10-01T12:34:56.789Z", "route": { "type": "LineString", "coordinates": [ [-73.57, 45.5], [-73.58, 45.51] ] } }
-
-
400 Bad Request: Missing required fields or invalid data. -
500 Internal Server Error: An error occurred on the server.
Example using curl:
curl -X POST http://localhost:5173/api/paths \
-H "Content-Type: application/json" \
-d '{
"rover_id": 1,
"route": {
"type": "LineString",
"coordinates": [
[-73.57, 45.5],
[-73.58, 45.51]
]
}
}'GET /api/paths/[id]
Retrieve a specific path by its ID.
-
200 OK: Returns the path object.-
Example Response Body:
{ "id": 1, "rover_id": 1, "timestamp": "2023-10-01T12:34:56.789Z", "route": { "type": "LineString", "coordinates": [ [-73.57, 45.5], [-73.58, 45.51] ] } }
-
-
400 Bad Request: Invalid ID format. -
404 Not Found: Path not found. -
500 Internal Server Error: An error occurred on the server.
Example using curl:
curl -X GET http://localhost:5173/api/paths/1DELETE /api/paths/[id]
Delete a specific path by its ID.
-
204 No Content: Path successfully deleted. -
400 Bad Request: Invalid ID format. -
404 Not Found: Path not found. -
500 Internal Server Error: An error occurred on the server.
Example using curl:
curl -X DELETE http://localhost:5173/api/paths/1GET /api/images
Retrieve a list of all uploaded images.
-
200 OK: Returns an array of image objects.-
Example Response Body:
[ { "id": 1, "filePath": "/uploads/image1.jpg", "uploadedAt": "2023-10-01T12:34:56.789Z" }, { "id": 2, "filePath": "/uploads/image2.jpg", "uploadedAt": "2023-10-02T12:34:56.789Z" } ]
-
-
500 Internal Server Error: An error occurred on the server.
Example using curl:
curl -X GET http://localhost:5173/api/imagesPOST /api/images
Create a new image with upload. Image currently saved at /uploads directory. Will return the ID of the created image.
-
image(file, required): The image file to upload.
-
201 Created: Image successfully created. Returns the ID of the created image.-
Example Response Body:
{ "image_id": 1 }
-
-
400 Bad Request: Missing required fields. -
500 Internal Server Error: An error occurred on the server.
Example using curl:
curl -X POST http://localhost:5173/api/images \
-F "image=@/home/syeadz/Downloads/cat.jpeg"- There is currently an issue with cross-site form submissions. It has been turned off for now, but would be required for production.
- The path ID is figured out from the rover which is currently on a path.
- The location is figured out from the rover's current GPS coordinates.
GET /api/images/[id]
Retrieve a specific image by its ID.
-
200 OK: Returns the image object.-
Example Response Body:
{ "id": 1, "filePath": "/uploads/image1.jpg", "uploadedAt": "2023-10-01T12:34:56.789Z" }
-
-
400 Bad Request: Invalid ID format. -
404 Not Found: Image not found. -
500 Internal Server Error: An error occurred on the server.
Example using curl:
curl -X GET http://localhost:5173/api/images/1DELETE /api/images/[id]
Delete a specific image by its ID.
-
204 No Content: Image successfully deleted. -
400 Bad Request: Invalid ID format. -
404 Not Found: Image not found. -
500 Internal Server Error: An error occurred on the server.
Example using curl:
curl -X DELETE http://localhost:5173/api/images/1GET /api/detections
Retrieve a list of all detections.
-
200 OK: Returns an array of detection objects.-
Example Response Body:
[ { "id": 1, "imageId": 1, "bbox": "(100,150,200,250)", "confidence": 0.92, "areaScore": 85, "depthScore": 90, "falsePositive": false }, { "id": 2, "imageId": 1, "bbox": "(50,75,150,175)", "confidence": 0.85, "areaScore": 80, "depthScore": 85, "falsePositive": true } ]
-
-
500 Internal Server Error: An error occurred on the server.
Example using curl:
curl -X GET http://localhost:5173/api/detectionsPOST /api/detections
Create a new detection associated with an image. Will return the ID of the created detection.
-
image_id(integer, required): The ID of the image to associate with the detection. -
bbox(array, required): The bounding box for the detection in the format [x_min, y_min, x_max, y_max]. -
confidence(float, required): The confidence score for the detection. -
area_score(integer, optional): The area score for the detection. -
depth_score(integer, optional): The depth score for the detection. -
false_positive(boolean, optional): Whether the detection is a false positive.
-
201 Created: Detection successfully created. Returns the ID of the created detection.-
Example Response Body:
{ "detection_id": 1 }
-
-
400 Bad Request: Missing required fields or invalid data. -
500 Internal Server Error: An error occurred on the server.
Example using curl:
curl -X POST http://localhost:5173/api/detections \
-H "Content-Type: application/json" \
-d '{
"image_id": 1,
"confidence": 0.92,
"bbox": [100, 150, 200, 250]
}'- Ensure that the
image_idprovided exists in the database. - The
bboxshould be an array of four numbers representing the coordinates of the bounding box. - The
confidenceshould be a float value between 0 and 1. - Optional fields can be omitted if not applicable.
GET /api/detections/[id]
Retrieve a specific detection by its ID.
-
200 OK: Returns the detection object.-
Example Response Body:
{ "id": 1, "imageId": 1, "bbox": "(100,150,200,250)", "confidence": 0.92, "areaScore": 85, "depthScore": 90, "falsePositive": false }
-
PATCH /api/detections/[id]
Update the area score and/or depth score for a specific detection.
-
areaScore(integer, optional): The updated area score for the detection. -
depthScore(integer, optional): The updated depth score for the detection.
-
200 OK: Detection scores successfully updated.-
Example Response Body:
{ "id": 1, "imageId": 1, "bbox": "(100,150,200,250)", "confidence": 0.92, "areaScore": 85, "depthScore": 90, "falsePositive": false, }
-
-
400 Bad Request: Missing required fields or invalid data. -
404 Not Found: Detection not found. -
500 Internal Server Error: An error occurred on the server.
Example using curl:
curl -X PATCH http://localhost:5173/api/detections/1 \
-H "Content-Type: application/json" \
-d '{
"areaScore": 85,
"depthScore": 90,
"falsePositive": 1
}'- Ensure that the detection ID provided in the URL exists in the database.
- The
areaScoreanddepthScoreshould be integer values between 0 and 100. -
falsePositiveshould be an integer value of either 0 (false) or 1 (true). - You can update as many valid fields as you want in a single request.
- It's not possible to update other fields (like
imageId,confidence, orbbox) using this endpoint.
DELETE /api/detections/[id]
Delete a specific detection by its ID.
-
200 OK: Detection successfully deleted. Returns a success message.-
Example Response Body:
{ "message": "Detection deleted successfully" }
-
-
400 Bad Request: Invalid ID format. -
404 Not Found: Detection not found. -
500 Internal Server Error: An error occurred on the server.
Example using curl:
curl -X DELETE http://localhost:5173/api/detections/1POST /api/rovers/[id]/logs
Create a new log entry for a specific rover.
-
latitude(float, required): The latitude of the rover. -
longitude(float, required): The longitude of the rover. -
altitude(float, required): The altitude of the rover. -
roll(float, required): The roll of the rover. -
pitch(float, required): The pitch of the rover. -
yaw(float, required): The yaw of the rover. -
temperature(float, required): The temperature of the rover. -
voltage(float, required): The voltage of the rover.
-
201 Created: Log entry successfully created. Returns the created log object.-
Example Response Body:
{ "id": 1, "rover_id": 1, "timestamp": "2023-10-01T12:34:56.789Z", "latitude": 45.5017, "longitude": -73.5673, "altitude": 10.5, "roll": 0.0, "pitch": 0.0, "yaw": 90.0, "temperature": 22.5, "voltage": 12.6 }
-
-
400 Bad Request: Missing required fields or invalid data. -
500 Internal Server Error: An error occurred on the server.
Example using curl:
curl -X POST http://localhost:5173/api/rovers/1/logs \
-H "Content-Type: application/json" \
-d '{
"latitude": 45.5017,
"longitude": -73.5673,
"altitude": 10.5,
"roll": 0.0,
"pitch": 0.0,
"yaw": 90.0,
"temperature": 22.5,
"voltage": 12.6
}'