Skip to content

API Documentation

EggiEl edited this page Mar 26, 2024 · 5 revisions

Endpoint: /storedData

This endpoint delivers a list of all known sensors stored in the MongoDB database.

Purpose

This function is primarily intended for use when initializing the user interface component at the start of an experiment. Additionally, it can be utilized for refreshing the UI or handling errors that necessitate a restart of the frontend.

Usage

GET /storedData

Response

The response is a JSON array containing information about all known sensors.

Example Request via Postman or other Tools

GET https://localhost:8000/storedData

Example Response

[
    [
     
        {
            "_id": "65e6515983c7b2f105ca749b",
            "temperature": 200,
            "time": "200",
            "__v": 0
        },
       
        {
            "_id": "65e6515d55ac1d9d8eef16d1",
            "temperature": 20,
            "time": "20",
        },
        {
            "_id": "65e6515f55ac1d9d8eef16d2",
            "temperature": 20,
            "time": "20",
        },
        {
            "_id": "65e6516155ac1d9d8eef16d3",
            "temperature": 20,
            "time": "20",        },
   
        {
            "_id": "65e6516a83c7b2f105ca74a3",
            "temperature": 200,
            "time": "200",
            "__v": 0
        },
        {
            "_id": "65e6521283c7b2f105ca74ab",
            "temperature": 200,
            "time": "200",
            "__v": 0
        },
        
    ],
    [
 {
            "_id": "65e6515b55ac1d9d8eef16d0",
            "temperature": 20,
            "time": "20",
        },
],
    [
{
            "_id": "65f2d8b23ddfb319a3e56c76",
            "temperature": 200,
            "time": "200",
            "__v": 0
        }
],
    [],
    [],
    []
]

Usage in UI

When mounting the UI component at the start of the experiment or when handling UI refreshes or errors that require a frontend restart, utilize this endpoint to fetch the necessary sensor data.

Image Reference

Sensor Image

Endpoint: /storedData_latest/:sensorname/:id

GET /storedData_latest/:sensorname/:id

Response

The response is a JSON array containing information about the sensor data newer than the specified header ID.

Example Request via Postman or other Tools

GET https://localhost:8000/storedData_latest/Sensor1/6602a19c2d76cc5bcd9ede51

Example Response

[
    {
        "_id": "sensor_id_placeholder",
        "temperature": temperature_value,
        "time": "time_value",
        "__v": 0
    },
    {
        "_id": "sensor_id_placeholder",
        "temperature": temperature_value,
        "time": "time_value",
        "__v": 0
    },
    {
        "_id": "sensor_id_placeholder",
        "temperature": temperature_value,
        "time": "time_value",
        "__v": 0
    }
]

Usage in UI

This endpoint should be utilized to retrieve sensor data newer than the specified header ID in the UI component for real-time updates or data synchronization purposes.

image

Clone this wiki locally