M74 Labs API Documentation

OpenAPI spec →

Introduction

This documentation aims to provide all the information you need to work with our API.

Authenticating requests

To authenticate requests, include an Authorization header with the value "Bearer {YOUR_AUTH_TOKEN}".

All authenticated endpoints are marked with a requires authentication badge in the documentation below.

You can retrieve your token by logging in.

Auth

Login

POST
https://amarnathm74labs.com
/api/auth/login

Authenticate a user and issue a Sanctum access token.

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
curl --request POST \
    "https://amarnathm74labs.com/api/auth/login" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"email\": \"[email protected]\",
    \"password\": \"secret\",
    \"device_name\": \"iPhone 15\"
}"
Example response:

Logout

POST
https://amarnathm74labs.com
/api/auth/logout
requires authentication

Revoke the access token used for this request.

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json
Example request:
curl --request POST \
    "https://amarnathm74labs.com/api/auth/logout" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
Example response:
{
    "message": "Logged out."
}

Brokers

List brokers

GET
https://amarnathm74labs.com
/api/brokers
requires authentication

Retrieve all MQTT brokers configured by the authenticated user.

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json
Example request:
curl --request GET \
    --get "https://amarnathm74labs.com/api/brokers" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
Example response:
[
    {
        "id": 1,
        "name": "Primary broker",
        "api_endpoint": "https://mqtt.example.com/api",
        "app_id": "app-id",
        "created_at": "2024-01-01T00:00:00Z",
        "updated_at": "2024-01-01T00:00:00Z"
    }
]

Create broker

POST
https://amarnathm74labs.com
/api/brokers
requires authentication

Register a new EMQX broker for the authenticated user.

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
curl --request POST \
    "https://amarnathm74labs.com/api/brokers" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"name\": \"Primary broker\",
    \"api_endpoint\": \"https:\\/\\/mqtt.example.com\\/api\",
    \"app_id\": \"app-id\",
    \"app_secret\": \"app-secret\"
}"
Example response:
{
    "id": 1,
    "name": "Primary broker",
    "api_endpoint": "https://mqtt.example.com/api",
    "app_id": "app-id",
    "created_at": "2024-01-01T00:00:00Z",
    "updated_at": "2024-01-01T00:00:00Z"
}

View broker

GET
https://amarnathm74labs.com
/api/brokers/{id}
requires authentication

Retrieve configuration for a single EMQX broker.

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

id
integer
required

The ID of the broker.

Example:
1
broker
integer
required

ID of the broker.

Example:
16
Example request:
curl --request GET \
    --get "https://amarnathm74labs.com/api/brokers/1" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
Example response:
{
    "id": 1,
    "name": "Primary broker",
    "api_endpoint": "https://mqtt.example.com/api",
    "app_id": "app-id",
    "created_at": "2024-01-01T00:00:00Z",
    "updated_at": "2024-01-01T00:00:00Z"
}

Update broker

PUT
PATCH
https://amarnathm74labs.com
/api/brokers/{id}
requires authentication

Modify the configuration for an EMQX broker.

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

id
integer
required

The ID of the broker.

Example:
1
broker
integer
required

ID of the broker.

Example:
16

Body Parameters

Example request:
curl --request PUT \
    "https://amarnathm74labs.com/api/brokers/1" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"name\": \"Primary broker\",
    \"api_endpoint\": \"https:\\/\\/mqtt.example.com\\/api\",
    \"app_id\": \"app-id\",
    \"app_secret\": \"app-secret\"
}"
Example response:
{
    "id": 1,
    "name": "Primary broker",
    "api_endpoint": "https://mqtt.example.com/api",
    "app_id": "app-id",
    "created_at": "2024-01-01T00:00:00Z",
    "updated_at": "2024-01-01T00:00:00Z"
}

Delete broker

DELETE
https://amarnathm74labs.com
/api/brokers/{id}
requires authentication

Remove an EMQX broker and unlink its devices.

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

id
integer
required

The ID of the broker.

Example:
1
broker
integer
required

ID of the broker.

Example:
16
Example request:
curl --request DELETE \
    "https://amarnathm74labs.com/api/brokers/1" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
Example response:
{
    "message": "Broker deleted."
}

Calibrations

List calibrations

GET
https://amarnathm74labs.com
/api/devices/{device_id}/calibrations
requires authentication

Retrieve paginated calibration history for a device.

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

device_id
integer
required

The ID of the device.

Example:
1
device
integer
required

ID of the device.

Example:
16

Query Parameters

page
integer

Page number for pagination.

Example:
1
Example request:
curl --request GET \
    --get "https://amarnathm74labs.com/api/devices/1/calibrations?page=1" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
Example response:
{
    "current_page": 1,
    "data": [
        {
            "id": 1,
            "device_id": 1,
            "calibrated_at": "2024-01-01T12:00:00Z",
            "mode": "normal",
            "status": "complete",
            "ai_gain": "1.000123",
            "av_gain": "0.999876",
            "error_message": null,
            "created_at": "2024-01-01T12:00:00Z",
            "updated_at": "2024-01-01T12:00:00Z"
        }
    ],
    "total": 1
}

Capabilities

List capabilities

GET
https://amarnathm74labs.com
/api/capabilities
requires authentication

Retrieve all available device capabilities.

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json
Example request:
curl --request GET \
    --get "https://amarnathm74labs.com/api/capabilities" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
Example response:
[
    {
        "value": "relay",
        "label": "Relay"
    },
    {
        "value": "energy_meter",
        "label": "Energy Meter"
    }
]

Cycle Readings

List cycle readings

GET
https://amarnathm74labs.com
/api/devices/{device_id}/cycles
requires authentication

Retrieve paginated cycle/waveform readings for a device.

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

device_id
integer
required

The ID of the device.

Example:
1
device
integer
required

ID of the device.

Example:
16

Query Parameters

page
integer

Page number for pagination.

Example:
1
Example request:
curl --request GET \
    --get "https://amarnathm74labs.com/api/devices/1/cycles?page=1" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
Example response:
{
    "current_page": 1,
    "data": [
        {
            "id": 1,
            "device_id": 1,
            "recorded_at": "2024-01-01T12:00:00Z",
            "frequency": "50.000",
            "samples_per_cycle": 80,
            "av_calibration_coeff": 1.342445739e-5,
            "ai_calibration_coeff": 4.190951586e-7,
            "samples": [
                [
                    -16664835,
                    73840
                ],
                [
                    -18470656,
                    71248
                ]
            ],
            "created_at": "2024-01-01T12:00:00Z",
            "updated_at": "2024-01-01T12:00:00Z"
        }
    ],
    "total": 1
}

Latest cycle reading

GET
https://amarnathm74labs.com
/api/devices/{device_id}/cycles/latest
requires authentication

Retrieve the most recent cycle/waveform reading for a device.

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

device_id
integer
required

The ID of the device.

Example:
1
device
integer
required

ID of the device.

Example:
16
Example request:
curl --request GET \
    --get "https://amarnathm74labs.com/api/devices/1/cycles/latest" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
Example response:
{
    "id": 1,
    "device_id": 1,
    "recorded_at": "2024-01-01T12:00:00Z",
    "frequency": "50.000",
    "samples_per_cycle": 80,
    "av_calibration_coeff": 1.342445739e-5,
    "ai_calibration_coeff": 4.190951586e-7,
    "samples": [
        [
            -16664835,
            73840
        ],
        [
            -18470656,
            71248
        ]
    ],
    "created_at": "2024-01-01T12:00:00Z",
    "updated_at": "2024-01-01T12:00:00Z"
}
{
    "message": "No cycle readings found."
}

Available waveform captures

GET
https://amarnathm74labs.com
/api/devices/{device_id}/cycles/available
requires authentication

List available waveform captures with metadata (no sample data) for date/time browsing.

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

device_id
integer
required

The ID of the device.

Example:
1
device
integer
required

ID of the device.

Example:
16

Query Parameters

from
string

Filter from this datetime (ISO 8601).

Example:
2024-01-01T00:00:00Z
to
string

Filter to this datetime (ISO 8601).

Example:
2024-01-31T23:59:59Z

Body Parameters

Example request:
curl --request GET \
    --get "https://amarnathm74labs.com/api/devices/1/cycles/available?from=2024-01-01T00%3A00%3A00Z&to=2024-01-31T23%3A59%3A59Z" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"from\": \"2026-05-08T17:58:52\",
    \"to\": \"2026-05-08T17:58:52\"
}"
Example response:
{
    "data": [
        {
            "id": 1,
            "recorded_at": "2024-01-01T12:00:00Z",
            "frequency": "50.000",
            "samples_per_cycle": 80
        }
    ]
}

Waveform detail with analysis

GET
https://amarnathm74labs.com
/api/devices/{device_id}/cycles/{cycle_id}
requires authentication

Retrieve a specific waveform capture with computed analysis metrics.

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

device_id
integer
required

The ID of the device.

Example:
1
cycle_id
integer
required

The ID of the cycle.

Example:
1
device
integer
required

ID of the device.

Example:
16
cycle
integer
required

ID of the cycle reading.

Example:
16
Example request:
curl --request GET \
    --get "https://amarnathm74labs.com/api/devices/1/cycles/1" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
Example response:
{
    "id": 1,
    "recorded_at": "2024-01-01T12:00:00Z",
    "frequency": "50.000",
    "samples_per_cycle": 80,
    "waveform": {
        "voltage": [
            230.5,
            228.1
        ],
        "current": [
            5.12,
            4.98
        ],
        "power_instantaneous": [
            1180.16,
            1135.9
        ],
        "time_ms": [
            0,
            0.25
        ]
    },
    "analysis": {
        "voltage_rms": 230.5,
        "current_rms": 5.12,
        "voltage_peak": 325.8,
        "current_peak": 7.24,
        "voltage_crest_factor": 1.414,
        "current_crest_factor": 1.414,
        "power_real": 1150,
        "power_apparent": 1180,
        "power_factor": 0.975,
        "phase_angle_deg": 12.5
    }
}
{
    "message": "Cycle reading not found."
}

Dashboard

Dashboard metrics

GET
https://amarnathm74labs.com
/api/dashboard/metrics
requires authentication

Retrieve device metrics for the authenticated user.

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json
Example request:
curl --request GET \
    --get "https://amarnathm74labs.com/api/dashboard/metrics" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
Example response:
{
    "devices_total": 3,
    "devices_online": 1,
    "recent_telemetry": [
        {
            "id": 42,
            "device_id": 7,
            "received_at": "2024-01-01T12:00:00Z",
            "created_at": "2024-01-01T12:00:00Z",
            "updated_at": "2024-01-01T12:00:00Z",
            "event": "message.delivered",
            "event_id": "evt-123",
            "event_timestamp": "2024-01-01T12:00:05Z",
            "device": {
                "id": 7,
                "name": "Living room sensor",
                "username": "mqtt-user",
                "client_id": "sensor-1"
            }
        }
    ]
}

Device Commands

Control relay

POST
https://amarnathm74labs.com
/api/devices/{device_id}/relay
requires authentication

Send an on/off relay command to the device.

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

device_id
integer
required

The ID of the device.

Example:
1
device
integer
required

ID of the device.

Example:
16

Body Parameters

Example request:
curl --request POST \
    "https://amarnathm74labs.com/api/devices/1/relay" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"state\": \"on\"
}"
Example response:
{
    "status": "sent",
    "command": "relay",
    "state": "on"
}

Trigger calibration

POST
https://amarnathm74labs.com
/api/devices/{device_id}/calibrate
requires authentication

Start, stop, or check status of single-channel mSure calibration.

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

device_id
integer
required

The ID of the device.

Example:
1
device
integer
required

ID of the device.

Example:
16

Body Parameters

Example request:
curl --request POST \
    "https://amarnathm74labs.com/api/devices/1/calibrate" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"op\": \"start\",
    \"channel\": \"AI\",
    \"mode\": \"normal\"
}"
Example response:
{
    "status": "sent",
    "command": "calibrate",
    "op": "start",
    "channel": "AI",
    "mode": "normal"
}

Run auto-calibration

POST
https://amarnathm74labs.com
/api/devices/{device_id}/autocal
requires authentication

Start full AI + AV mSure calibration sequence (~45 seconds).

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

device_id
integer
required

The ID of the device.

Example:
1
device
integer
required

ID of the device.

Example:
16
Example request:
curl --request POST \
    "https://amarnathm74labs.com/api/devices/1/autocal" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
Example response:
{
    "status": "sent",
    "command": "autocal"
}

Set operating mode

POST
https://amarnathm74labs.com
/api/devices/{device_id}/mode
requires authentication

Switch the device between normal, debug, and monitoring operating modes. Monitoring mode sends readings on every energy ready interrupt (~10s) and auto-returns to normal after 10 minutes.

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

device_id
integer
required

The ID of the device.

Example:
1
device
integer
required

ID of the device.

Example:
16

Body Parameters

Example request:
curl --request POST \
    "https://amarnathm74labs.com/api/devices/1/mode" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"mode\": \"normal\"
}"
Example response:
{
    "status": "sent",
    "command": "mode",
    "mode": "normal"
}

Update device config

POST
https://amarnathm74labs.com
/api/devices/{device_id}/config
requires authentication

Set the reading interval for energy measurements.

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

device_id
integer
required

The ID of the device.

Example:
1
device
integer
required

ID of the device.

Example:
16

Body Parameters

Example request:
curl --request POST \
    "https://amarnathm74labs.com/api/devices/1/config" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"interval_ms\": 5000
}"
Example response:
{
    "status": "sent",
    "command": "config",
    "interval_ms": 5000
}

Read/write ADE register

POST
https://amarnathm74labs.com
/api/devices/{device_id}/register
requires authentication

Perform a direct register read or write on the ADE9153A.

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

device_id
integer
required

The ID of the device.

Example:
1
device
integer
required

ID of the device.

Example:
16

Body Parameters

Example request:
curl --request POST \
    "https://amarnathm74labs.com/api/devices/1/register" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"action\": \"read\",
    \"address\": \"0x0000\",
    \"value\": 42
}"
Example response:
{
    "status": "sent",
    "command": "register",
    "action": "read",
    "address": "0x0000"
}

Get diagnostics

POST
https://amarnathm74labs.com
/api/devices/{device_id}/diag
requires authentication

Request full system diagnostics from the device.

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

device_id
integer
required

The ID of the device.

Example:
1
device
integer
required

ID of the device.

Example:
16
Example request:
curl --request POST \
    "https://amarnathm74labs.com/api/devices/1/diag" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
Example response:
{
    "status": "sent",
    "command": "diag"
}

ADE hardware reset

POST
https://amarnathm74labs.com
/api/devices/{device_id}/ade-hw-reset
requires authentication

Perform hardware reset of the ADE chip (pulls RESET pin).

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

device_id
integer
required

The ID of the device.

Example:
1
device
integer
required

ID of the device.

Example:
16
Example request:
curl --request POST \
    "https://amarnathm74labs.com/api/devices/1/ade-hw-reset" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
Example response:
{
    "status": "sent",
    "command": "ade_hw_reset"
}

ADE software reset

POST
https://amarnathm74labs.com
/api/devices/{device_id}/ade-reset
requires authentication

Deinitialize and re-initialize the full energy meter stack.

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

device_id
integer
required

The ID of the device.

Example:
1
device
integer
required

ID of the device.

Example:
16
Example request:
curl --request POST \
    "https://amarnathm74labs.com/api/devices/1/ade-reset" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
Example response:
{
    "status": "sent",
    "command": "ade_reset"
}

Configure overcurrent threshold

POST
https://amarnathm74labs.com
/api/devices/{device_id}/oc-config
requires authentication

Set the overcurrent trip threshold in milliamps.

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

device_id
integer
required

The ID of the device.

Example:
1
device
integer
required

ID of the device.

Example:
16

Body Parameters

Example request:
curl --request POST \
    "https://amarnathm74labs.com/api/devices/1/oc-config" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"threshold_ma\": 12000
}"
Example response:
{
    "status": "sent",
    "command": "oc_config",
    "threshold_ma": 12000
}

Reset overcurrent trip

POST
https://amarnathm74labs.com
/api/devices/{device_id}/oc-reset
requires authentication

Clear the overcurrent trip flag so relay can be turned ON again.

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

device_id
integer
required

The ID of the device.

Example:
1
device
integer
required

ID of the device.

Example:
16
Example request:
curl --request POST \
    "https://amarnathm74labs.com/api/devices/1/oc-reset" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
Example response:
{
    "status": "sent",
    "command": "oc_reset"
}

Reset ESP32

POST
https://amarnathm74labs.com
/api/devices/{device_id}/esp-reset
requires authentication

Reboot the ESP32 device.

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

device_id
integer
required

The ID of the device.

Example:
1
device
integer
required

ID of the device.

Example:
16
Example request:
curl --request POST \
    "https://amarnathm74labs.com/api/devices/1/esp-reset" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
Example response:
{
    "status": "sent",
    "command": "esp_reset"
}

Configure no-load threshold

POST
https://amarnathm74labs.com
/api/devices/{device_id}/noload-config
requires authentication

Set the no-load power threshold in watts.

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

device_id
integer
required

The ID of the device.

Example:
1
device
integer
required

ID of the device.

Example:
16

Body Parameters

Example request:
curl --request POST \
    "https://amarnathm74labs.com/api/devices/1/noload-config" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"threshold_w\": 0.001
}"
Example response:
{
    "status": "sent",
    "command": "noload_config",
    "threshold_w": 0.001
}

Request waveform

POST
https://amarnathm74labs.com
/api/devices/{device_id}/waveform
requires authentication

Request a cycle/waveform capture from the device. Response arrives as type:cycle within 10-15 seconds.

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

device_id
integer
required

The ID of the device.

Example:
1
device
integer
required

ID of the device.

Example:
16
Example request:
curl --request POST \
    "https://amarnathm74labs.com/api/devices/1/waveform" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
Example response:
{
    "status": "sent",
    "command": "waveform"
}

Device Telemetry

List telemetry

GET
https://amarnathm74labs.com
/api/devices/{device_id}/telemetry
requires authentication

Retrieve paginated telemetry records for a device.

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

device_id
integer
required

The ID of the device.

Example:
1
device
integer
required

ID of the device.

Example:
16

Query Parameters

page
integer

Page number for pagination.

Example:
1
Example request:
curl --request GET \
    --get "https://amarnathm74labs.com/api/devices/1/telemetry?page=1" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
Example response:
{
    "current_page": 1,
    "data": [
        {
            "id": 10,
            "device_id": 1,
            "payload": "{\"cmd\":\"ade_mode\",\"status\":\"error\",\"error\":\"ESP_ERR_INVALID_STATE\"}",
            "received_at": "2024-01-01T12:00:00Z",
            "event": "message.publish",
            "event_id": "evt-123",
            "event_timestamp": "2024-01-01T12:00:01Z",
            "created_at": "2024-01-01T12:00:01Z",
            "updated_at": "2024-01-01T12:00:01Z"
        }
    ],
    "total": 1
}

Devices

List devices

GET
https://amarnathm74labs.com
/api/devices
requires authentication

Retrieve all devices owned by the authenticated user.

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json
Example request:
curl --request GET \
    --get "https://amarnathm74labs.com/api/devices" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
Example response:
[
    {
        "id": 1,
        "name": "Living room sensor",
        "broker_id": 1,
        "username": "mqtt-user",
        "client_id": "sensor-1",
        "notes": "Measures temperature",
        "last_received_at": "2024-01-01T12:00:00Z",
        "status": "connected",
        "status_at": "2024-01-01T12:05:00Z",
        "telemetry": [],
        "created_at": "2024-01-01T00:00:00Z",
        "updated_at": "2024-01-01T00:00:00Z"
    }
]

Create device

POST
https://amarnathm74labs.com
/api/devices
requires authentication

Register a new device for the authenticated user.

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
curl --request POST \
    "https://amarnathm74labs.com/api/devices" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"name\": \"Living room sensor\",
    \"broker_id\": 1,
    \"username\": \"mqtt-user\",
    \"client_id\": \"sensor-1\",
    \"notes\": \"architecto\",
    \"capabilities\": [
        \"relay\",
        \"energy_meter\"
    ]
}"
Example response:
{
    "id": 1,
    "name": "Living room sensor",
    "username": "mqtt-user",
    "client_id": "sensor-1",
    "notes": "Measures temperature",
    "last_received_at": null,
    "status": null,
    "status_at": null,
    "capabilities": [
        {
            "capability": "relay",
            "props": null
        }
    ],
    "created_at": "2024-01-01T00:00:00Z",
    "updated_at": "2024-01-01T00:00:00Z"
}

View device

GET
https://amarnathm74labs.com
/api/devices/{id}
requires authentication

Retrieve details for a single device.

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

id
integer
required

The ID of the device.

Example:
1
device
integer
required

ID of the device.

Example:
16
Example request:
curl --request GET \
    --get "https://amarnathm74labs.com/api/devices/1" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
Example response:
{
    "id": 1,
    "name": "Living room sensor",
    "broker_id": 1,
    "username": "mqtt-user",
    "client_id": "sensor-1",
    "notes": "Measures temperature",
    "last_received_at": "2024-01-01T12:00:00Z",
    "status": "connected",
    "status_at": "2024-01-01T12:05:00Z",
    "telemetry": [],
    "created_at": "2024-01-01T00:00:00Z",
    "updated_at": "2024-01-01T00:00:00Z"
}

Update device

PUT
PATCH
https://amarnathm74labs.com
/api/devices/{id}
requires authentication

Modify an existing device.

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

id
integer
required

The ID of the device.

Example:
1
device
integer
required

ID of the device.

Example:
16

Body Parameters

Example request:
curl --request PUT \
    "https://amarnathm74labs.com/api/devices/1" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"name\": \"Living room sensor\",
    \"broker_id\": 1,
    \"username\": \"mqtt-user\",
    \"client_id\": \"sensor-1\",
    \"notes\": \"architecto\",
    \"capabilities\": [
        \"relay\",
        \"energy_meter\"
    ]
}"
Example response:
{
    "id": 1,
    "name": "Living room sensor",
    "username": "mqtt-user",
    "client_id": "sensor-1",
    "notes": "Measures temperature",
    "last_received_at": "2024-01-02T00:00:00Z",
    "status": "disconnected",
    "status_at": "2024-01-02T00:05:00Z",
    "capabilities": [
        {
            "capability": "relay",
            "props": null
        }
    ],
    "created_at": "2024-01-01T00:00:00Z",
    "updated_at": "2024-01-02T00:00:00Z"
}

Delete device

DELETE
https://amarnathm74labs.com
/api/devices/{id}
requires authentication

Remove a device and its credentials.

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

id
integer
required

The ID of the device.

Example:
1
device
integer
required

ID of the device.

Example:
16
Example request:
curl --request DELETE \
    "https://amarnathm74labs.com/api/devices/1" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
Example response:
{
    "message": "Device deleted."
}

Publish to device

POST
https://amarnathm74labs.com
/api/devices/{device_id}/publish
requires authentication

Send a message to the device topic.

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

device_id
integer
required

The ID of the device.

Example:
1
device
integer
required

ID of the device.

Example:
16

Body Parameters

Example request:
curl --request POST \
    "https://amarnathm74labs.com/api/devices/1/publish" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"payload\": \"device-online\",
    \"payload_encoding\": \"plain\",
    \"qos\": 1,
    \"retain\": false
}"
Example response:
{
    "id": "00060563A10558877ACA0C006CFA0000"
}

Endpoints

GET api/user

GET
https://amarnathm74labs.com
/api/user
requires authentication

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json
Example request:
curl --request GET \
    --get "https://amarnathm74labs.com/api/user" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
Example response:
Headers
cache-control: no-cache, private
content-type: application/json
access-control-allow-origin: *
{
    "message": "Unauthenticated."
}

Energy Aggregations

List energy aggregations

GET
https://amarnathm74labs.com
/api/devices/{device_id}/aggregations
requires authentication

Retrieve paginated energy aggregations for a device.

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

device_id
integer
required

The ID of the device.

Example:
1
device
integer
required

ID of the device.

Example:
16

Query Parameters

period
string

Filter by period type (hourly or daily).

Example:
hourly
from
string

Filter aggregations from this date (Y-m-d format).

Example:
2024-01-01
to
string

Filter aggregations to this date (Y-m-d format).

Example:
2024-01-31
page
integer

Page number for pagination.

Example:
1
Example request:
curl --request GET \
    --get "https://amarnathm74labs.com/api/devices/1/aggregations?period=hourly&from=2024-01-01&to=2024-01-31&page=1" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
Example response:
{
    "current_page": 1,
    "data": [
        {
            "id": 1,
            "device_id": 1,
            "period": "hourly",
            "period_start": "2024-01-01T12:00:00Z",
            "energy_wh": "150.5000",
            "reading_count": 60,
            "avg_voltage": "120.5000",
            "avg_current": "5.1234",
            "avg_power_factor": "0.9800",
            "max_power": "650.0000",
            "min_power": "580.0000",
            "created_at": "2024-01-01T13:00:00Z",
            "updated_at": "2024-01-01T13:00:00Z"
        }
    ],
    "total": 1
}

Energy aggregation summary

GET
https://amarnathm74labs.com
/api/devices/{device_id}/aggregations/summary
requires authentication

Retrieve energy summary totals with quality metrics.

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

device_id
integer
required

The ID of the device.

Example:
1
device
integer
required

ID of the device.

Example:
16
Example request:
curl --request GET \
    --get "https://amarnathm74labs.com/api/devices/1/aggregations/summary" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
Example response:
{
    "today": "12.5000",
    "this_week": "85.2500",
    "this_month": "320.7500",
    "all_time": "1500.0000",
    "avg_daily_kwh": 0.43,
    "projected_monthly_kwh": 12.9,
    "voltage_quality": {
        "avg_voltage": 230.5,
        "in_range_pct": 95.5,
        "quality_score": "good"
    },
    "avg_power_factor": 0.92
}

Energy Readings

List energy readings

GET
https://amarnathm74labs.com
/api/devices/{device_id}/readings
requires authentication

Retrieve paginated energy readings for a device with optional time filtering.

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

device_id
integer
required

The ID of the device.

Example:
1
device
integer
required

ID of the device.

Example:
16

Query Parameters

page
integer

Page number for pagination.

Example:
1
from
string

Filter readings from this datetime (ISO 8601).

Example:
2024-01-01T00:00:00Z
to
string

Filter readings to this datetime (ISO 8601).

Example:
2024-01-31T23:59:59Z
order
string

Sort order by recorded_at (asc or desc).

Example:
desc
per_page
integer

Items per page (max 200).

Example:
25

Body Parameters

Example request:
curl --request GET \
    --get "https://amarnathm74labs.com/api/devices/1/readings?page=1&from=2024-01-01T00%3A00%3A00Z&to=2024-01-31T23%3A59%3A59Z&order=desc&per_page=25" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"from\": \"2026-05-08T17:58:52\",
    \"to\": \"2026-05-08T17:58:52\",
    \"order\": \"asc\",
    \"per_page\": 1
}"
Example response:
{
    "current_page": 1,
    "data": [
        {
            "id": 1,
            "device_id": 1,
            "recorded_at": "2024-01-01T12:00:00Z",
            "voltage_rms": "120.5000",
            "current_rms": "5.123456",
            "power_active": "615.0000",
            "power_fvar": "100.0000",
            "power_apparent": "623.0000",
            "power_factor": "0.9870",
            "frequency": "60.000",
            "phase_angle": "17.47",
            "voltage_peak": "170.2500",
            "current_peak": "7.234567",
            "voltage_crest": "1.4142",
            "current_crest": "1.4142",
            "energy_wh": "1234.5678",
            "energy_wh_delta": "0.1234",
            "temp_c": "42.50",
            "created_at": "2024-01-01T12:00:00Z",
            "updated_at": "2024-01-01T12:00:00Z"
        }
    ],
    "total": 1
}

Latest energy reading

GET
https://amarnathm74labs.com
/api/devices/{device_id}/readings/latest
requires authentication

Retrieve the most recent energy reading for a device.

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

device_id
integer
required

The ID of the device.

Example:
1
device
integer
required

ID of the device.

Example:
16
Example request:
curl --request GET \
    --get "https://amarnathm74labs.com/api/devices/1/readings/latest" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
Example response:
{
    "id": 1,
    "device_id": 1,
    "recorded_at": "2024-01-01T12:00:00Z",
    "voltage_rms": "120.5000",
    "current_rms": "5.123456",
    "power_active": "615.0000",
    "power_fvar": "100.0000",
    "power_apparent": "623.0000",
    "power_factor": "0.9870",
    "frequency": "60.000",
    "phase_angle": "17.47",
    "voltage_peak": "170.2500",
    "current_peak": "7.234567",
    "voltage_crest": "1.4142",
    "current_crest": "1.4142",
    "energy_wh": "1234.5678",
    "energy_wh_delta": "0.1234",
    "temp_c": "42.50",
    "created_at": "2024-01-01T12:00:00Z",
    "updated_at": "2024-01-01T12:00:00Z"
}
{
    "message": "No readings found."
}

Energy reading statistics

GET
https://amarnathm74labs.com
/api/devices/{device_id}/readings/stats
requires authentication

Retrieve aggregated statistics for energy readings within a time window.

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

device_id
integer
required

The ID of the device.

Example:
1
device
integer
required

ID of the device.

Example:
16

Query Parameters

from
string

Start datetime (ISO 8601).

Example:
2024-01-01T00:00:00Z
to
string

End datetime (ISO 8601).

Example:
2024-01-31T23:59:59Z

Body Parameters

Example request:
curl --request GET \
    --get "https://amarnathm74labs.com/api/devices/1/readings/stats?from=2024-01-01T00%3A00%3A00Z&to=2024-01-31T23%3A59%3A59Z" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"from\": \"2026-05-08T17:58:52\",
    \"to\": \"2026-05-08T17:58:52\"
}"
Example response:
{
    "period": {
        "from": "2024-01-01T00:00:00Z",
        "to": "2024-01-31T23:59:59Z",
        "reading_count": 1440
    },
    "voltage": {
        "avg": 230.5,
        "min": 218,
        "max": 242,
        "std_dev": 3.2,
        "in_range_pct": 95.5,
        "sag_count": 12,
        "swell_count": 3
    },
    "current": {
        "avg": 4.5,
        "min": 0.1,
        "max": 15.2
    },
    "power": {
        "avg": 1035,
        "min": 23,
        "max": 3500,
        "total_energy_wh": 14904
    },
    "power_factor": {
        "avg": 0.92,
        "min": 0.45,
        "max": 0.99,
        "below_085_pct": 8.5
    },
    "frequency": {
        "avg": 50,
        "min": 49.8,
        "max": 50.2,
        "std_dev": 0.05
    },
    "temperature": {
        "avg": 42.5,
        "min": 35,
        "max": 55
    }
}

Time series data

GET
https://amarnathm74labs.com
/api/devices/{device_id}/readings/timeseries
requires authentication

Retrieve time-bucketed energy readings for charting.

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

device_id
integer
required

The ID of the device.

Example:
1
device
integer
required

ID of the device.

Example:
16

Query Parameters

from
string
required

Start datetime (ISO 8601).

Example:
2024-01-01T00:00:00Z
to
string
required

End datetime (ISO 8601).

Example:
2024-01-02T00:00:00Z
metric
string

Metric to aggregate: voltage_rms, current_rms, power_active, power_factor, frequency, temp_c, or all.

Example:
voltage_rms
interval
string

Bucket interval: 5m, 15m, 1h, 6h, 1d, 1w.

Example:
1h

Body Parameters

Example request:
curl --request GET \
    --get "https://amarnathm74labs.com/api/devices/1/readings/timeseries?from=2024-01-01T00%3A00%3A00Z&to=2024-01-02T00%3A00%3A00Z&metric=voltage_rms&interval=1h" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"from\": \"2026-05-08T17:58:52\",
    \"to\": \"2026-05-08T17:58:52\",
    \"metric\": \"power_active\",
    \"interval\": \"1h\"
}"
Example response:
{
    "interval": "1h",
    "metric": "voltage_rms",
    "data": [
        {
            "bucket": "2024-01-01 00:00:00",
            "avg": 230.5,
            "min": 228,
            "max": 233,
            "count": 60
        }
    ]
}

Metric distribution

GET
https://amarnathm74labs.com
/api/devices/{device_id}/readings/distribution
requires authentication

Get histogram-style distribution of a metric.

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

device_id
integer
required

The ID of the device.

Example:
1
device
integer
required

ID of the device.

Example:
16

Query Parameters

from
string
required

Start datetime (ISO 8601).

Example:
2024-01-01T00:00:00Z
to
string
required

End datetime (ISO 8601).

Example:
2024-01-31T23:59:59Z
metric
string
required

Metric to distribute: voltage_rms, current_rms, power_active, power_factor, frequency, temp_c.

Example:
voltage_rms
buckets
integer

Number of histogram buckets (2-100).

Example:
20

Body Parameters

Example request:
curl --request GET \
    --get "https://amarnathm74labs.com/api/devices/1/readings/distribution?from=2024-01-01T00%3A00%3A00Z&to=2024-01-31T23%3A59%3A59Z&metric=voltage_rms&buckets=20" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"from\": \"2026-05-08T17:58:52\",
    \"to\": \"2026-05-08T17:58:52\",
    \"metric\": \"current_rms\",
    \"buckets\": 1
}"
Example response:
{
    "metric": "voltage_rms",
    "buckets": [
        {
            "range_start": 218,
            "range_end": 219.2,
            "count": 15,
            "percentage": 3.5
        }
    ],
    "total_count": 430
}

Hourly usage profile

GET
https://amarnathm74labs.com
/api/devices/{device_id}/readings/hourly-profile
requires authentication

Get average energy usage by hour of day.

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

device_id
integer
required

The ID of the device.

Example:
1
device
integer
required

ID of the device.

Example:
16

Query Parameters

from
string

Start datetime (ISO 8601).

Example:
2024-01-01T00:00:00Z
to
string

End datetime (ISO 8601).

Example:
2024-01-31T23:59:59Z

Body Parameters

Example request:
curl --request GET \
    --get "https://amarnathm74labs.com/api/devices/1/readings/hourly-profile?from=2024-01-01T00%3A00%3A00Z&to=2024-01-31T23%3A59%3A59Z" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"from\": \"2026-05-08T17:58:52\",
    \"to\": \"2026-05-08T17:58:52\"
}"
Example response:
{
    "data": [
        {
            "hour": 0,
            "avg_power": 120.5,
            "avg_voltage": 231.2,
            "total_energy_wh": 240.5,
            "reading_count": 120
        }
    ]
}

Loads

List loads

GET
https://amarnathm74labs.com
/api/devices/{device_id}/loads
requires authentication

Retrieve paginated loads for a device with optional filtering.

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

device_id
integer
required

The ID of the device.

Example:
1
device
integer
required

ID of the device.

Example:
16

Query Parameters

page
integer

Page number for pagination.

Example:
1
from
string

Filter loads started from this datetime (ISO 8601).

Example:
2024-01-01T00:00:00Z
to
string

Filter loads started to this datetime (ISO 8601).

Example:
2024-01-31T23:59:59Z
sort
string

Sort by: date, energy, or duration.

Example:
date

Body Parameters

Example request:
curl --request GET \
    --get "https://amarnathm74labs.com/api/devices/1/loads?page=1&from=2024-01-01T00%3A00%3A00Z&to=2024-01-31T23%3A59%3A59Z&sort=date" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"from\": \"2026-05-08T17:58:52\",
    \"to\": \"2026-05-08T17:58:52\",
    \"sort\": \"duration\"
}"
Example response:
{
    "current_page": 1,
    "data": [
        {
            "id": 1,
            "device_id": 1,
            "name": "TV",
            "started_at": "2024-01-01T10:00:00Z",
            "ended_at": "2024-01-01T12:00:00Z",
            "start_energy_wh": "1234.5678",
            "end_energy_wh": "1240.1234",
            "energy_consumed_wh": "5.5556",
            "created_at": "2024-01-01T10:00:00Z",
            "updated_at": "2024-01-01T12:00:00Z"
        }
    ],
    "total": 1
}

Get active load

GET
https://amarnathm74labs.com
/api/devices/{device_id}/loads/active
requires authentication

Retrieve the current active load for a device.

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

device_id
integer
required

The ID of the device.

Example:
1
device
integer
required

ID of the device.

Example:
16
Example request:
curl --request GET \
    --get "https://amarnathm74labs.com/api/devices/1/loads/active" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
Example response:
{
    "id": 1,
    "device_id": 1,
    "name": "TV",
    "started_at": "2024-01-01T10:00:00Z",
    "ended_at": null,
    "start_energy_wh": "1234.5678",
    "end_energy_wh": null,
    "energy_consumed_wh": null,
    "created_at": "2024-01-01T10:00:00Z",
    "updated_at": "2024-01-01T10:00:00Z"
}
{
    "message": "No active load."
}

Load summary by appliance

GET
https://amarnathm74labs.com
/api/devices/{device_id}/loads/summary
requires authentication

Aggregate load statistics grouped by appliance name.

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

device_id
integer
required

The ID of the device.

Example:
1
device
integer
required

ID of the device.

Example:
16

Query Parameters

from
string

Filter loads started from this datetime (ISO 8601).

Example:
2024-01-01T00:00:00Z
to
string

Filter loads started to this datetime (ISO 8601).

Example:
2024-01-31T23:59:59Z

Body Parameters

Example request:
curl --request GET \
    --get "https://amarnathm74labs.com/api/devices/1/loads/summary?from=2024-01-01T00%3A00%3A00Z&to=2024-01-31T23%3A59%3A59Z" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"from\": \"2026-05-08T17:58:52\",
    \"to\": \"2026-05-08T17:58:52\"
}"
Example response:
{
    "data": [
        {
            "name": "TV",
            "session_count": 15,
            "total_energy_wh": 450.25,
            "total_duration_minutes": 1800.5,
            "avg_power_w": 15,
            "projected_monthly_kwh": 0.54
        }
    ]
}

Start a load

POST
https://amarnathm74labs.com
/api/devices/{device_id}/loads
requires authentication

Start a new load for a device. Ends any existing active load.

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

device_id
integer
required

The ID of the device.

Example:
1
device
integer
required

ID of the device.

Example:
16

Body Parameters

Example request:
curl --request POST \
    "https://amarnathm74labs.com/api/devices/1/loads" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"name\": \"TV\"
}"
Example response:
{
    "id": 1,
    "device_id": 1,
    "name": "TV",
    "started_at": "2024-01-01T10:00:00Z",
    "ended_at": null,
    "start_energy_wh": "1234.5678",
    "end_energy_wh": null,
    "energy_consumed_wh": null,
    "created_at": "2024-01-01T10:00:00Z",
    "updated_at": "2024-01-01T10:00:00Z"
}
{
    "message": "No energy readings available to start a load."
}

End a load

PUT
https://amarnathm74labs.com
/api/devices/{device_id}/loads/{load_id}/end
requires authentication

End a specific load and calculate energy consumed.

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

device_id
integer
required

The ID of the device.

Example:
1
load_id
integer
required

The ID of the load.

Example:
1
device
integer
required

ID of the device.

Example:
16
load
integer
required

ID of the load.

Example:
16
Example request:
curl --request PUT \
    "https://amarnathm74labs.com/api/devices/1/loads/1/end" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
Example response:
{
    "id": 1,
    "device_id": 1,
    "name": "TV",
    "started_at": "2024-01-01T10:00:00Z",
    "ended_at": "2024-01-01T12:00:00Z",
    "start_energy_wh": "1234.5678",
    "end_energy_wh": "1240.1234",
    "energy_consumed_wh": "5.5556",
    "created_at": "2024-01-01T10:00:00Z",
    "updated_at": "2024-01-01T12:00:00Z"
}
{
    "message": "Load already ended."
}
{
    "message": "No energy readings available to end this load."
}

Webhooks

Receive EMQX webhook

POST
https://amarnathm74labs.com
/api/emqx_endpoint/{broker_id}/{secret}
requires authentication

Ingest messages forwarded from the EMQX HTTP connector.

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

broker_id
integer
required

The ID of the broker.

Example:
1
secret
string
required

Webhook secret appended to the route.

Example:
architecto
broker
integer
required

ID of the broker receiving webhook traffic.

Example:
16

Body Parameters

Example request:
curl --request POST \
    "https://amarnathm74labs.com/api/emqx_endpoint/1/architecto" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"client\": \"sensor-1\",
    \"username\": \"mqtt-user\",
    \"payload\": \"device-online\",
    \"received_at\": \"1704110400000\",
    \"event\": \"message.delivered\",
    \"timestamp\": \"1704110405000\",
    \"id\": \"11f56100\"
}"
Example response:
{
    "status": "accepted"
}

Get broker webhook URL

GET
https://amarnathm74labs.com
/api/brokers/{broker_id}/webhook
requires authentication

Retrieve the full EMQX webhook endpoint for a broker.

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

broker_id
integer
required

The ID of the broker.

Example:
1
Example request:
curl --request GET \
    --get "https://amarnathm74labs.com/api/brokers/1/webhook" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
Example response:
{
    "url": "https://example.com/api/emqx_endpoint/1/secret123"
}

Rotate broker webhook secret

POST
https://amarnathm74labs.com
/api/brokers/{broker_id}/webhook/rotate
requires authentication

Generate a new webhook secret for the broker.

Headers

Authorization
Example:
Bearer {YOUR_AUTH_TOKEN}
Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

broker_id
integer
required

The ID of the broker.

Example:
1
Example request:
curl --request POST \
    "https://amarnathm74labs.com/api/brokers/1/webhook/rotate" \
    --header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
Example response:
{
    "url": "https://example.com/api/emqx_endpoint/1/newsecret456"
}