Skip to main content

Get Average Analysis

curl -X GET https://api.example.com/analysis/average/workspace123/meter123/ \
  -H "Authorization: Bearer YOUR_TOKEN"
{
  "message": "",
  "result": {
    "id": "analysis123",
    "type": "average",
    "workspace_id": "workspace123",
    "meter_id": "meter123",
    "status": "saved",
    "data": {
      "period": {
        "start_date": "2024-01-01T00:00:00Z",
        "end_date": "2024-01-31T23:59:59Z"
      },
      "result": [
        {
          "sensor": "ph",
          "average": 7.2,
          "min": 6.5,
          "max": 8.0
        }
      ]
    }
  }
}
Retrieve average analysis results for a meter. Endpoint: GET /analysis/average/{work_id}/{meter_id}/ Authentication: Required (Bearer token)

Path Parameters

work_id
string
required
Workspace ID
meter_id
string
required
Meter ID

Create Average Analysis

curl -X POST https://api.example.com/analysis/average/ \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "workspace_id": "workspace123",
    "meter_id": "meter123",
    "sensor_name": "ph",
    "start_date": "2024-01-01",
    "end_date": "2024-01-31",
    "sensor_type": "ph"
  }'
{
  "message": "Análisis generando con el id: analysis456"
}
Create a new average analysis for sensor data. Endpoint: POST /analysis/average/ Authentication: Required (Bearer token)

Request Body

workspace_id
string
required
Workspace ID
meter_id
string
required
Meter ID
sensor_name
string
required
Sensor name for analysis
start_date
string
required
Start date (YYYY-MM-DD format)
end_date
string
required
End date (YYYY-MM-DD format)
sensor_type
string
Specific sensor type to analyze: ph, temperature, conductivity, tds, turbidity (optional, if omitted analyzes all sensors)

Update Average Analysis

curl -X PUT https://api.example.com/analysis/average/analysis123/ \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "workspace_id": "workspace123",
    "meter_id": "meter123",
    "range": {
      "start_date": "2024-01-01T00:00:00Z",
      "end_date": "2024-01-31T23:59:59Z"
    },
    "sensor_type": "ph"
  }'
{
  "message": "Analysis updated successfully",
  "analysis_id": "analysis123"
}
Update an existing average analysis with new parameters. Endpoint: PUT /analysis/average/{id}/ Authentication: Required

Path Parameters

id
string
required
Analysis ID to update

Request Body

workspace_id
string
required
Workspace ID
meter_id
string
required
Meter ID
range
object
required
Date range for the analysis
sensor_type
string
Specific sensor type to analyze (optional)

Get Average Period Analysis

curl -X GET https://api.example.com/analysis/average/period/workspace123/meter123/ \
  -H "Authorization: Bearer YOUR_TOKEN"
{
  "message": "",
  "result": {
    "id": "analysis789",
    "type": "average_period",
    "data": {
      "sensor": "ph",
      "period": {
        "start_date": "2024-01-01T00:00:00Z",
        "end_date": "2024-01-31T23:59:59Z"
      },
      "period_type": "days",
      "averages": [
        {
          "date": "2024-01-01",
          "value": 7.1
        },
        {
          "date": "2024-01-02",
          "value": 7.3
        }
      ]
    }
  }
}
Retrieve average period analysis (averages grouped by time period). Endpoint: GET /analysis/average/period/{work_id}/{meter_id}/ Authentication: Required (Bearer token)

Path Parameters

work_id
string
required
Workspace ID
meter_id
string
required
Meter ID

Create Average Period Analysis

curl -X POST https://api.example.com/analysis/average/period/ \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "workspace_id": "workspace123",
    "meter_id": "meter123",
    "sensor_name": "ph",
    "start_date": "2024-01-01",
    "end_date": "2024-01-31",
    "period_type": "days",
    "sensor_type": "ph"
  }'
{
  "message": "Análisis generando con el id: analysis999"
}
Create average period analysis with time grouping. Endpoint: POST /analysis/average/period/ Authentication: Required (Bearer token)

Request Body

workspace_id
string
required
Workspace ID
meter_id
string
required
Meter ID
sensor_name
string
required
Sensor name
start_date
string
required
Start date (YYYY-MM-DD)
end_date
string
required
End date (YYYY-MM-DD)
period_type
string
default:"days"
Time period grouping: days, months, or years
sensor_type
string
Specific sensor type (optional)

Update Average Period Analysis

curl -X PUT https://api.example.com/analysis/average/period/analysis456/ \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "workspace_id": "workspace123",
    "meter_id": "meter123",
    "sensor_name": "ph",
    "start_date": "2024-01-01",
    "end_date": "2024-01-31",
    "period_type": "days"
  }'
{
  "message": "Period analysis updated successfully",
  "analysis_id": "analysis456"
}
Update an existing average period analysis. Endpoint: PUT /analysis/average/period/{id}/ Authentication: Required

Path Parameters

id
string
required
Analysis ID to update

Request Body

workspace_id
string
required
Workspace ID
meter_id
string
required
Meter ID
sensor_name
string
required
Sensor name to analyze
start_date
string
required
Start date (YYYY-MM-DD format)
end_date
string
required
End date (YYYY-MM-DD format)
period_type
string
required
Period grouping: days, weeks, months

Get Prediction Analysis

curl -X GET https://api.example.com/analysis/prediction/workspace123/meter123/ \
  -H "Authorization: Bearer YOUR_TOKEN"
{
  "message": "",
  "result": {
    "id": "pred123",
    "type": "prediction",
    "data": {
      "sensor": "ph",
      "data": {
        "labels": ["2024-01-01", "2024-01-02"],
        "values": [7.1, 7.2]
      },
      "pred": {
        "labels": ["2024-02-01", "2024-02-02"],
        "values": [7.15, 7.25]
      }
    }
  }
}
Retrieve prediction analysis results. Endpoint: GET /analysis/prediction/{work_id}/{meter_id}/ Authentication: Required (Bearer token)

Path Parameters

work_id
string
required
Workspace ID
meter_id
string
required
Meter ID

Create Prediction Analysis

curl -X POST https://api.example.com/analysis/prediction/ \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "workspace_id": "workspace123",
    "meter_id": "meter123",
    "sensor_name": "ph",
    "start_date": "2024-01-01",
    "end_date": "2024-01-31",
    "period_type": "days",
    "sensor_type": "ph",
    "ahead": 10
  }'
{
  "message": "Análisis generando con el id: pred456"
}
Create future value predictions based on historical data. Endpoint: POST /analysis/prediction/ Authentication: Required (Bearer token)

Request Body

workspace_id
string
required
Workspace ID
meter_id
string
required
Meter ID
sensor_name
string
required
Sensor name
start_date
string
required
Historical data start date (YYYY-MM-DD)
end_date
string
required
Historical data end date (YYYY-MM-DD)
period_type
string
default:"days"
Time period: days, months, or years
sensor_type
string
Specific sensor type (optional)
ahead
number
default:"10"
Number of time periods to predict ahead

Update Prediction Analysis

curl -X PUT https://api.example.com/analysis/prediction/pred123/ \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "workspace_id": "workspace123",
    "meter_id": "meter123",
    "range": {
      "start_date": "2024-01-01T00:00:00Z",
      "end_date": "2024-01-31T23:59:59Z"
    },
    "sensor_type": "ph",
    "ahead": 10
  }'
{
  "message": "Prediction analysis updated successfully",
  "analysis_id": "pred123"
}
Update an existing prediction analysis with new parameters. Endpoint: PUT /analysis/prediction/{id}/ Authentication: Required

Path Parameters

id
string
required
Analysis ID to update

Request Body

workspace_id
string
required
Workspace ID
meter_id
string
required
Meter ID
range
object
required
Date range for training data
sensor_type
string
required
Sensor type to predict
ahead
number
default:"10"
Number of time periods to predict ahead

Get Correlation Analysis

curl -X GET https://api.example.com/analysis/correlation/workspace123/meter123/ \
  -H "Authorization: Bearer YOUR_TOKEN"
{
  "message": "",
  "result": {
    "id": "corr123",
    "type": "correlation",
    "data": {
      "method": "pearson",
      "sensors": ["ph", "temperature", "conductivity"],
      "matrix": [
        [1.0, 0.85, 0.62],
        [0.85, 1.0, 0.71],
        [0.62, 0.71, 1.0]
      ]
    }
  }
}
Retrieve correlation analysis between sensors. Endpoint: GET /analysis/correlation/{work_id}/{meter_id}/ Authentication: Required (Bearer token)

Path Parameters

work_id
string
required
Workspace ID
meter_id
string
required
Meter ID

Create Correlation Analysis

curl -X POST https://api.example.com/analysis/correlation/ \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "workspace_id": "workspace123",
    "meter_id": "meter123",
    "sensor_name": "all",
    "start_date": "2024-01-01",
    "end_date": "2024-01-31",
    "period_type": "days",
    "sensors": ["ph", "temperature", "conductivity"],
    "method": "pearson"
  }'
{
  "message": "Análisis generando con el id: corr789"
}
Create correlation analysis between multiple sensors. Endpoint: POST /analysis/correlation/ Authentication: Required (Bearer token)

Request Body

workspace_id
string
required
Workspace ID
meter_id
string
required
Meter ID
sensor_name
string
required
Sensor identifier
start_date
string
required
Start date (YYYY-MM-DD)
end_date
string
required
End date (YYYY-MM-DD)
period_type
string
default:"days"
Time period: days, months, or years
sensors
array
required
Array of sensor types to correlate: ph, temperature, conductivity, tds, turbidity
method
string
default:"pearson"
Correlation method: pearson, spearman, or kendall

Update Correlation Analysis

curl -X PUT https://api.example.com/analysis/correlation/corr123/ \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "workspace_id": "workspace123",
    "meter_id": "meter123",
    "range": {
      "start_date": "2024-01-01T00:00:00Z",
      "end_date": "2024-01-31T23:59:59Z"
    },
    "method": "spearman"
  }'
{
  "message": "Correlation analysis updated successfully",
  "analysis_id": "corr123"
}
Update an existing correlation analysis with new parameters. Endpoint: PUT /analysis/correlation/{id}/ Authentication: Required

Path Parameters

id
string
required
Analysis ID to update

Request Body

workspace_id
string
required
Workspace ID
meter_id
string
required
Meter ID
range
object
required
Date range for analysis
method
string
default:"pearson"
Correlation method: pearson, spearman, or kendall

Delete Analysis

curl -X DELETE https://api.example.com/analysis/analysis123/ \
  -H "Authorization: Bearer YOUR_TOKEN"
{
  "message": "Análisis eliminado"
}
Delete an analysis. Endpoint: DELETE /analysis/{id}/ Authentication: Required (Bearer token)

Path Parameters

id
string
required
Analysis ID to delete

Create AI Chat Session

curl -X POST https://api.example.com/analysis/ai/analysis123/session \
  -H "Authorization: Bearer YOUR_TOKEN"
{
  "session_id": "analysis123-user123",
  "context": "Tipo de análisis: average\nParámetros del análisis: {...}",
  "created_at": "2024-01-15T10:30:00Z"
}
Create an AI chat session for an analysis to ask questions about the results. Endpoint: POST /analysis/ai/{analysis_id}/session Authentication: Required (Bearer token)

Path Parameters

analysis_id
string
required
Analysis ID to discuss

Response

session_id
string
Chat session identifier
context
string
Analysis context provided to the AI
created_at
string
Session creation timestamp

Chat with AI About Analysis

curl -X POST https://api.example.com/analysis/ai/analysis123/chat \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "message": "What does this pH trend indicate?"
  }'
{
  "response": "Based on the analysis data, the pH levels show a stable trend around 7.2, which indicates neutral to slightly alkaline water. This is within the normal range for most freshwater systems.",
  "session_id": "analysis123"
}
Send a message to the AI assistant about an analysis. Creates a session automatically if one doesn’t exist. Endpoint: POST /analysis/ai/{analysis_id}/chat Authentication: Required (Bearer token)

Path Parameters

analysis_id
string
required
Analysis ID to discuss

Request Body

message
string
required
Question or message to the AI assistant

Response

response
string
AI-generated response
session_id
string
Chat session identifier

Get AI Chat Session History

curl -X GET https://api.example.com/analysis/ai/analysis123/session \
  -H "Authorization: Bearer YOUR_TOKEN"
{
  "session_id": "analysis123-user123",
  "context": "Tipo de análisis: average\nParámetros del análisis: {...}",
  "created_at": "2024-01-15T10:30:00Z",
  "updated_at": "2024-01-15T11:00:00Z",
  "messages": [
    {
      "id": "msg1",
      "role": "user",
      "content": "What does this pH trend indicate?",
      "timestamp": "2024-01-15T10:35:00Z"
    },
    {
      "id": "msg2",
      "role": "assistant",
      "content": "Based on the analysis data...",
      "timestamp": "2024-01-15T10:35:05Z"
    }
  ],
  "metadata": {
    "analysis_id": "analysis123",
    "analysis_type": "average",
    "user_id": "user123"
  }
}
Retrieve the full chat history for an analysis. Endpoint: GET /analysis/ai/{analysis_id}/session Authentication: Required (Bearer token)

Path Parameters

analysis_id
string
required
Analysis ID

Generate PDF Report

curl -X GET https://api.example.com/analysis/analysis123/report/pdf \
  -H "Authorization: Bearer YOUR_TOKEN" \
  --output report.pdf
Generate a comprehensive PDF report for an analysis with charts and tables. Endpoint: GET /analysis/{analysis_id}/report/pdf Authentication: Required (Bearer token)

Path Parameters

analysis_id
string
required
Analysis ID to generate report for

Response

Returns a PDF file download with:
  • Analysis metadata and configuration
  • Visualizations (line charts, bar charts, heatmaps)
  • Data tables
  • Generated timestamp and user information
Content-Type: application/pdf

Build docs developers (and LLMs) love