eGauge Meter API
eGauge Meter API
The eGauge WebAPI is a JSON-based API that provides access to eGauge meters. It offers secure means to read device data, configure the device, and perform various control operations.
The WebAPI is intended to eventually replace the eGauge XML API. For new applications, developers are encouraged to use WebAPI rather than the legacy XML API.
The authentication service. Clients can use this to obtain and manage tokens that grant access to the other resources in this API.
The meter uses JSON Web Tokens (JWT or simply token) to restrict access to protected resources. Clients must include such tokens in requests via the HTTP Authorization header. This header must have the form:
Authorization: Bearer JWT
where JWT is a valid token.
Tokens are valid for a limited time; typically for about 10 minutes. However, a meter may revoke a token earlier, e.g., due to a reboot.
The service provides the ability to execute various operations for their side effects, such as rebooting the meter. Unless stated otherwise, the resources in this service are available only to users with the save right (see /auth/rights).
curl -i -X GET \ 'https://webapi.egauge.net/_mock/webapi/4.6/openapi/config/alert?filter=string&max-depth=1' \ -H 'Authorization: Bearer <YOUR_JWT_HERE>'
{ "result": { "custom": [ … ], "reporter": { … }, "sys-prio": [ … ] }, "error": "Error message (present if an error occurred)." }
Up to 32 custom alerts.
Custom alerts consist of an arbitrary boolean condition that is checked at certain times. When the condition evaluates to true, the alert is triggered.
The alert reporting configuration. Alerts may be reported via a web server or via an email server.
The priority of each system-generated alert. /sys/alert provides a description of these alerts.
curl -i -X PUT \ https://webapi.egauge.net/_mock/webapi/4.6/openapi/config/alert \ -H 'Authorization: Bearer <YOUR_JWT_HERE>' \ -H 'Content-Type: application/json' \ -d '{ "custom": [ { "name": "temperature alert", "detail": "It is hot in here: %l C!", "frequency": "sec", "priority": 7, "cond": { "lhs": "temp_internal()", "op": "<", "rhs": "30" } } ], "reporter": { "web": { "min-priority": 7, "service": "", "uri": "https://alerts.com/report", "options": "gzip,secure", "user": "jsmith", "password": "secret!" }, "mail": { "server": "smtp.mail.com", "user": "egaugealert@mail.com", "password": "string", "from-address": "eGauge1345", "to": [ { "format": "string", "min-priority": 3, "address": "user@site.com" } ] } }, "sys-prio": [ 0, 0, 7, 0, 7, 4, 0, 0, 1, 6, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0 ] }'
{ "status": "OK", "error": "Error message (present if an error occurred)." }
Up to 32 custom alerts.
Custom alerts consist of an arbitrary boolean condition that is checked at certain times. When the condition evaluates to true, the alert is triggered.
The alert reporting configuration. Alerts may be reported via a web server or via an email server.
The priority of each system-generated alert. /sys/alert provides a description of these alerts.
curl -i -X POST \ https://webapi.egauge.net/_mock/webapi/4.6/openapi/config/alert \ -H 'Authorization: Bearer <YOUR_JWT_HERE>' \ -H 'Content-Type: application/json' \ -d '{ "custom": [ { "name": "temperature alert", "detail": "It is hot in here: %l C!", "frequency": "sec", "priority": 7, "cond": { "lhs": "temp_internal()", "op": "<", "rhs": "30" } } ], "reporter": { "web": { "min-priority": 7, "service": "", "uri": "https://alerts.com/report", "options": "gzip,secure", "user": "jsmith", "password": "secret!" }, "mail": { "server": "smtp.mail.com", "user": "egaugealert@mail.com", "password": "string", "from-address": "eGauge1345", "to": [ { "format": "string", "min-priority": 3, "address": "user@site.com" } ] } }, "sys-prio": [ 0, 0, 7, 0, 7, 4, 0, 0, 1, 6, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0 ] }'
{ "status": "OK", "error": "Error message (present if an error occurred)." }
curl -i -X DELETE \ https://webapi.egauge.net/_mock/webapi/4.6/openapi/config/alert \ -H 'Authorization: Bearer <YOUR_JWT_HERE>'