Timestream

Base route: /api/ts

đź“š Read more about Timestream data in the Back-end Server Architecture AWS Timestream documentation.

Table of contents

  1. /getAllBuoyIds
    1. Response Schema
    2. Sample Success Response
    3. Fail Response
  2. /getCurrentBuoyData
    1. Response Schema
    2. Sample Success Response
    3. Fail Response
  3. /getBuoyHistory
    1. Response Schema
    2. Sample Success Response
    3. Fail Response
  4. /getBuoyThreshold
    1. Request Schema
    2. Sample Request
    3. Response Schema
    4. Sample Success Response
    5. Fail Response

đź’ˇ To set up the testing environment using Postman, refer to the Setting up testing section of the back-end documentation.

/getAllBuoyIds

Description Get all device ids that exist on the table.
HTTP Verb GET
Success Codes 200
Failure Codes 404, 500
Request Schema N/A
Sample Request N/A

Response Schema

{ 
    "data": 
    [{
        "“buoy_id”": string,
    }]
}

Sample Success Response

{ 
    "data": 
    [
        {"buoy_id":"0"},
        {"buoy_id":"1"},
        {"buoy_id":"100"}
    ]
}

Fail Response

{ 
    "error": 
    { 
        "message": "queryString is null or empty" 
    }
}

/getCurrentBuoyData

Description Get all data from specified list of buoy ids (query string).
HTTP Verb GET
Success Codes 200
Failure Codes 404, 500
Request Schema buoyIdList: string
Sample Request buoyIdList: 1,2,3,4,5,12

Response Schema

{
    data: [
        {
             “buoy_id”: string,
             "measure_name": string,
             "time": from_iso8601_timestamp,
             "measure_value::double": double,
             "measure_value::boolean": boolean,
             "measure_value::varchar": boolean,
        },
    ]
}

Sample Success Response

{
    data: [
        {
             “buoy_id”: 1,
             "measure_name": "do",
             "time": "2023-02-18 01:38:08.480000000",
             "measure_value::double": "80.3",
             "measure_value::boolean": null,
             "measure_value::varchar": null,
        },
    ]
}

If no match with query parameters:

{
    data: [ ]
}

Fail Response

If the query is empty:

{
    "error": 
    { 
        "message": "queryString is null or empty" 
    }
}

/getBuoyHistory

Description Get historical data from buoys
HTTP Verb GET
Success Codes 200
Failure Codes 404, 500
Request Schema { “userId”: string, “deviceId”: number }
Sample Request { buoyIdList:1,12,8, measureName:ph, start:2021-03-30T03:42:32.000Z, end:2022-03-30T03:42:32.000Z }

Response Schema

{
    "data": [
        {
            "buoy_id": string,
            "measure_name": string,
            "time": from_iso8601_timestamp,
            "measure_value::double": typeof measure_value,
            "measure_value::boolean": boolean,
            "measure_value::varchar": boolean
        }
    ]
}

Sample Success Response

{
    "data": [
        {
            "buoy_id": "1",
            "measure_name": "ph",
            "time": "2022-03-25 04:45:06.865000000",
            "measure_value::double": "7.03",
            "measure_value::boolean": null,
            "measure_value::varchar": null
        },
        {
            "buoy_id": "12",
            "measure_name": "ph",
            "time": "2022-03-25 04:45:40.124000000",
            "measure_value::double": "7.03",
            "measure_value::boolean": null,
            "measure_value::varchar": null
        },
        {
            "buoy_id": "8",
            "measure_name": "ph",
            "time": "2022-03-25 04:45:44.780000000",
            "measure_value::double": "7.03",
            "measure_value::boolean": null,
            "measure_value::varchar": null
        }
    ]
}

Fail Response

If the query is empty:

{
    "error":
    {
        "message":"queryString is null or empty"
    }
}

/getBuoyThreshold

Description Get information on whether any of the specified devices have metrics that have passed a threshold.
HTTP Verb GET
Success Codes 200
Failure Codes 404, 500

Request Schema

{
    buoyIdList:  string
    measureName:  string
    start: from_iso8601_timestamp
    end:  from_iso8601_timestamp
    measureValueType:  typeof measure_value
    threshold:  Number 
}

Note: in typescript a comparator and number combined is of type Number

Sample Request

{
    buoyIdList:  1,8   
    measureName:  ph
    start:  2021-03-30T03:42:32.000Z
    end:  2022-03-30T03:42:32.000Z
    measureValueType:  measure_value::double
    threshold:  >5 
}

Response Schema

{
    "data": [
        {
            "buoy_id": string,
            "measure_name": string,
            "time": string,
            "measure_value::double": double,
            "measure_value::boolean": boolean,
            "measure_value::varchar": boolean
        }
    ]
}

Sample Success Response

{
    "data": [
        {
            "buoy_id": "1",
            "measure_name": "ph",
            "time": "2022-03-25 04:45:06.865000000",
            "measure_value::double": "7.03",
            "measure_value::boolean": null,
            "measure_value::varchar": null
        },
        {
            "buoy_id": "8",
            "measure_name": "ph",
            "time": "2022-03-25 04:45:44.780000000",
            "measure_value::double": "7.03",
            "measure_value::boolean": null,
            "measure_value::varchar": null
        }
    ]
}

If no match with query parameters:

{
    data: [ ]
}

Fail Response

If the query is empty:

{
    "error":
    {
        "message": "queryString is null or empty"
    }
}