9 Energy endpoints
b24idalu edited this page 2026-05-28 08:44:51 +00:00

Energy endpoints

GET /energy/health

Path to endpoint

GET /energy/health

Required values

None

Return values

Returns a JSON array:

  • "OK"

When no error occurs

  • Returns an okay
  • Status: 200 OK

When error occurs

  • If service is not running will not return anything

GET /energy/all/{esensorid}

Path to endpoint

GET /energy/all/{esensorid}

Required values

  • esensorid: sensor id

Return values

Returns a JSON array:

  • esensorid: sensor name
  • timestamp: time of reading
  • kilowatt: energy usage

When no error occurs

  • Returns all energy sensor data
  • Status: 200 OK

When error occurs

  • Server failure or database issue
  • Status: 500

GET /energy/total

Path to endpoint

GET /energy/total

Required values

None

Return values

Returns a JSON array:

  • esensorid: sensor name
  • timestamp: time of reading
  • kilowatt: monthly energy (all sensors)

When no error occurs

  • Returns monthly energy data for all sensors
  • Status: 200 OK

When error occurs

  • No data available
  • Status: 404 Not Found

GET /energy/total/{esensorid}

Path to endpoint

GET /energy/total/{esensorid}

Required values

  • esensorid: sensor id

Return values

Returns a JSON array:

  • esensorid: sensor name
  • timestamp: time of reading
  • kilowatt: total energy

When no error occurs

  • Returns total energy data for one sensor
  • Status: 200 OK

When error occurs

  • No data found for sensor or sensor not found
  • Status: 404 Not Found

GET /energy/total/{esensorid}/{year}/{month}

Path to endpoint

GET /energy/total/{esensorid}/{year}/{month}

Required values

  • esensorid: sensor id
  • year: year
  • month: month

Return values

Returns a JSON array:

  • esensorid: sensor name
  • timestamp: time of reading
  • kilowatt: total monthly energy (all sensors)

When no error occurs

  • Returns monthly energy data for all sensors
  • Status: 200 OK

When error occurs

  • No data found for sensors during this month
  • Status: 404 Not Found

GET /energy/total/{year}/{month}

Path to endpoint

GET /energy/total/{year}/{month}

Required values

  • year: year
  • month: month

Return values

Returns a JSON array:

  • esensorid: empty string
  • timestamp: time of reading
  • kilowatt: total energy monthly

When no error occurs

  • Returns total monthly energy data for all sensors
  • Status: 200 OK

When error occurs

  • No data found for sensors during this month
  • Status: 404 Not Found

GET /energy/latest/{esensorid}

Path to endpoint

GET /energy/latest/{esensorid}

Required values

  • esensorid: sensor id

Return values

Returns a JSON array:

  • esensorid: empty string
  • timestamp: time of reading
  • kilowatt: latest energy data for a sensor

When no error occurs

  • Returns latest energy data for one sensor
  • Status: 200 OK

When error occurs

  • No latest energy data or invalid esensorid
  • Status: 404 Not Found

GET /energy/sensors

Path to endpoint

GET /energy/sensors

Required values

None

Return values

Returns a JSON array:

  • esensorid: for all sensors

When no error occurs

  • Returns all sensors
  • Status: 200 OK

When error occurs

  • No sensors exist or database error
  • Status: 404 Not Found