Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Cloud API

/config

The /config endpoint is a POST request. It takes sensor/device, buoy details, and sensor config as stated in the Subscribe Config detailed by device team in its body. It also needs a firebase signed ID token in its header that authorizes a firebase user to use the HTTP method.

Headers taken:

  • authorizationToken (REQUIRED): Authorization JWT token generated by the front-end client when a user signs in to verify that an authorized user has sent a request to set configurations to a device.

Example Headers: authorizationToken: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c

Request Body taken:

  • version (REQUIRED): Version number of topic that will be sent to.
  • buoy_id (REQUIRED): Buoy id that configuration payload will be sent to.
  • payload (REQUIRED): Configuration payload that will be published to the IoT network that end devices/sensors will be subscribed to.

Example Body:

{
    "version": 0,
    "buoy_id": 1,
    "payload": {
        "ph": {
            "time-interval": 6000,
            "unit": null,
            "average-value": true,
            "average-time-interval": 60,
            "disable": false
        }
    }
}

Output formats:

Valid JWT:

{
    "statusCode": 200,
    "body": "\"Successfully published configuration to devices\"",
    "configuration": {
        "ph": {
            "time-interval": 6000,
            "unit": null,
            "average-value": true,
            "average-time-interval": 60,
            "disable": false
        }
    }
}

Invalid JWT:

{
    "Message": "User is not authorized to access this resource with an explicit deny"
}

Missing requirements:

{
    "statusCode": 400,
    "body": "\"must provide a buoy id in body\""
}

/calibration_points

The /calibration_points is a PUT request that updates a calibration point from a specific buoy.

Headers taken:

  • authorizationToken (REQUIRED): Authorization JWT token generated by the front-end client when a user signs in to verify that an authorized user has sent a request to set configurations to a device.

  • x-api-key (REQUIRED): API key generated by AWS API Gateway to verify that an authorized user has sent a request to set configurations to a device.

Example Headers: authorizationToken: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c

x-api-key: 1234567890

Request Body taken:

  • id (Required): ID of calibration point to Get, Update, or Post.
  • digital_value (Required): Digital value of calibration point to Post or Update.
  • physical_value (Required): Physical value of calibration point to Post or Update.
  • sensor_id (Required): Sensor ID of calibration point to Post or Update.

Example Body:

{
    "id": 1,
    "digital_value": 100,
    "physical_value": 7.0,
    "sensor_id": 1
}

Output formats:

Valid POST:

{
    "statusCode": 200,
    "body": "\"Successfully added calibration point to buoy\""
}

Valid GET:

{
    "statusCode": 200,
    "body": [
        {
            "id": 1,
            "digital_value": 100,
            "physical_value": 7.0,
            "sensor_id": 1
        },
        {
            "id": 2,
            "digital_value": 200,
            "physical_value": 7.5,
            "sensor_id": 1
        }
    ]
}

Invalid JSON:

{
    "statusCode": 400,
    "body": "\"Invalid JSON\""
}

Data Error:

{
    "statusCode": 500,
    "body": "\"Error inserting data\""
}

/calibration_points/{sensor_id}

The /calibration_points/{sensor_id} endpoint is a GET request that returns all calibration points for a specific buoy. It is a POST request that adds a calibration point to a specific buoy.

Headers taken:

  • authorizationToken (REQUIRED): Authorization JWT token generated by the front-end client when a user signs in to verify that an authorized user has sent a request to set configurations to a device.

  • x-api-key (REQUIRED): API key generated by AWS API Gateway to verify that an authorized user has sent a request to set configurations to a device.

Example Headers: authorizationToken: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c

x-api-key: 1234567890

Request Body taken:

  • id (Required): ID of calibration point to Get, Update, or Post.
  • digital_value (Required): Digital value of calibration point to Post or Update.
  • physical_value (Required): Physical value of calibration point to Post or Update.
  • sensor_id (Required): Sensor ID of calibration point to Post or Update.

Example Body:

{
    "id": 1,
    "digital_value": 100,
    "physical_value": 7.0,
    "sensor_id": 1
}

Path Parameters taken:

  • sensor_id (Required): Sensor ID of calibration point to Get or Post.

Example Path Parameters: sensor_id: 1

Output formats:

Valid PUT:

{
    "statusCode": 200,
    "body": "\"Successfully updated calibration point\""
}

Invalid JSON:

{
    "statusCode": 400,
    "body": "\"Invalid JSON\""
}

Data Error:

{
    "statusCode": 500,
    "body": "\"Error inserting data\""
}

/devices

The /devices endpoint is a GET request that returns all devices in the database. It is a POST request that adds a device to the database.

Headers taken:

  • authorizationToken (REQUIRED): Authorization JWT token generated by the front-end client when a user signs in to verify that an authorized user has sent a request to set configurations to a device.

  • x-api-key (REQUIRED): API key generated by AWS API Gateway to verify that an authorized user has sent a request to set configurations to a device.

Example Headers: authorizationToken: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c

x-api-key: 1234567890

Request Body taken:

  • device_id (Required): ID of device to Get, Update, or Post.
  • device_name (Required): Name of device to Post or Update.
  • device_description (Required): Description of device to Post or Update.
  • location_x (Required): X coordinate of device to Post or Update.
  • location_y (Required): Y coordinate of device to Post or Update.
  • time_interval (Required): Time interval of device data transfer to the cloud.
  • active (Required): Whether or not the device is active.

Example Body:

{
    "device_id": 1,
    "device_name": "Buoy 1",
    "device_description": "Buoy 1",
    "location_x": 1.0,
    "location_y": 1.0,
    "time_interval": 60,
    "active": true
}

Output formats:

Valid POST:

{
    "statusCode": 200,
    "body": "\"Successfully inserted a new device\""
}

Valid GET:

{
    "statusCode": 200,
    "body": [
        {
            "device_id": 1,
            "device_name": "Buoy 1",
            "device_description": "Buoy 1",
            "location_x": 1.0,
            "location_y": 1.0,
            "time_interval": 60,
            "active": true
        },
        {
            "device_id": 2,
            "device_name": "Buoy 2",
            "device_description": "Buoy 2",
            "location_x": 2.0,
            "location_y": 2.0,
            "time_interval": 60,
            "active": true
        }
    ]
}

Data Error:

{
    "statusCode": 500,
    "body": "\"Error inserting data\""
}

/devices/{device_id}

The /devices/{device_id} endpoint is a PUT request that updates a specific device in the database.

Headers taken:

  • authorizationToken (REQUIRED): Authorization JWT token generated by the front-end client when a user signs in to verify that an authorized user has sent a request to set configurations to a device.

  • x-api-key (REQUIRED): API key generated by AWS API Gateway to verify that an authorized user has sent a request to set configurations to a device.

Example Headers: authorizationToken: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c

x-api-key: 1234567890

Request Body taken:

  • device_id (Required): ID of device to Get, Update, or Post.
  • device_name (Required): Name of device to Post or Update.
  • device_description (Required): Description of device to Post or Update.
  • location_x (Required): X coordinate of device to Post or Update.
  • location_y (Required): Y coordinate of device to Post or Update.
  • time_interval (Required): Time interval of device data transfer to the cloud.
  • active (Required): Whether or not the device is active.

Example Body:

{
    "device_id": 1,
    "device_name": "Buoy 1",
    "device_description": "Buoy 1",
    "location_x": 1.0,
    "location_y": 1.0,
    "time_interval": 60,
    "active": true
}

Path Parameters taken:

  • device_id (Required): ID of device to PUT.

Example Path Parameters:

device_id: 1

Output formats:

Valid PUT:

{
    "statusCode": 200,
    "body": "\"Successfully updated device\""
}

Data Error:

{
    "statusCode": 500,
    "body": "\"Error updating data\""
}

Not Found:

{
    "statusCode": 404,
    "body": "\"No device found with the given device_id\""
}

/sensors

The /sensors endpoint is a GET request that returns all sensors in the database. It is a POST request that adds a sensor to the database.

Headers taken:

  • authorizationToken (REQUIRED): Authorization JWT token generated by the front-end client when a user signs in to verify that an authorized user has sent a request to set configurations to a device.

  • x-api-key (REQUIRED): API key generated by AWS API Gateway to verify that an authorized user has sent a request to set configurations to a device.

Example Headers: authorizationToken: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c

x-api-key: 1234567890

Request Body taken (POST):

  • sensor_id (Required): ID of sensor to Get, Update, or Post.
  • device_id (Required): ID of the device the sensor is attached to.
  • supplier (Required): Name of the sensor supplier.
  • manufacturer (Required): Name of the sensor manufacturer.
  • model (Required): Name of the sensor model.
  • comm_protocol (Required): Communication protocol of the sensor.
  • calibration_formula (Required): Calibration formula of the sensor.
  • last_calibration_date : Date of the last calibration of the sensor.
  • minimum_required_calibration_points (Required): Minimum number of calibration points required for the sensor.
  • metric_type (Required): Type of metric the sensor measures.
  • default_metric_unit (Required): Default unit of the metric the sensor measures.
  • calibrated (Required): Whether or not the sensor is calibrated.
  • enabled (Required): Whether or not the sensor is enabled.
  • min_val (Required): Minimum value the sensor can measure.
  • max_val (Required): Maximum value the sensor can measure.

Example Body (POST):

{
    "sensor_id": 1,
    "device_id": 1,
    "supplier": "Supplier 1",
    "manufacturer": "Manufacturer 1",
    "model": "Model 1",
    "comm_protocol": "Protocol 1",
    "calibration_formula": "Formula 1",
    "last_calibration_date": "2020-01-01",
    "minimum_required_calibration_points": 1,
    "metric_type": "Type 1",
    "default_metric_unit": "Unit 1",
    "calibrated": true,
    "enabled": true,
    "min_val": 1.0,
    "max_val": 1.0
}

Output formats:

Valid POST:

{
    "statusCode": 200,
    "body": "\"Successfully inserted a new sensor\""
}

Data Error:

{
    "statusCode": 500,
    "body": "\"Error inserting data\""
}

Valid GET:

{
    "statusCode": 200,
    "body": [
        {
            "sensor_id": 1,
            "device_id": 1,
            "supplier": "Supplier 1",
            "manufacturer": "Manufacturer 1",
            "model": "Model 1",
            "comm_protocol": "Protocol 1",
            "calibration_formula": "Formula 1",
            "last_calibration_date": "2020-01-01",
            "minimum_required_calibration_points": 1,
            "metric_type": "Type 1",
            "default_metric_unit": "Unit 1",
            "calibrated": true,
            "enabled": true,
            "min_val": 1.0,
            "max_val": 1.0
        }
    ]
}

Invalid GET:

{
    "statusCode": 500,
    "body": "\"Error fetching data\""
}

/sensors/{sensor_id}

The /sensors/{sensor_id} is a PUT request that updates a sensor with the given sensor_id.

Headers taken:

  • authorizationToken (REQUIRED): Authorization JWT token generated by the front-end client when a user signs in to verify that an authorized user has sent a request to set configurations to a device.

  • x-api-key (REQUIRED): API key generated by AWS API Gateway to verify that an authorized user has sent a request to set configurations to a device.

Example Headers: authorizationToken: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c

x-api-key: 1234567890

Request Body taken:

  • sensor_id (Required): ID of sensor to Get, Update, or Post.
  • device_id (Required): ID of the device the sensor is attached to.
  • supplier (Required): Name of the sensor supplier.
  • manufacturer (Required): Name of the sensor manufacturer.
  • model (Required): Name of the sensor model.
  • comm_protocol (Required): Communication protocol of the sensor.
  • calibration_formula (Required): Calibration formula of the sensor.
  • last_calibration_date : Date of the last calibration of the sensor.
  • minimum_required_calibration_points (Required): Minimum number of calibration points required for the sensor.
  • metric_type (Required): Type of metric the sensor measures.
  • default_metric_unit (Required): Default unit of the metric the sensor measures.
  • calibrated (Required): Whether or not the sensor is calibrated.
  • enabled (Required): Whether or not the sensor is enabled.
  • min_val (Required): Minimum value the sensor can measure.
  • max_val (Required): Maximum value the sensor can measure.

Example Body (PUT):

{
    "sensor_id": 1,
    "device_id": 1,
    "supplier": "Supplier 1",
    "manufacturer": "Manufacturer 1",
    "model": "Model 1",
    "comm_protocol": "Protocol 1",
    "calibration_formula": "Formula 1",
    "last_calibration_date": "2020-01-01",
    "minimum_required_calibration_points": 1,
    "metric_type": "Type 1",
    "default_metric_unit": "Unit 1",
    "calibrated": true,
    "enabled": true,
    "min_val": 1.0,
    "max_val": 1.0
}

Path Parameters taken:

  • sensor_id (Required): ID of sensor to PUT.

Example Path Parameters:

sensor_id: 1

Output formats:

Valid PUT:

{
    "statusCode": 200,
    "body": "\"Successfully updated the sensor\""
}

Sensor Not Found:

{
    "statusCode": 404,
    "body": "\"No sensor found with the given sensor_id\""
}

Data Error:

{
    "statusCode": 500,
    "body": "\"Error updating data\""
}