Skip to main content

Data & Monitoring

POST /seriesDataInflux

Retrieve time-series data from InfluxDB for chart visualization.
query
array
required
Array of query objects defining the data to retrieve
query[].measurement
string
InfluxDB measurement name
query[].field
string
Field to query from the measurement
query[].samplingPeriod
string
Sampling interval (e.g., “5m”, “1h”, ”30s”)
import { request } from './utils/js/request';
import { backend } from './utils/routes/app.routes';

const query = [
  {
    measurement: 'water_flow',
    field: 'flow_rate',
    samplingPeriod: '5m'
  }
];

const { data } = await request(
  `${backend['Mas Agua']}/seriesDataInflux`,
  'POST',
  query
);
data
object
Object with variable IDs as keys and arrays of time/value pairs as values
Response
{
  "data": {
    "var_123": [
      { "time": "01/03/26, 10:00:00 a. m.", "value": 1.65 },
      { "time": "01/03/26, 10:05:00 a. m.", "value": 1.72 },
      { "time": "01/03/26, 10:10:00 a. m.", "value": 1.58 }
    ]
  }
}
Refer to src/modules/dashBoard/factories/chartQueryBuilderMap.js:66-70.

POST /dataInflux

Retrieve a single data point from InfluxDB for real-time values.
varsInflux
object
required
Variable configuration object from InfluxDB
varsInflux.calc_field
string
Calculated field name to retrieve
const { data } = await request(
  `${backend['Mas Agua']}/dataInflux`,
  'POST',
  {
    calc_field: 'chlorine_level',
    measurement: 'water_quality'
  }
);
data
object
Object containing the current value for the requested field
Response
{
  "data": {
    "chlorine_level": {
      "value": 0.65
    }
  }
}
See src/modules/dashBoard/factories/chartQueryBuilderMap.js:149-152.

POST /multipleDataInflux

Retrieve multiple real-time data points in a single request.
influxVarsToRequest
array
required
Array of data objects with variable configurations
influxVarsToRequest[].dataInflux
object
Variable metadata including ID, name, unit, and varsInflux configuration
const influxVarsToRequest = [
  {
    dataInflux: {
      id: 'var_1',
      name: 'flow_rate',
      unit: 'm3/h',
      varsInflux: {
        measurement: 'water_flow',
        field: 'flow'
      }
    }
  },
  {
    dataInflux: {
      id: 'var_2',
      name: 'pressure',
      unit: 'bar',
      varsInflux: {
        measurement: 'water_pressure',
        field: 'pressure'
      }
    }
  }
];

const response = await request(
  `${backend['Mas Agua']}/multipleDataInflux`,
  'POST',
  influxVarsToRequest
);
const values = response.data;
data
object
Object with variable IDs as keys and current values
Response
{
  "data": {
    "var_1": 1.65,
    "var_2": 3.2
  }
}
Refer to src/modules/DrawDiagram/utils/js/drawActions.js:175-179.

Diagram Management

GET /getObjectCanva

Retrieve diagram canvas objects including lines, images, texts, and polylines.
id
integer
required
Diagram ID to retrieve
const objectDiagram = await request(
  `${backend['Mas Agua']}/getObjectCanva?id=${diagramId}`,
  'GET'
).then((res) => res?.data?.[0]);
data
array
Array containing the diagram object
data[0].id
integer
Diagram ID
data[0].title
string
Diagram title
data[0].backgroundColor
string
Background color (hex code)
data[0].backgroundImg
string
Background image URL
data[0].lines
array
Array of line objects
data[0].polylines
array
Array of polyline objects
data[0].texts
array
Array of text objects
data[0].images
array
Array of image objects with associated variables
Response
{
  "data": [
    {
      "id": 5,
      "title": "Water Treatment Plant",
      "backgroundColor": "#ffffff",
      "backgroundImg": "https://example.com/bg.png",
      "lines": [
        {
          "id": 1,
          "points": {
            "start": { "left": 100, "top": 200 },
            "end": { "left": 300, "top": 200 }
          },
          "stroke": "#0000ff",
          "strokeWidth": 2,
          "variable": {
            "name": "flow_rate",
            "unit": "m3/h",
            "varsInflux": {...}
          }
        }
      ],
      "images": [...],
      "texts": [...],
      "polylines": [...]
    }
  ]
}
See src/modules/DrawDiagram/utils/js/drawActions.js:14-17.

POST /saveDiagram

Save or update a diagram with all canvas objects.
diagram
object
required
Diagram metadata
diagram.id
integer
Diagram ID (omit for new diagrams)
diagram.title
string
required
Diagram title
diagram.backgroundColor
string
Background color
diagram.backgroundImg
string
Background image URL
lines
array
Array of line objects to save
polylines
array
Array of polyline objects to save
texts
array
Array of text objects to save
images
array
Array of image objects to save
deleted
object
Object containing arrays of deleted object IDs
const saveObjects = {
  diagram: {
    id: 5,
    title: 'Water Treatment Plant',
    status: 1,
    backgroundColor: '#ffffff',
    backgroundImg: ''
  },
  lines: [
    {
      id: 1,
      id_influxvars: 'var_123',
      points: {
        start: { left: 100, top: 200 },
        end: { left: 300, top: 200 }
      },
      stroke: '#0000ff',
      strokeWidth: 2,
      animation: 1,
      invertAnimation: false,
      status: 1
    }
  ],
  images: [],
  texts: [],
  polylines: [],
  deleted: {
    lines: [],
    images: [3, 5],
    texts: [],
    polylines: []
  }
};

await request(
  `${backend['Mas Agua']}/saveDiagram`,
  'POST',
  saveObjects
);
success
boolean
Indicates if the save operation was successful
Refer to src/modules/DrawDiagram/utils/js/drawActions.js:364.

Configuration & Variables

GET /getVarsInflux

Retrieve all InfluxDB variables available for the current schema.
import { request } from './utils/js/request';
import { backend } from './utils/routes/app.routes';

const list = await request(
  `${backend['Mas Agua']}/getVarsInflux`,
  'GET'
);

if (list?.data) {
  const variables = list.data;
  // Use variables...
}
data
array
Array of variable objects with InfluxDB configuration
Response
{
  "data": [
    {
      "id": "var_123",
      "name": "flow_rate",
      "unit": "m3/h",
      "type": "number",
      "varsInflux": {
        "measurement": "water_flow",
        "field": "flow",
        "calc_field": "flow_rate"
      }
    },
    {
      "id": "var_124",
      "name": "pressure",
      "unit": "bar",
      "type": "number",
      "varsInflux": {...}
    }
  ]
}
See src/modules/DrawDiagram/components/Fields/actions.js:5-8.

GET /getConfigNotify

Retrieve notification configuration for MQTT devices.
const config = await request(
  `${backend['Mas Agua']}/getConfigNotify`,
  'GET'
);

const configData = config.data;
data
object
Nested object organized by device, brand, and version
Response
{
  "data": {
    "Reconectador": {
      "NOJA": {
        "v1": [
          {
            "id": 1,
            "id_event_influx": 100,
            "alarm": true
          }
        ]
      }
    }
  }
}
Refer to src/modules/ConfigNotifications/utils/js/index.js:5.

POST /sendConfigMQTT

Send configuration to MQTT devices.
topic
string
required
MQTT topic to publish to
data
object
required
Configuration data to send
const topic = 'coop/energia/Reconectadores/NOJA/0310123456789/action';
const data = {
  source_0: [100, 101, 102]
};

await request(
  `${backend['Mas Agua']}/sendConfigMQTT`,
  'POST',
  { topic, data }
);
success
boolean
Indicates if the MQTT message was sent successfully
See src/modules/ConfigNotifications/utils/js/index.js:68-71.

GET /getAllMenu

Retrieve all menu items for the application.
const menusResponse = await request(
  `${backend['Mas Agua']}/getAllMenu`,
  'GET'
);

const menus = menusResponse?.data || [];
data
array
Array of menu item objects
Response
{
  "data": [
    {
      "id": 1,
      "name": "Dashboard",
      "icon": "dashboard",
      "path": "/dashboard",
      "status": true
    },
    {
      "id": 2,
      "name": "Diagrams",
      "icon": "diagram",
      "path": "/diagrams",
      "status": true
    }
  ]
}
Refer to src/modules/NavBarCustom/utils/js/index.js:33.

GET /getPermission

Retrieve user or profile permissions for menu items.
id
string
required
User ID or profile ID
type
string
required
Permission type: “id_user” or “id_profile”
profile
string
Profile ID (when querying by user)
const usuario = storage.get('usuario');

const permissiondata = await request(
  `${backend['Mas Agua']}/getPermission?id=${usuario.sub}&type=id_user&profile=${usuario.profile}`,
  'GET'
);

const permissions = permissiondata?.data || [];
data
array
Array of permission objects
Response
{
  "data": [
    {
      "id": 28,
      "id_menu": 1,
      "id_profile": 4,
      "id_user": null,
      "status": true
    },
    {
      "id": 112,
      "id_menu": 25,
      "id_profile": null,
      "id_user": 6,
      "status": false
    }
  ]
}
See src/modules/NavBarCustom/utils/js/index.js:18-22.

Error Responses

All endpoints may return the following error responses:

401 Unauthorized

{
  "error": {
    "message": "Invalid or expired token",
    "code": "UNAUTHORIZED"
  }
}

500 Internal Server Error

Server errors return detailed error messages extracted from the response:
{
  "error1": { "message": "Database connection failed" },
  "error2": { "message": "Invalid query parameters" }
}
The client utility concatenates these into a single error message:
// Extracted error: "Database connection failed Invalid query parameters"

Rate Limits

No explicit rate limits are currently enforced, but clients should implement reasonable throttling to avoid server overload.

Next Steps

Authentication

Learn about JWT token authentication

Components

Explore chart components that use these endpoints