NAV
Command Line Ruby Python PHP Perl Java NodeJS Javascript

Introduction

Welcome to the EKM METERING API!

We at EKM see easy access to your data, and the scalable systems behind the EKM Push, as crucial to moving our products into the future. To that end, we do what is unheard of in our industry, we give you your data for FREE.

The EKM API is organized around Representational State Transfer, or REST. You can use our Application Programming Interface, or API, to access EKM API endpoints, which can get you information on various EKM Push meter data and utilize it in your own application, database, billing system, or building automation system.

We have language bindings in Shell (cURL), Ruby, Python, PHP, Java, Javascript and Nodejs! You can view code examples in the dark area to the right, and you can switch the programming language of the examples with the tabs in the top right.

Our API is designed to have predictable, resource-oriented URLs and to use HTTP response codes to indicate API errors. We use built-in HTTP features, like HTTP authentication and HTTP verbs, which can be understood by off-the-shelf HTTP clients, and we support cross-origin resource sharing to allow you to interact securely with our API from a client-side web application (though you should remember that you should never expose your secret EKM Push API key in any public website’s client-side code). JSON will be returned in all responses from the API, including errors (though if you’re using API bindings, we will convert the response to the appropriate language-specific object).

Authentication

To authorize, make sure to use your personal EKM Push account key.

The examples in this API documentation use the demo key of MTAxMDoyMDIw. Please make sure you remove this key and place your personal key in the https address if you are trying to access the meters in your account.

With shell, you can just pass the correct address with each request
curl -s "URL Here"
Authorization: "EKM Push Key"
# Ruby Version: 3.1.2

# Load required modules
require 'net/http'
require 'json'
require 'uri'

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call

def call_api(api_path)
  uri = URI.parse("URL Here#{api_path}")
  response = Net::HTTP.get_response(uri)
  puts response.uri
  JSON.parse(response.body)
end

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call
# URI only NOT URL - Do not include for example https://summary.ekmpush.com
api_object = call_api('URI Here')

# This just displays the object but you can use what ever
# code you would like to work with the object here
require 'pp'
pp api_object

'''
Python version: 3.9.12
'''

# Required Python Modules
import urllib.request
import urllib.error
import urllib.parse
import json
import pprint

# This function accesses the api_request URL and converts
# the contents to a usable Python object and returns it
def call_api ( api_request ):
    '''
    Make http request
    '''
    response = urllib.request.urlopen(api_request)
    response = response.read()
    json_object = json.loads(response.decode())
    return json_object

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call
api_object = call_api("URL Here")

# This just displays the object but you can use what ever
# code you would like to work with the object here
pprint.pprint(api_object)

<?php
// PHP 8.0.17 (cli)

// Call the callApi function to create a usable
// object named $apiObject from the API request URL.
// Put the API request URL in the call
$apiObject=callApi('URL Here');

// This just displays the object but you can use what ever
// code you would like to work with the object here
var_dump($apiObject);

// This function accesses the apiRequest URL and converts
// the contents to a usable PHP object and returns it
function callApi ($apiRequest='') {

        $json=@file_get_contents($apiRequest);
        $jsonObject=json_decode($json);
        return ($jsonObject);

}
?>    
#!/usr/bin/perl
# Perl version: v5.34
# CPAN.pm version 2.2
# Perl Modules Version:
# JSON: 4.05
# LWP::Protocol::https: 6.10
# LWP::Simple: 6.62
#
# OS Prerequisites
# UBUNTU
# apt install cpanminus
#
# Install Perl Modules
#       cpan LWP::Simple
#       cpan LWP::Protocol::https
#       cpan JSON

# Required Perl Modules
use strict;
use warnings;
use LWP::Simple;
use JSON;
use Data::Dumper;

# This function accesses the api_request URL and converts
# the contents to a usable Perl object and returns it
sub call_api {
    my $api_request = shift;
    my $json_text   = get($api_request);
    my $json_object = JSON->new->utf8->decode($json_text);
    return $json_object;
}

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call
my $api_object = call_api('URL Here');

# This just displays the object but you can use what ever
# code you would like to work with the object here
print Dumper($api_object);    ## no critic (InputOutput::RequireCheckedSyscalls)

/*
 openjdk version "17.0.2" 2022-01-18

 Download the correct org.json jar version for your
 needs from: https://mvnrepository.com/artifact/org.json/json

 This example uses version 20220320 accessible here:
 https://repo1.maven.org/maven2/org/json/json/20220320/json-20220320.jar

 Instructions to run this program

 1. Put this code in a file named EKM.java
 2. Copy the downloaded org.json jar and EKM.java to the same directory
 3. Compile
  javac -cp .:./json-20220320.jar ./EKM.java
 4. Run
  java -cp .:./json-20220320.jar EKM
*/

//Import required classes
import java.net.*;
import java.io.*;
import org.json.*;

@java.lang.SuppressWarnings({"java:S106", "java:S112", "java:S125"})

public class EKM {
    public static JSONObject callApi(String apiRequest) throws Exception {

        // This code accesses the apiRequest URL and converts
        // the contents to a usable JSON object

        URL url = new URL(apiRequest);
        URLConnection connection = url.openConnection();
        BufferedReader in = new BufferedReader(
                                               new InputStreamReader(
                                                                     connection.getInputStream()));

        StringBuilder response = new StringBuilder();
        String inputLine;

        while ((inputLine = in.readLine()) != null)
            response.append(inputLine);

        in.close();

        return new JSONObject(response.toString());
    }

    public static void main(String[] args) throws Exception {
        /*
         Call callApi to create a usable
         object named apiObject from the API request URL.
         Put the API request URL in the call
         */
        JSONObject apiObject = EKM.callApi("URL Here");

        /*
         You can access any part of the apiObject using code like this:
         JSONArray  readData = apiObject.getJSONObject("readMeter").getJSONArray("ReadSet").
         getJSONObject(0).getJSONArray("ReadData");
        */

        // This just outputs the whole apiObject
        System.out.println(apiObject.toString(4));
    }
}
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">

// The example function is called from the 
// body tag when the page loads
function example(){

// Call the callApi function to create a usable
// object named apiObject from the API request URL.
// Put the API request URL in the call
callApi('URL Here',function(apiObject){

       // This just displays the object in the result div
       // you can use what ever code you would like to work 
       // with the object here
       document.getElementById("result").innerHTML = "<pre>"+JSON.stringify(apiObject, null, 4)+"</pre>";
       });

};

// This code accesses the apiRequest URL and converts
// the contents to a usable JSON object named apiObject
function callApi(apiRequest,callback) {
    var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
      if (xhttp.readyState == 4 && xhttp.status == 200) {
        var jsonObject = JSON.parse(xhttp.responseText);
        callback(jsonObject);
      }
    };
    xhttp.open("GET", apiRequest, true);
    xhttp.send();
}
</script>

</head>
  <body onload="example()">
    <div id="result"/>
  </body>
</html>
/*
* Requirements
* NodeJS: v16.14.2
* Axios:  0.27.2
*/

// Load modules
const axios = require('axios');

const apiClient = axios.create({
  baseURL: 'URL Here',
  timeout: 1000 * 15,
})

// This code accesses the apiRequest query and
// logs the response data or the error
;(async () => {
  try {
    const res = await apiClient.get('URI Here');
    const apiResData = res.data;

    console.log(JSON.stringify(apiResData, null, 2));
  } catch (error) {
    console.error(error.message);
  }
})();

Make sure to replace the sample key: MTAxMDoyMDIw, with your API key in the https address.

EKM uses API keys to allow access to the API. You authenticate to the EKM API by providing one of your unique API keys in each request. Each Push account holder is provided with an EKM Push User Key, which provides access to all meters in their account. This key carries lots of privileges so we encourage you to keep it secret. In addition to this master key, additional keys are also provided to give access to each meter individually, and keys can be created to provide access to sub groups of meters upon request. These secondary keys can be used to share single meters, or a subset of meters, without sharing access to all meters in an account. For example, if you are a landlord with multiple rentals and meters, you could share specific meter keys with each of your tenants, so that they could have access to only the data that pertains to their usage.

Authentication to the API occurs via HTTP Basic Auth. Provide your API key as the basic authorized username. You do not need to provide a password. You must authenticate for all requests.

The EKM Push API expects the API key to be included in all requests to the server. The key is included in the URL in the following way:

Authorization: key=MTAxMDoyMDIw

Realtime API

Click here to go to Realtime Documentation

If you are developing your own app, cloud-to-cloud solution, billing system, or other SAS solution, our Real-Time API allows you to easily access your EKM Push data in any format that you need. Below you will find descriptions regarding how to access the data, and about the filters you can apply so the data comes to you in a format that is easily digested and inserted into your software solution.

The real-time API provides the 1000 latest meter reads for each of your meters. If your meter is being read once per minute, the data will be made available once per minute, per meter. Whether you have 1 meter or 10,000 meters, this is the easiest and most scalable way to access your data.

The EKM Dash, EKM Widget, encompass.io, wattvision.com, pvoutput.org, the other solutions in our Push App Store, as well as other customers that have their own custom solutions, all use this API to access their data. We use the same API as you and do not give ourselves any special permissions, we see what you see, which forces us to make the API as great as possible for everyone. We have even given you code examples that can be copy and pasted into your own software language to make the data access that much easier.

Use the API definition, metered values definition, code snippet suggestion, and guide to get you on your way to developing your next killer app. If you create something great, let us know; we’re open to adding all useful apps into the Push App Store.

We also have a Realtime API Request Builder Tool found here: Realtime API Builder

Account API

Click here to go to Account API Documentation

This API provides information for accounts and devices owned by the account.

Get information for the specified target, which can be account, gateway, or meter.

You could make API request with the EKM Push Key that is your own Authorization Key that you received for your Push Account, or instead the EKM Push Key you could use Gateway Key for more restricted access. Be aware that if you use the Gateway Key, you will only receive information regards to that gateway.

Trigger API

A REST API to lookup/create/update/delete triggers.

EKM Push3 gateway triggers are one of the most powerful tools that EKM has to offer. You can automate how and when the EKM Push system will react to metered values. You can have the Push gateway send you an email or control a relay to turn on/off a switch or close a valve based on the metered data for example. Push3 gateways have the ability trigger specific actions based on conditions that you set up. Triggers live on the Push3 gateways so they will continue to function even without an internet connection. Triggers can control the relays on the v.4 Omnimeters, in order to turn something on or off, or they can email you notifications of the trigger. Please note: v.3 Omnimeters do not have controllable relays, so the relay triggers will not work, but the email triggers will.

All trigger API requests require an API bearer token to prove that the client is authorized to make the request.

If the token has OWNER permissions then only triggers owned by the account associated with the token are accessible.

Trigger API Token

The Trigger section requires an API token to authorize the request.

An API token can be created here: Create API Token

Token permissions

Tokens can be given READ or READ/WRITE permission. READ permission allows only GET requests, while READ/WRITE permission also allows PUT/POST/DELETE.

Token privileges

OWNER privilege allows requests for objects owned by the account assigned to the token when it is created.

Trigger HTTPS Request

Trigger API request example

curl -i 'https://api.ekmpush.com/api/trigger?key=MTAxMDoyMDIw&gateway=4016fa0500cd' -H "Accept: application/json" -H "Authorization: Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk"
# Ruby Version: 3.1.2

# Load required modules
require 'net/http'
require 'json'
require 'uri'

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call
def call_api(api_path)
  req_header = {
    'Authorization' => 'Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk',
    'Accept' => 'application/json'
  }
  uri = URI.parse("https://api.ekmpush.com#{api_path}")
  response = Net::HTTP.get_response(uri, req_header)
  puts response.uri
  JSON.parse(response.body)
end

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call
# URI only NOT URL - Do not include https://api.ekmpush.com
api_object = call_api('/api/trigger?key=MTAxMDoyMDIw&gateway=4016fa0500cd')

# This just displays the object but you can use what ever
# code you would like to work with the object here

require 'pp'
pp api_object

'''
Python version: 3.9.12
'''

# Required Python Modules
import urllib.request
import urllib.error
import urllib.parse
import json
import pprint

# This function accesses the api_request URL and converts
# the contents to a usable Python object and returns it
def call_api ( api_request ):
    '''Make http request'''
    headers = {
        "Accept": "application/json",
        "Authorization": "Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk"
    }
    request = urllib.request.Request(api_request, headers=headers)
    response = urllib.request.urlopen(request)
    response = response.read()
    json_object = json.loads(response.decode())
    return json_object

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call
api_object = call_api("https://api.ekmpush.com/api/trigger\
?key=MTAxMDoyMDIw&gateway=4016fa0500cd")

# This just displays the object but you can use what ever
# code you would like to work with the object here
pprint.pprint(api_object)

<?php
// PHP 8.0.17 (cli)

// Call the callApi function to create a usable
// object named $apiObject from the API request URL.
// Put the API request URL in the call
$apiObject=callApi('https://api.ekmpush.com/api/trigger?key=MTAxMDoyMDIw&gateway=4016fa0500cd');

// This just displays the object but you can use what ever
// code you would like to work with the object here
var_dump($apiObject);

// This function accesses the apiRequest URL and converts
// the contents to a usable PHP object and returns it
function callApi ($apiRequest='') {
        $context = stream_context_create([
            "http" => [
                "method" => "GET",
                "header" => "Accept: application/json\r\n" .
                "Authorization: Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk\r\n"
            ]
        ]);
        $json=@file_get_contents($apiRequest, false, $context);
        $jsonObject=json_decode($json);
        return ($jsonObject);

}
#!/usr/bin/perl
# Perl version: v5.34
# CPAN.pm version 2.2
# Perl Modules Version:
# JSON: 4.05
# LWP::Protocol::https: 6.10
# LWP::Simple: 6.62
#
# OS Prerequisites
# UBUNTU
# apt install cpanminus
#
# Install Perl Modules
#       cpan LWP::Simple
#       cpan LWP::Protocol::https
#       cpan JSON

# Required Perl Modules
use strict;
use warnings;
use LWP::UserAgent;
use JSON;
use Data::Dumper;

my $user_agent = LWP::UserAgent->new;

# This function accesses the api_request URL and converts
# the contents to a usable Perl object and returns it
sub call_api {    
    my $api_request = shift;
    my $request    = HTTP::Request->new('GET' => $api_request);
    $request -> header('Accept', 'application/json');
    $request -> header('Authorization', 'Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk');
    my $json_text   = $user_agent->request($request);
    my $json_object = JSON->new->utf8->decode($json_text->content);
    return $json_object;
}

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call
my $api_object = call_api(
'https://api.ekmpush.com/api/trigger?key=MTAxMDoyMDIw&gateway=4016fa0500cd'
);

# This just displays the object but you can use what ever
# code you would like to work with the object here
print Dumper($api_object);    ## no critic (InputOutput::RequireCheckedSyscalls)

/*
 openjdk version "17.0.2" 2022-01-18

 Download the correct org.json jar version for your
 needs from: https://mvnrepository.com/artifact/org.json/json

 This example uses version 20220320 accessible here:
 https://repo1.maven.org/maven2/org/json/json/20220320/json-20220320.jar

 Instructions to run this program

 1. Put this code in a file named EKM.java
 2. Copy the downloaded org.json jar and EKM.java to the same directory
 3. Compile
  javac -cp .:./json-20220320.jar ./EKM.java
 4. Run
  java -cp .:./json-20220320.jar EKM
*/

//Import required classes
import java.net.*;
import java.io.*;
import org.json.*;

// Supress Warnings
@java.lang.SuppressWarnings({"java:S106", "java:S112", "java:S125"})

public class EKM {
    public static JSONObject callApi(String apiRequest) throws Exception {

        // This code accesses the apiRequest URL and converts
        // the contents to a usable JSON object

        URL url = new URL(apiRequest);
        URLConnection connection = url.openConnection();
        connection.setRequestProperty("Accept", "application/json");
        connection.setRequestProperty("Authorization", "Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk");
        BufferedReader in = new BufferedReader(
                                               new InputStreamReader(
                                                                     connection.getInputStream()));

        StringBuilder response = new StringBuilder();
        String inputLine;

        while ((inputLine = in.readLine()) != null)
            response.append(inputLine);

        in.close();

        return new JSONObject(response.toString());
    }

    public static void main(String[] args) throws Exception {
        /*
         Call callApi to create a usable
         object named apiObject from the API request URL.
         Put the API request URL in the call
         */
        JSONObject apiObject = EKM.callApi("https://api.ekmpush.com/api/trigger?key=MTAxMDoyMDIw&gateway=4016fa0500cd");


        // This just displays the object but you can use what ever
        // code you would like to work with the object here
        System.out.println(apiObject.toString(4));
        }
}

/*
* Requirements
* NodeJS: v16.14.2
* Axios:  0.27.2
*/

// Load modules
const axios = require('axios');

// This code accesses the apiRequest query
// and logs the response data or the error
;(async () => {
  try {
    const res = await axios.get(
        'https://api.ekmpush.com/api/trigger?key=MTAxMDoyMDIw&gateway=4016fa0500cd', {
          headers: {
            'Accept': 'application/json',
            // eslint-disable-next-line max-len
            'Authorization': 'Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk',
          }});
    const apiResData = res.data;
    console.log(JSON.stringify(apiResData, null, 2));
  } catch (error) {
    console.error(error.message);
  }
})();

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">

// The example function is called from the
// body tag when the page loads
function example(){

// Call the callApi function to create a usable
// object named apiObject from the API request URL.
// Put the API request URL in the call
callApi('https://api.ekmpush.com/api/trigger?key=MTAxMDoyMDIw&gateway=4016fa0500cd',function(apiObject){

      // This just displays the object in the result div
      // you can use what ever code you would like to work
      // with the object here
      document.getElementById("result").innerHTML = "<pre>"+JSON.stringify(apiObject, null, 4)+"</pre>";
      });

};

// This code accesses the apiRequest URL and converts
// the contents to a usable JSON object named apiObject
function callApi(apiRequest,callback) {
    var xhttp = new XMLHttpRequest();    
    xhttp.onreadystatechange = function() {
      if (xhttp.readyState == 4 && xhttp.status == 200) {
        var jsonObject = JSON.parse(xhttp.responseText);
        callback(jsonObject);
      }
    };
    xhttp.open("GET", apiRequest, true);
    xhttp.setRequestHeader("Accept", "application/json")
    xhttp.setRequestHeader("Authorization", "Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk")
    xhttp.send();
}
</script>

</head>
  <body onload="example()">
    <div id="result"> </div>
  </body>
</html>

The above example returns the following results:

{"triggers": [{"trigger_uuid": "058f3dba18cb11edbdf452540000ef9a", "trigger_name": "test", "conditions": [{"type": "data", "field": "kWh_Tot", "source": "meter", "duration": "0", "source_id": "000350000900", "continuous": false, "hysteresis": "60", "threshold_test": "rise_eq", "threshold_value": "10"}], "actions": [{"params": {"relay": "relay_1", "status": "close", "duration": 1}, "target": "meter", "command": "setRelay", "target_id": "000350000900"}], "extras": {}, "enabled": true, "created_at": "2021-07-28T17:20:31.824621+00:00", "updated_at": "2021-07-28T17:20:31.824621+00:00"}]}
{"triggers"=>
  [{"trigger_uuid"=>"058f3dba18cb11edbdf452540000ef9a",
    "trigger_name"=>"test",
    "conditions"=>
     [{"type"=>"data",
       "field"=>"kWh_Tot",
       "source"=>"meter",
       "duration"=>"0",
       "source_id"=>"000350000900",
       "continuous"=>false,
       "hysteresis"=>"60",
       "threshold_test"=>"rise_eq",
       "threshold_value"=>"10"}],
    "actions"=>
     [{"params"=>{"relay"=>"relay_1", "status"=>"close", "duration"=>1},
       "target"=>"meter",
       "command"=>"setRelay",
       "target_id"=>"000350000900"}],
    "extras"=>{},
    "enabled"=>true,
    "created_at"=>"2021-07-28T17:20:31.824621+00:00",
    "updated_at"=>"2021-07-28T17:20:31.824621+00:00"}]}
{'triggers': [{'actions': [{'command': 'setRelay',
                            'params': {'duration': 1,
                                       'relay': 'relay_1',
                                       'status': 'close'},
                            'target': 'meter',
                            'target_id': '000350000900'}],
               'conditions': [{'continuous': False,
                               'duration': '0',
                               'field': 'kWh_Tot',
                               'hysteresis': '60',
                               'source': 'meter',
                               'source_id': '000350000900',
                               'threshold_test': 'rise_eq',
                               'threshold_value': '10',
                               'type': 'data'}],
               'created_at': '2021-07-28T17:20:31.824621+00:00',
               'enabled': True,
               'extras': {},
               'trigger_name': 'test',
               'trigger_uuid': '058f3dba18cb11edbdf452540000ef9a',
               'updated_at': '2021-07-28T17:20:31.824621+00:00'}]}
object(stdClass)#6 (1) {
  ["triggers"]=>
  array(1) {
    [0]=>
    object(stdClass)#1 (8) {
      ["trigger_uuid"]=>
      string(32) "058f3dba18cb11edbdf452540000ef9a"
      ["trigger_name"]=>
      string(4) "test"
      ["conditions"]=>
      array(1) {
        [0]=>
        object(stdClass)#2 (9) {
          ["type"]=>
          string(4) "data"
          ["field"]=>
          string(7) "kWh_Tot"
          ["source"]=>
          string(5) "meter"
          ["duration"]=>
          string(1) "0"
          ["source_id"]=>
          string(12) "000350000900"
          ["continuous"]=>
          bool(false)
          ["hysteresis"]=>
          string(2) "60"
          ["threshold_test"]=>
          string(7) "rise_eq"
          ["threshold_value"]=>
          string(2) "10"
        }
      }
      ["actions"]=>
      array(1) {
        [0]=>
        object(stdClass)#4 (4) {
          ["params"]=>
          object(stdClass)#3 (3) {
            ["relay"]=>
            string(7) "relay_1"
            ["status"]=>
            string(5) "close"
            ["duration"]=>
            int(1)
          }
          ["target"]=>
          string(5) "meter"
          ["command"]=>
          string(8) "setRelay"
          ["target_id"]=>
          string(12) "000350000900"
        }
      }
      ["extras"]=>
      object(stdClass)#5 (0) {
      }
      ["enabled"]=>
      bool(true)
      ["created_at"]=>
      string(32) "2021-07-28T17:20:31.824621+00:00"
      ["updated_at"]=>
      string(32) "2021-07-28T17:20:31.824621+00:00"
    }
  }
}
$VAR1 = {
          'triggers' => [
                          {
                            'created_at' => '2021-07-28T17:20:31.824621+00:00',
                            'enabled' => bless( do{\(my $o = 1)}, 'JSON::PP::Boolean' ),
                            'extras' => {},
                            'trigger_name' => 'test',
                            'updated_at' => '2021-07-28T17:20:31.824621+00:00',
                            'conditions' => [
                                              {
                                                'duration' => '0',
                                                'threshold_value' => '10',
                                                'continuous' => bless( do{\(my $o = 0)}, 'JSON::PP::Boolean' ),
                                                'source' => 'meter',
                                                'source_id' => '000350000900',
                                                'hysteresis' => '60',
                                                'type' => 'data',
                                                'threshold_test' => 'rise_eq',
                                                'field' => 'kWh_Tot'
                                              }
                                            ],
                            'actions' => [
                                           {
                                             'params' => {
                                                           'duration' => 1,
                                                           'status' => 'close',
                                                           'relay' => 'relay_1'
                                                         },
                                             'target' => 'meter',
                                             'command' => 'setRelay',
                                             'target_id' => '000350000900'
                                           }
                                         ],
                            'trigger_uuid' => '058f3dba18cb11edbdf452540000ef9a'
                          }
                        ]
        };
{"triggers": [{
    "trigger_name": "test",
    "updated_at": "2021-07-28T17:20:31.824621+00:00",
    "trigger_uuid": "058f3dba18cb11edbdf452540000ef9a",
    "extras": {},
    "created_at": "2021-07-28T17:20:31.824621+00:00",
    "conditions": [{
        "duration": "0",
        "threshold_test": "rise_eq",
        "field": "kWh_Tot",
        "continuous": false,
        "threshold_value": "10",
        "source": "meter",
        "source_id": "000350000900",
        "type": "data",
        "hysteresis": "60"
    }],
    "actions": [{
        "target_id": "000350000900",
        "params": {
            "duration": 1,
            "relay": "relay_1",
            "status": "close"
        },
        "command": "setRelay",
        "target": "meter"
    }],
    "enabled": true
}]}
{
  "triggers": [
    {
      "trigger_uuid": "058f3dba18cb11edbdf452540000ef9a",
      "trigger_name": "test",
      "conditions": [
        {
          "type": "data",
          "field": "kWh_Tot",
          "source": "meter",
          "duration": "0",
          "source_id": "000350000900",
          "continuous": false,
          "hysteresis": "60",
          "threshold_test": "rise_eq",
          "threshold_value": "10"
        }
      ],
      "actions": [
        {
          "params": {
            "relay": "relay_1",
            "status": "close",
            "duration": 1
          },
          "target": "meter",
          "command": "setRelay",
          "target_id": "000350000900"
        }
      ],
      "extras": {},
      "enabled": true,
      "created_at": "2021-07-28T17:20:31.824621+00:00",
      "updated_at": "2021-07-28T17:20:31.824621+00:00"
    }
  ]
}
{
    "triggers": [
        {
            "trigger_uuid": "058f3dba18cb11edbdf452540000ef9a",
            "trigger_name": "test",
            "conditions": [
                {
                    "type": "data",
                    "field": "kWh_Tot",
                    "source": "meter",
                    "duration": "0",
                    "source_id": "000350000900",
                    "continuous": false,
                    "hysteresis": "60",
                    "threshold_test": "rise_eq",
                    "threshold_value": "10"
                }
            ],
            "actions": [
                {
                    "params": {
                        "relay": "relay_1",
                        "status": "close",
                        "duration": 1
                    },
                    "target": "meter",
                    "command": "setRelay",
                    "target_id": "000350000900"
                }
            ],
            "extras": {},
            "enabled": true,
            "created_at": "2021-07-28T17:20:31.824621+00:00",
            "updated_at": "2021-07-28T17:20:31.824621+00:00"
        }
    ]
}

All trigger requests will begin with the following information in the HTTPS address:

https://api.ekmpush.com/api/trigger?

The information that you provide, such as your EKM Push Key (i.e. MTAxMDoyMDIw), and all other associated information will follow the HTTPS address.

The example below of what a typical trigger HTTPS address will look like:

https://api.ekmpush.com/api/trigger?key=MTAxMDoyMDIw&gateway=4016fa0500cd

An example of the information that is in a typical HTTPS call is as follows:

HTTPS Address Description
https://api.ekmpush.com/api/trigger? Beginning of the HTTPS address
key Parameter for calling the key
MTAxMDoyMDIw EKM Push authorization key that is assigned to the meter
gateway Parameter for get trigger attributes for all the triggers owned by the specified gateway.
4016fa0500cd The mac address of the gateway that owns the trigger.

Additionally, you have to add in the request headers:

HEADERS DESCRIPTION
Accept Sets output type to JSON (i.e. application/json).
Authorization API Bearer Token to prove that the client is authorized to make the request (i.e. Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk)

Indent output

If you need to print JSON in a pretty way you have to set indent parameter.

Replace INDENT_NUMBER with a number greater than 0. This number means the number of spaces to print out the JSON:

https://api.ekmpush.com/api/trigger?key=MTAxMDoyMDIw&gateway=4016fa0500cd&indent=INDENT_NUMBER


To print the JSON with 4 spaces of indentation, your HTTPS address should look like the following:

https://api.ekmpush.com/api/trigger?key=MTAxMDoyMDIw&gateway=4016fa0500cd&indent=4

Trigger Lookup by UUID

curl -i 'https://api.ekmpush.com/api/trigger?key=MTAxMDoyMDIw&trigger=1c27d0dcefc811eb90b27de8d650408c' -H "Accept: application/json" -H "Authorization: Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk"
# Ruby Version: 3.1.2

# Load required modules
require 'net/http'
require 'json'
require 'uri'

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call
def call_api(api_path)
  req_header = {
    'Authorization' => 'Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk',
    'Accept' => 'application/json'
  }
  uri = URI.parse("https://api.ekmpush.com#{api_path}")
  response = Net::HTTP.get_response(uri, req_header)
  puts response.uri
  JSON.parse(response.body)
end

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call
# URI only NOT URL - Do not include https://api.ekmpush.com
api_object = call_api('/api/trigger?key=MTAxMDoyMDIw&trigger=1c27d0dcefc811eb90b27de8d650408c')

# This just displays the object but you can use what ever
# code you would like to work with the object here
require 'pp'
pp api_object

'''
Python version: 3.9.12
'''

# Required Python Modules
import urllib.request
import urllib.error
import urllib.parse
import json
import pprint

# This function accesses the api_request URL and converts
# the contents to a usable Python object and returns it
def call_api ( api_request ):
    '''Make http request'''
    headers = {
        "Accept": "application/json",
        "Authorization": "Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk"
    }
    request = urllib.request.Request(api_request, headers=headers)
    response = urllib.request.urlopen(request)
    response = response.read()
    json_object = json.loads(response.decode())
    return json_object

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call
api_object = call_api("https://api.ekmpush.com/api/trigger\
?key=MTAxMDoyMDIw&trigger=1c27d0dcefc811eb90b27de8d650408c")

# This just displays the object but you can use what ever
# code you would like to work with the object here
pprint.pprint(api_object)

<?php
// PHP 8.0.17 (cli)

// Call the callApi function to create a usable
// object named $apiObject from the API request URL.
// Put the API request URL in the call
$apiObject=callApi('https://api.ekmpush.com/api/trigger?key=MTAxMDoyMDIw&trigger=1c27d0dcefc811eb90b27de8d650408c');

// This just displays the object but you can use what ever
// code you would like to work with the object here
var_dump($apiObject);

// This function accesses the apiRequest URL and converts
// the contents to a usable PHP object and returns it
function callApi ($apiRequest='') {
        $context = stream_context_create([
            "http" => [
                "method" => "GET",
                "header" => "Accept: application/json\r\n" .
                "Authorization: Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk\r\n"
            ]
        ]);
        $json=@file_get_contents($apiRequest, false, $context);
        $jsonObject=json_decode($json);
        return ($jsonObject);

}
#!/usr/bin/perl
# Perl version: v5.34
# CPAN.pm version 2.2
# Perl Modules Version:
# JSON: 4.05
# LWP::Protocol::https: 6.10
# LWP::Simple: 6.62
#
# OS Prerequisites
# UBUNTU
# apt install cpanminus
#
# Install Perl Modules
#       cpan LWP::Simple
#       cpan LWP::Protocol::https
#       cpan JSON

# Required Perl Modules
use strict;
use warnings;
use LWP::UserAgent;
use JSON;
use Data::Dumper;

my $user_agent = LWP::UserAgent->new;

# This function accesses the api_request URL and converts
# the contents to a usable Perl object and returns it
sub call_api {    
    my $api_request = shift;
    my $request    = HTTP::Request->new('GET' => $api_request);
    $request -> header('Accept', 'application/json');
    $request -> header('Authorization', 'Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk');
    my $json_text   = $user_agent->request($request);
    my $json_object = JSON->new->utf8->decode($json_text->content);
    return $json_object;
}

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call
my $api_object = call_api(
'https://api.ekmpush.com/api/trigger?key=MTAxMDoyMDIw&trigger=1c27d0dcefc811eb90b27de8d650408c'
);

# This just displays the object but you can use what ever
# code you would like to work with the object here
print Dumper($api_object);    ## no critic (InputOutput::RequireCheckedSyscalls)

/*
 openjdk version "17.0.2" 2022-01-18

 Download the correct org.json jar version for your
 needs from: https://mvnrepository.com/artifact/org.json/json

 This example uses version 20220320 accessible here:
 https://repo1.maven.org/maven2/org/json/json/20220320/json-20220320.jar

 Instructions to run this program

 1. Put this code in a file named EKM.java
 2. Copy the downloaded org.json jar and EKM.java to the same directory
 3. Compile
  javac -cp .:./json-20220320.jar ./EKM.java
 4. Run
  java -cp .:./json-20220320.jar EKM
*/

//Import required classes
import java.net.*;
import java.io.*;
import org.json.*;

// Supress Warnings
@java.lang.SuppressWarnings({"java:S106", "java:S112", "java:S125"})

public class EKM {
    public static JSONObject callApi(String apiRequest) throws Exception {

        // This code accesses the apiRequest URL and converts
        // the contents to a usable JSON object

        URL url = new URL(apiRequest);
        URLConnection connection = url.openConnection();
        connection.setRequestProperty("Accept", "application/json");
        connection.setRequestProperty("Authorization", "Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk");
        BufferedReader in = new BufferedReader(
                                               new InputStreamReader(
                                                                     connection.getInputStream()));

        StringBuilder response = new StringBuilder();
        String inputLine;

        while ((inputLine = in.readLine()) != null)
            response.append(inputLine);

        in.close();

        return new JSONObject(response.toString());
    }

    public static void main(String[] args) throws Exception {
        /*
         Call callApi to create a usable
         object named apiObject from the API request URL.
         Put the API request URL in the call
         */
        JSONObject apiObject = EKM.callApi("https://api.ekmpush.com/api/trigger?key=MTAxMDoyMDIw&trigger=1c27d0dcefc811eb90b27de8d650408c");


        // This just displays the object but you can use what ever
        // code you would like to work with the object here
        System.out.println(apiObject.toString(4));
        }
}

/*
* Requirements
* NodeJS: v16.14.2
* Axios:  0.27.2
*/

// Load modules
const axios = require('axios');

// This code accesses the apiRequest query
// and logs the response data or the error
;(async () => {
  try {
    const res = await axios.get(
        'https://api.ekmpush.com/api/trigger?key=MTAxMDoyMDIw&trigger=1c27d0dcefc811eb90b27de8d650408c', {
          headers: {
            'Accept': 'application/json',
            // eslint-disable-next-line max-len
            'Authorization': 'Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk',
          }});
    const apiResData = res.data;
    console.log(JSON.stringify(apiResData, null, 2));
  } catch (error) {
    console.error(error.message);
  }
})();

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">

// The example function is called from the
// body tag when the page loads
function example(){

// Call the callApi function to create a usable
// object named apiObject from the API request URL.
// Put the API request URL in the call
callApi('https://api.ekmpush.com/api/trigger?key=MTAxMDoyMDIw&trigger=1c27d0dcefc811eb90b27de8d650408c',function(apiObject){

      // This just displays the object in the result div
      // you can use what ever code you would like to work
      // with the object here
      document.getElementById("result").innerHTML = "<pre>"+JSON.stringify(apiObject, null, 4)+"</pre>";
      });

};

// This code accesses the apiRequest URL and converts
// the contents to a usable JSON object named apiObject
function callApi(apiRequest,callback) {
    var xhttp = new XMLHttpRequest();    
    xhttp.onreadystatechange = function() {
      if (xhttp.readyState == 4 && xhttp.status == 200) {
        var jsonObject = JSON.parse(xhttp.responseText);
        callback(jsonObject);
      }
    };
    xhttp.open("GET", apiRequest, true);
    xhttp.setRequestHeader("Accept", "application/json")
    xhttp.setRequestHeader("Authorization", "Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk")
    xhttp.send();
}
</script>

</head>
  <body onload="example()">
    <div id="result"> </div>
  </body>
</html>

Get trigger attributes for the specified trigger as a JSON object.

To retrieve the trigger attribute, all that is required is to change the UUID, to the UUID of your trigger:

https://api.ekmpush.com/api/trigger?key=MTAxMDoyMDIw&trigger=UUID


The example below will return the trigger attribute for the trigger UUID 1c27d0dcefc811eb90b27de8d650408c:

https://api.ekmpush.com/api/trigger?key=MTAxMDoyMDIw&trigger=1c27d0dcefc811eb90b27de8d650408c

URL PARAMETERS

KEY DESCRIPTION
trigger (string) – The trigger uuid.

Additionally, you have to add in the request headers:

HEADERS PARAMETERS

HEADERS DESCRIPTION
Accept Sets output type to JSON (i.e. application/json).
Authorization API Bearer Token to prove that the client is authorized to make the request (i.e. Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk)

Trigger Lookup by Gateway

curl -i 'https://api.ekmpush.com/api/trigger?key=MTAxMDoyMDIw&gateway=4016fa0500cd' -H "Accept: application/json" -H "Authorization: Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk"
# Ruby Version: 3.1.2

# Load required modules
require 'net/http'
require 'json'
require 'uri'

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call
def call_api(api_path)
  req_header = {
    'Authorization' => 'Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk',
    'Accept' => 'application/json'
  }
  uri = URI.parse("https://api.ekmpush.com#{api_path}")
  response = Net::HTTP.get_response(uri, req_header)
  puts response.uri
  JSON.parse(response.body)
end

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call
# URI only NOT URL - Do not include https://api.ekmpush.com
api_object = call_api('/api/trigger?key=MTAxMDoyMDIw&gateway=4016fa0500cd')

# This just displays the object but you can use what ever
# code you would like to work with the object here

require 'pp'
pp api_object

'''
Python version: 3.9.12
'''

# Required Python Modules
import urllib.request
import urllib.error
import urllib.parse
import json
import pprint

# This function accesses the api_request URL and converts
# the contents to a usable Python object and returns it
def call_api ( api_request ):
    '''Make http request'''
    headers = {
        "Accept": "application/json",
        "Authorization": "Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk"
    }
    request = urllib.request.Request(api_request, headers=headers)
    response = urllib.request.urlopen(request)
    response = response.read()
    json_object = json.loads(response.decode())
    return json_object

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call
api_object = call_api("https://api.ekmpush.com/api/trigger\
?key=MTAxMDoyMDIw&gateway=4016fa0500cd")

# This just displays the object but you can use what ever
# code you would like to work with the object here
pprint.pprint(api_object)

<?php
// PHP 8.0.17 (cli)

// Call the callApi function to create a usable
// object named $apiObject from the API request URL.
// Put the API request URL in the call
$apiObject=callApi('https://api.ekmpush.com/api/trigger?key=MTAxMDoyMDIw&gateway=4016fa0500cd');

// This just displays the object but you can use what ever
// code you would like to work with the object here
var_dump($apiObject);

// This function accesses the apiRequest URL and converts
// the contents to a usable PHP object and returns it
function callApi ($apiRequest='') {
        $context = stream_context_create([
            "http" => [
                "method" => "GET",
                "header" => "Accept: application/json\r\n" .
                "Authorization: Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk\r\n"
            ]
        ]);
        $json=@file_get_contents($apiRequest, false, $context);
        $jsonObject=json_decode($json);
        return ($jsonObject);

}
#!/usr/bin/perl
# Perl version: v5.34
# CPAN.pm version 2.2
# Perl Modules Version:
# JSON: 4.05
# LWP::Protocol::https: 6.10
# LWP::Simple: 6.62
#
# OS Prerequisites
# UBUNTU
# apt install cpanminus
#
# Install Perl Modules
#       cpan LWP::Simple
#       cpan LWP::Protocol::https
#       cpan JSON

# Required Perl Modules
use strict;
use warnings;
use LWP::UserAgent;
use JSON;
use Data::Dumper;

my $user_agent = LWP::UserAgent->new;

# This function accesses the api_request URL and converts
# the contents to a usable Perl object and returns it
sub call_api {    
    my $api_request = shift;
    my $request    = HTTP::Request->new('GET' => $api_request);
    $request -> header('Accept', 'application/json');
    $request -> header('Authorization', 'Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk');
    my $json_text   = $user_agent->request($request);
    my $json_object = JSON->new->utf8->decode($json_text->content);
    return $json_object;
}

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call
my $api_object = call_api(
'https://api.ekmpush.com/api/trigger?key=MTAxMDoyMDIw&gateway=4016fa0500cd'
);

# This just displays the object but you can use what ever
# code you would like to work with the object here
print Dumper($api_object);    ## no critic (InputOutput::RequireCheckedSyscalls)

/*
 openjdk version "17.0.2" 2022-01-18

 Download the correct org.json jar version for your
 needs from: https://mvnrepository.com/artifact/org.json/json

 This example uses version 20220320 accessible here:
 https://repo1.maven.org/maven2/org/json/json/20220320/json-20220320.jar

 Instructions to run this program

 1. Put this code in a file named EKM.java
 2. Copy the downloaded org.json jar and EKM.java to the same directory
 3. Compile
  javac -cp .:./json-20220320.jar ./EKM.java
 4. Run
  java -cp .:./json-20220320.jar EKM
*/

//Import required classes
import java.net.*;
import java.io.*;
import org.json.*;

// Supress Warnings
@java.lang.SuppressWarnings({"java:S106", "java:S112", "java:S125"})

public class EKM {
    public static JSONObject callApi(String apiRequest) throws Exception {

        // This code accesses the apiRequest URL and converts
        // the contents to a usable JSON object

        URL url = new URL(apiRequest);
        URLConnection connection = url.openConnection();
        connection.setRequestProperty("Accept", "application/json");
        connection.setRequestProperty("Authorization", "Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk");
        BufferedReader in = new BufferedReader(
                                               new InputStreamReader(
                                                                     connection.getInputStream()));

        StringBuilder response = new StringBuilder();
        String inputLine;

        while ((inputLine = in.readLine()) != null)
            response.append(inputLine);

        in.close();

        return new JSONObject(response.toString());
    }

    public static void main(String[] args) throws Exception {
        /*
         Call callApi to create a usable
         object named apiObject from the API request URL.
         Put the API request URL in the call
         */
        JSONObject apiObject = EKM.callApi("https://api.ekmpush.com/api/trigger?key=MTAxMDoyMDIw&gateway=4016fa0500cd");


        // This just displays the object but you can use what ever
        // code you would like to work with the object here
        System.out.println(apiObject.toString(4));
        }
}

/*
* Requirements
* NodeJS: v16.14.2
* Axios:  0.27.2
*/

// Load modules
const axios = require('axios');

// This code accesses the apiRequest query
// and logs the response data or the error
;(async () => {
  try {
    const res = await axios.get(
        'https://api.ekmpush.com/api/trigger?key=MTAxMDoyMDIw&gateway=4016fa0500cd', {
          headers: {
            'Accept': 'application/json',
            // eslint-disable-next-line max-len
            'Authorization': 'Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk',
          }});
    const apiResData = res.data;
    console.log(JSON.stringify(apiResData, null, 2));
  } catch (error) {
    console.error(error.message);
  }
})();

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">

// The example function is called from the
// body tag when the page loads
function example(){

// Call the callApi function to create a usable
// object named apiObject from the API request URL.
// Put the API request URL in the call
callApi('https://api.ekmpush.com/api/trigger?key=MTAxMDoyMDIw&gateway=4016fa0500cd',function(apiObject){

      // This just displays the object in the result div
      // you can use what ever code you would like to work
      // with the object here
      document.getElementById("result").innerHTML = "<pre>"+JSON.stringify(apiObject, null, 4)+"</pre>";
      });

};

// This code accesses the apiRequest URL and converts
// the contents to a usable JSON object named apiObject
function callApi(apiRequest,callback) {
    var xhttp = new XMLHttpRequest();    
    xhttp.onreadystatechange = function() {
      if (xhttp.readyState == 4 && xhttp.status == 200) {
        var jsonObject = JSON.parse(xhttp.responseText);
        callback(jsonObject);
      }
    };
    xhttp.open("GET", apiRequest, true);
    xhttp.setRequestHeader("Accept", "application/json")
    xhttp.setRequestHeader("Authorization", "Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk")
    xhttp.send();
}
</script>

</head>
  <body onload="example()">
    <div id="result"> </div>
  </body>
</html>

Get trigger attributes for all the triggers owned by the specified gateway.

To retrieve all the triggers attributes owned by a gateway, all that is required is to change the GATEWAY_MAC, to your gateway mac:

https://api.ekmpush.com/api/trigger?key=MTAxMDoyMDIw&gateway=GATEWAY_MAC


The example below will return all the triggers attributes for the gateway 4016fa0500cd:

https://api.ekmpush.com/api/trigger?key=MTAxMDoyMDIw&gateway=4016fa0500cd

KEY DESCRIPTION
gateway (string) – The mac address of the gateway that owns the trigger.

Additionally, you have to add in the request headers:

HEADERS PARAMETERS

HEADERS DESCRIPTION
Accept Sets output type to JSON (i.e. application/json).
Authorization API Bearer Token to prove that the client is authorized to make the request (i.e. Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk)

Create Trigger

curl -i -X POST 'https://api.ekmpush.com/api/trigger?key=MTAxMDoyMDIw&gateway=4016fa0500cd' -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk" --data-raw '{"trigger": {"actions": [{"target": "meter", "target_id": "000350000900", "command": "setRelay", "params": {"relay": "relay_1", "status": "close", "duration": 1}}], "conditions": [{"type": "data", "field": "kWh_Tot", "source": "meter", "duration": "0", "source_id": "000350000900", "continuous": false, "hysteresis": "60", "threshold_test": "rise_eq", "threshold_value": "10"}], "enabled": true, "trigger_name": "Some trigger"}}'
# Ruby Version: 3.1.2

# Load required modules
require 'net/http'
require 'json'
require 'uri'

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call
def call_api(api_path, headers, data)
  uri = URI.parse("https://api.ekmpush.com#{api_path}")

  # Create the HTTP objects
  https = Net::HTTP.new(uri.host, uri.port)
  https.use_ssl = true
  request = Net::HTTP::Post.new(uri.request_uri, headers)
  request.body = data

  # Send the request
  response = https.request(request)
  JSON.parse(response.body)
end

# Set headers
req_header = {
  'Accept' => 'application/json',
  'Content-Type' => 'application/json',
  'Authorization' => 'Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk'
}

# Set Request JSON Object
req_data = '{
  "trigger": {
      "actions": [
          {
              "target": "meter",
              "target_id": "000350000900",
              "command": "setRelay",
              "params": {
                  "relay": "relay_1",
                  "status": "close",
                  "duration": 1
              }
          }
      ],
      "conditions": [
          {
              "type": "data",
              "field": "kWh_Tot",
              "source": "meter",
              "duration": "0",
              "source_id": "000350000900",
              "continuous": false,
              "hysteresis": "60",
              "threshold_test": "rise_eq",
              "threshold_value": "10"
          }
      ],
      "enabled": true,
      "trigger_name": "Some trigger"
  }
}'

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call
# URI only NOT URL - Do not include https://api.ekmpush.com
api_object = call_api('/api/trigger?key=MTAxMDoyMDIw&gateway=4016fa0500cd', req_header, req_data)

# This just displays the object but you can use what ever
# code you would like to work with the object here
require 'pp'
pp api_object

'''
Python version: 3.9.12
'''

# Required Python Modules
import urllib.request
import urllib.error
import urllib.parse
import json
import pprint

# This function accesses the api_request URL and converts
# the contents to a usable Python object and returns it
def call_api ( api_request, data):
    '''Make http request'''
    req = urllib.request.Request(api_request)
    req.add_header('Accept', 'application/json')
    req.add_header('Content-Type', 'application/json')
    req.add_header('Authorization', 'Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk')
    jsondata = json.dumps(data)
    json_bytes = jsondata.encode('utf-8')   # Needs to be bytes
    response = urllib.request.urlopen(req, json_bytes)
    response = response.read()
    json_object = json.loads(response.decode())
    return json_object

# Request JSON Object
req_data = {
  "trigger": {
      "actions": [
          {
              "target": "meter",
              "target_id": "000350000900",
              "command": "setRelay",
              "params": {
                  "relay": "relay_1",
                  "status": "close",
                  "duration": 1
              }
          }
      ],
      "conditions": [
          {
              "type": "data",
              "field": "kWh_Tot",
              "source": "meter",
              "duration": "0",
              "source_id": "000350000900",
              "continuous": False,
              "hysteresis": "60",
              "threshold_test": "rise_eq",
              "threshold_value": "10"
          }
      ],
      "enabled": True,
      "trigger_name": "Some trigger"
  }
}

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call
api_object = call_api("https://api.ekmpush.com/api/trigger"\
    "?key=MTAxMDoyMDIw&gateway=4016fa0500cd", req_data)

# This just displays the object but you can use what ever
# code you would like to work with the object here
pprint.pprint(api_object)

<?php
// PHP 8.0.17 (cli)

$reqData = '{
    "trigger": {
        "actions": [
            {
                "target": "meter",
                "target_id": "000350000900",
                "command": "setRelay",
                "params": {
                    "relay": "relay_1",
                    "status": "close",
                    "duration": 1
                }
            }
        ],
        "conditions": [
            {
                "type": "data",
                "field": "kWh_Tot",
                "source": "meter",
                "duration": "0",
                "source_id": "000350000900",
                "continuous": false,
                "hysteresis": "60",
                "threshold_test": "rise_eq",
                "threshold_value": "10"
            }
        ],
        "enabled": true,
        "trigger_name": "Some trigger"
    }
  }';

// Call the callApi function to create a usable
// object named $apiObject from the API request URL.
// Put the API request URL in the call
$apiObject=callApi('https://api.ekmpush.com/api/trigger?key=MTAxMDoyMDIw&gateway=4016fa0500cd', $reqData);

// This just displays the object but you can use what ever
// code you would like to work with the object here
var_dump($apiObject);

// This function accesses the apiRequest URL and converts
// the contents to a usable PHP object and returns it
function callApi ($apiRequest='', $reqData='') {    
    $opts = array('http' =>
        array(
            'method'  => 'POST',
            'header'  => "Content-Type: application/json\r\n".
            "Accept: application/json\r\n".
            "Authorization: Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk\r\n",
            'content' => $reqData
        )
    );
    $context = stream_context_create($opts);
    $json = file_get_contents($apiRequest, false, $context,);
    $jsonObject = json_decode($json, true);
    return ($jsonObject);
}

?>
#!/usr/bin/perl
# Perl version: v5.34
# CPAN.pm version 2.2
# Perl Modules Version:
# JSON: 4.05
# LWP::Protocol::https: 6.10
# LWP::UserAgent: 6.43
#
# OS Prerequisites
# UBUNTU
# apt install cpanminus
#
# Install Perl Modules
#       cpan LWP::UserAgent
#       cpan LWP::Protocol::https
#       cpan JSON

# Required Perl Modules
use strict;
use warnings;
use LWP::UserAgent;
use JSON;
use Data::Dumper;

# This function accesses the api_request URL and converts
# the contents to a usable Perl object and returns it
sub call_api {
    my $req_json = {
        'trigger'=> {
            'actions'=> [
                {
                    'target'=> 'meter',
                    'target_id'=> '000350000900',
                    'command'=> 'setRelay',
                    'params'=> {
                        'relay'=> 'relay_1',
                        'status'=> 'close',
                        'duration'=> 1
                    }
                }
            ],
            'conditions'=> [
                {
                    'type'=> 'data',
                    'field'=> 'kWh_Tot',
                    'source'=> 'meter',
                    'duration'=> '0',
                    'source_id'=> '000350000900',
                    'continuous'=> 'false',
                    'hysteresis'=> '60',
                    'threshold_test'=> 'rise_eq',
                    'threshold_value'=> '10'
                }
            ],
            'enabled'=> 'true',
            'trigger_name'=> 'Some trigger'
        }
    };
    my $api_request = shift;
    my $req         = HTTP::Request->new( 'POST', $api_request );
    $req->header( 'Accept' => 'application/json' );
    $req->header( 'Content-Type' => 'application/json' );
    $req->header( 'Authorization' => 'Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk' );
    $req->content( encode_json $req_json );
    my $lwp         = LWP::UserAgent->new;
    my $res         = $lwp->request($req);
    my $content     = $res->decoded_content();
    my $json_object = JSON->new->utf8->decode($content);
    return $json_object;
}

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call
my $api_object =
  call_api('https://api.ekmpush.com/api/trigger?key=MTAxMDoyMDIw&gateway=4016fa0500cd');

# This just displays the object but you can use what ever
# code you would like to work with the object here
print Dumper($api_object);    ## no critic (InputOutput::RequireCheckedSyscalls)


/*
 openjdk version "17.0.2" 2022-01-18

 Download the correct org.json jar version for your
 needs from: https://mvnrepository.com/artifact/org.json/json

 This example uses version 20220320 accessible here:
 https://repo1.maven.org/maven2/org/json/json/20220320/json-20220320.jar

 Instructions to run this program

 1. Put this code in a file named EKM.java
 2. Copy the downloaded org.json jar and EKM.java to the same directory
 3. Compile
  javac -cp .:./json-20220320.jar ./EKM.java
 4. Run
  java -cp .:./json-20220320.jar EKM
*/

//Import required classes
import java.net.*;
import java.io.*;
import org.json.*;

@java.lang.SuppressWarnings({"java:S106", "java:S112", "java:S125"})

public class EKM {
    public static JSONObject callApiPost(String apiRequest) throws Exception {

        // This code accesses the apiRequest URL and converts
        // the contents to a usable JSON object

        URL url = new URL(apiRequest);        
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("POST");
        connection.setRequestProperty( "Content-type", "application/json");
        connection.setRequestProperty("Accept", "application/json");
        connection.setRequestProperty( "Authorization", "Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk");
        connection.setDoOutput(true);

        String reqData = "{\"trigger\": { \"actions\": [ { \"target\": \"meter\", \"target_id\": \"000350000900\", \"command\": \"setRelay\", \"params\": { \"relay\": \"relay_1\", \"status\": \"close\", \"duration\": 1 } } ], \"conditions\": [ { \"type\": \"data\", \"field\": \"kWh_Tot\", \"source\": \"meter\", \"duration\": \"0\", \"source_id\": \"000350000900\", \"continuous\": false, \"hysteresis\": \"60\", \"threshold_test\": \"rise_eq\", \"threshold_value\": \"10\" } ], \"enabled\": true, \"trigger_name\": \"Some trigger\" }}";
        try(OutputStream os = connection.getOutputStream()) {
            byte[] input = reqData.getBytes("utf-8");
            os.write(input, 0, input.length);           
        }

        try(BufferedReader br = new BufferedReader(
            new InputStreamReader(connection.getInputStream(), "utf-8"))) {
                StringBuilder response = new StringBuilder();
                String responseLine = null;
                while ((responseLine = br.readLine()) != null) {
                    response.append(responseLine.trim());
                }
                return new JSONObject(response.toString());
            }        
    }
    public static JSONObject callApi(String apiRequest) throws Exception {
        // This code accesses the apiRequest URL and converts
        // the contents to a usable JSON object
        URL url = new URL(apiRequest);
        URLConnection yc = url.openConnection();
        BufferedReader in = new BufferedReader(new InputStreamReader(
                                    yc.getInputStream()));
        String inputLine;
        while ((inputLine = in.readLine()) != null) 
            System.out.println(inputLine);
        in.close();
        return new JSONObject(inputLine.toString());
    }

    public static void main(String[] args) throws Exception {
        /*
         Call callApiPost to create a usable
         object named apiObject from the API request URL.
         Put the API request URL in the call
         */
        JSONObject apiObject = EKM.callApiPost("https://api.ekmpush.com/api/trigger?key=MTAxMDoyMDIw&gateway=4016fa0500cd");


        // This just displays the object but you can use what ever
        // code you would like to work with the object here
        System.out.println(apiObject.toString(4));
        }
}

/*
* Requirements
* NodeJS: v16.14.2
* Axios:  0.27.2
*/

// Load modules
const axios = require('axios');

// This code accesses the apiRequest query
// and logs the response data or the error
;(async () => {
  try {
    const params = {
      'trigger': {
        'actions': [
          {
            'target': 'meter',
            'target_id': '000350000900',
            'command': 'setRelay',
            'params': {
              'relay': 'relay_1',
              'status': 'close',
              'duration': 1,
            },
          },
        ],
        'conditions': [
          {
            'type': 'data',
            'field': 'kWh_Tot',
            'source': 'meter',
            'duration': '0',
            'source_id': '000350000900',
            'continuous': false,
            'hysteresis': '60',
            'threshold_test': 'rise_eq',
            'threshold_value': '10',
          },
        ],
        'enabled': true,
        'trigger_name': 'Some trigger',
      },
    };
    const headers = {
      headers: {
        'Content-Type': 'application/json',
        'Accept': 'application/json',
        // eslint-disable-next-line max-len
        'Authorization': 'Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk',
      },
    };
    const url = 'https://api.ekmpush.com/api/trigger?key=MTAxMDoyMDIw&gateway=4016fa0500cd';
    const res = await axios.post(url, params, headers);
    const apiResData = res.data;
    console.log(JSON.stringify(apiResData, null, 2));
  } catch (error) {
    console.error(error.message);
  }
})();

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">

// The example function is called from the
// body tag when the page loads
function example(){

// Call the callApi function to create a usable
// object named apiObject from the API request URL.
// Put the API request URL in the call
callApi('https://api.ekmpush.com/api/trigger?key=MTAxMDoyMDIw&gateway=4016fa0500cd',function(apiObject){         
       // This just displays the object in the result div
       // you can use what ever code you would like to work
       // with the object here
       document.getElementById("result").innerHTML = "<pre>"+JSON.stringify(apiObject, null, 4)+"</pre>";
       });

};

// This code accesses the apiRequest URL and converts
// the contents to a usable JSON object named apiObject
function callApi(apiRequest,callback) {
    var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
      if (xhttp.readyState == 4 && xhttp.status == 200) {
        var jsonObject = JSON.parse(xhttp.responseText);
        callback(jsonObject);
      }
    };
    const params = {
      'trigger': {
        'actions': [
          {
            'target': 'meter',
            'target_id': '000350000900',
            'command': 'setRelay',
            'params': {
              'relay': 'relay_1',
              'status': 'close',
              'duration': 1,
            },
          },
        ],
        'conditions': [
          {
            'type': 'data',
            'field': 'kWh_Tot',
            'source': 'meter',
            'duration': '0',
            'source_id': '000350000900',
            'continuous': false,
            'hysteresis': '60',
            'threshold_test': 'rise_eq',
            'threshold_value': '10',
          },
        ],
        'enabled': true,
        'trigger_name': 'Some trigger',
      },
    };
    xhttp.open("POST", apiRequest, true);
    xhttp.setRequestHeader("Accept", "application/json")
    xhttp.setRequestHeader("Content-Type", "application/json")
    xhttp.setRequestHeader("Authorization", "Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk")
    xhttp.send(JSON.stringify(params));
}
</script>

</head>
  <body onload="example()">
    <div id="result"/>
  </body>
</html>

To create a new trigger you need to make a POST request and follow three (3) steps:

  1. Set the URL
  2. Set headers
  3. Pass the request JSON Object.

1. Set the URL

To start is required to set the gateway where you want to create the trigger:

https://api.ekmpush.com/api/trigger?key=MTAxMDoyMDIw&gateway=GATEWAY_MAC

The example below will create the trigger for the gateway 4016fa0500cd:

https://api.ekmpush.com/api/trigger?key=MTAxMDoyMDIw&gateway=4016fa0500cd


2. Set headers

You have to set the request headers:

HEADERS PARAMETERS

HEADERS DESCRIPTION
Accept Sets output type to JSON (i.e. application/json).
Content-Type Original media type of the resource (i.e. application/json).
Authorization API Bearer Token to prove that the client is authorized to make the request (i.e. Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk)


3. Pass the Request JSON Object

Also, you will need to pass the Request JSON Object:

{ "trigger": { "actions": [{}], "conditions": [{}], "enabled": true, "trigger_name": "Trigger Name" } }

JSON PARAMETERS

KEY DESCRIPTION
trigger (jsonobj) – The trigger attributes.
actions (jsonobj) List of actions.
conditions (jsonobj) List of conditions.
enabled (boolean) Enable trigger if true (default).
trigger_name (string) The name of the trigger.

Actions

{ "trigger": { "actions": [{}], "conditions": [{}], "enabled": true, "trigger_name": "Trigger Name" } }

Actions can be a meter setting command or an email notification.

See Device Settings API.

Email notifications have some limitations to limit potential abuse:

Example action: Send email notification

"actions": [ { "target": "gateway", "command": "sendEmail" } ]

Example action: Close relay one on meter 000350000900

"actions": [ { "target": "meter", "target_id": "000350000900", "command": "setRelay", "params": { "relay": "relay_1", "status": "close", "duration": 1 } } ]

Conditions

{ "trigger": { "actions": [{}], "conditions": [{}], "enabled": true, "trigger_name": "Trigger Name" } }

There are two types of conditions: Data and RRULE (recurrence rule). Data conditions are for testing field data values and RRULE conditions are for triggering actions at a specified time or recurrence.

Data Condition

KEY DESCRIPTION
type (string) Condition type (ie “data”).
source (string) The data source device type (ie “meter”, “iostack”)
source_id (string) The source id (ie meter address).
field (string) The name of the field to monitor.
threshold_value (float) The threshold value to compare with.
threshold_test (string) The threshold value test.
“==”: Data field value equals threshold value
“!=”: Data field value not equals threshold value
“>=”: Data field value greater than or equals threshold value
“<=”: Data field value less than or equals threshold value
“>”: Data field value greater than threshold value
“<”: Data field value less than threshold value
duration (float) Optional - Minimum duration in seconds of the test condition (default 0).
hysteresis (float) Optional - Minimum time in seconds before the next test (default 60).
continuous (boolean) Optional - Keep firing as long as condition is satisfied (default false).
tolerance (float) Optional - Floating point comparison tolerance/epsilon (default 1e-6).

Example:

"conditions": [ { "type": "data", "field": "kWh_Tot", "source": "meter", "duration": "0", "source_id": "000350000900", "continuous": False, "hysteresis": "60", "threshold_test": "rise_eq", "threshold_value": "10" } ]

RRULE Condition

KEY DESCRIPTION
type (string) Condition type (ie “rrule”).
rrule (string) Recurrence rule (see: iCalendar RFC-5545).

Note: All date-times are UTC (no offset).

Example RRULE condition: Starting on 7/2/2021 17:32 UTC, trigger every day at 00:35:00 UTC

"conditions": [ { "type": "rrule", "rrule": "DTSTART:20210702T173200\nRRULE:FREQ=DAILY;BYHOUR=0;BYMINUTE=35;BYSECOND=0" } ]

There are some decent open source RRULE generator demos you can use to build the RRULE strings:

Example

Knowing how the Request JSON Object works, we can create one for our example:

{ "trigger": { "actions": [ { "target": "meter", "target_id": "000350000900", "command": "setRelay", "params": { "relay": "relay_1", "status": "close", "duration": 1 } } ], "conditions": [ { "type": "data", "field": "kWh_Tot", "source": "meter", "duration": "0", "source_id": "000350000900", "continuous": false, "hysteresis": "60", "threshold_test": "rise_eq", "threshold_value": "10" } ], "enabled": true, "trigger_name": "Some trigger" } }

Response

In the response you will receive a JSON:

{ "trigger": { "trigger_uuid": "058f3dba18cb11edbdf452540000ef9a", "trigger_name": "Some trigger", "conditions": [ { "type": "data", "field": "kWh_Tot", "source": "meter", "duration": "0", "source_id": "000350000900", "continuous": false, "hysteresis": "60", "threshold_test": "rise_eq", "threshold_value": "10" } ], "actions": [ { "params": { "relay": "relay_1", "status": "close", "duration": 1 }, "target": "meter", "command": "setRelay", "target_id": "000350000900" } ], "extras": {}, "enabled": true, "created_at": "2022-08-10T16:39:36.904846-04:00", "updated_at": "2022-08-10T16:39:36.904846-04:00" } }

Read-only attributes:

KEY DESCRIPTION
trigger_uuid (string) A unique identifier.
created_at (string) The date/time of creation (ISO format).
updated_at (string) The date/time of last update/modify (ISO format).

Modify Trigger

curl -i -X PUT 'https://api.ekmpush.com/api/trigger?key=MTAxMDoyMDIw' -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk" --data-raw '{"trigger": {"trigger_name": "New trigger name", "trigger_uuid": "058f3dba18cb11edbdf452540000ef9a"}}'
# Ruby Version: 3.1.2

# Load required modules
require 'net/http'
require 'json'
require 'uri'

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call
def call_api(api_path, headers, data)
  uri = URI.parse("https://api.ekmpush.com#{api_path}")

  # Create the HTTP objects
  https = Net::HTTP.new(uri.host, uri.port)
  https.use_ssl = true
  request = Net::HTTP::Put.new(uri.request_uri, headers)
  request.body = data

  # Send the request
  response = https.request(request)
  JSON.parse(response.body)
end

# Set headers
req_header = {
  'Authorization' => 'Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk',
  'Content-Type' => 'application/json'
}

# Set Request JSON Object
req_data = '{
  "trigger": {
      "trigger_name": "New trigger name",
      "trigger_uuid": "058f3dba18cb11edbdf452540000ef9a"
  }
}'

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call
# URI only NOT URL - Do not include https://api.ekmpush.com
api_object = call_api('/api/trigger?key=MTAxMDoyMDIw&gateway=4016fa0500cd', req_header, req_data)

# This just displays the object but you can use what ever
# code you would like to work with the object here
require 'pp'
pp api_object

'''
Python version: 3.9.12
'''

# Required Python Modules
import urllib.request
import urllib.error
import urllib.parse
import json
import pprint

# This function accesses the api_request URL and converts
# the contents to a usable Python object and returns it
def call_api ( api_request, data):
    '''Make http request'''
    req = urllib.request.Request(api_request, method='PUT')
    req.add_header('Accept', 'application/json')
    req.add_header('Content-Type', 'application/json')
    req.add_header('Authorization', 'Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk')
    jsondata = json.dumps(data)
    json_bytes = jsondata.encode('utf-8')   # Needs to be bytes
    response = urllib.request.urlopen(req, json_bytes)
    response = response.read()
    json_object = json.loads(response.decode())
    return json_object

# Request JSON Object
req_data = {
  "trigger": {
      "trigger_name": "New trigger name",
      "trigger_uuid": "058f3dba18cb11edbdf452540000ef9a"
  }
}

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call
api_object = call_api("https://api.ekmpush.com/api/trigger"\
    "?key=MTAxMDoyMDIw&gateway=4016fa0500cd", req_data)

# This just displays the object but you can use what ever
# code you would like to work with the object here
pprint.pprint(api_object)

<?php
// PHP 8.0.17 (cli)

$reqData = '{
    "trigger": {
        "trigger_name": "New trigger name",
        "trigger_uuid": "058f3dba18cb11edbdf452540000ef9a"
    }
  }';

// Call the callApi function to create a usable
// object named $apiObject from the API request URL.
// Put the API request URL in the call
$apiObject=callApi('https://api.ekmpush.com/api/trigger?key=MTAxMDoyMDIw&gateway=4016fa0500cd', $reqData);

// This just displays the object but you can use what ever
// code you would like to work with the object here
var_dump($apiObject);

// This function accesses the apiRequest URL and converts
// the contents to a usable PHP object and returns it
function callApi ($apiRequest='', $reqData='') {    
    $opts = array('http' =>
        array(
            'method'  => 'PUT',
            'header'  => "Content-Type: application/json\r\n".
            "Accept: application/json\r\n".
            "Authorization: Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk\r\n",
            'content' => $reqData
        )
    );
    $context = stream_context_create($opts);
    $json = file_get_contents($apiRequest, false, $context,);
    $jsonObject = json_decode($json, true);
    return ($jsonObject);
}

?>
#!/usr/bin/perl
# Perl version: v5.34
# CPAN.pm version 2.2
# Perl Modules Version:
# JSON: 4.05
# LWP::Protocol::https: 6.10
# LWP::UserAgent: 6.43
#
# OS Prerequisites
# UBUNTU
# apt install cpanminus
#
# Install Perl Modules
#       cpan LWP::UserAgent
#       cpan LWP::Protocol::https
#       cpan JSON

# Required Perl Modules
use strict;
use warnings;
use LWP::UserAgent;
use JSON;
use Data::Dumper;

# This function accesses the api_request URL and converts
# the contents to a usable Perl object and returns it
sub call_api {
    my $req_json = {
        'trigger'=> {
            'trigger_name'=> 'New trigger name',
            'trigger_uuid'=> '058f3dba18cb11edbdf452540000ef9a'
        }
    };
    my $api_request = shift;
    my $req         = HTTP::Request->new( 'PUT', $api_request );
    $req->header( 'Accept' => 'application/json' );
    $req->header( 'Content-Type' => 'application/json' );
    $req->header( 'Authorization' => 'Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk' );
    $req->content( encode_json $req_json );
    my $lwp         = LWP::UserAgent->new;
    my $res         = $lwp->request($req);
    my $content     = $res->decoded_content();
    my $json_object = JSON->new->utf8->decode($content);
    return $json_object;
}

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call
my $api_object =
  call_api('https://api.ekmpush.com/api/trigger?key=MTAxMDoyMDIw&gateway=4016fa0500cd');

# This just displays the object but you can use what ever
# code you would like to work with the object here
print Dumper($api_object);    ## no critic (InputOutput::RequireCheckedSyscalls)


/*
 openjdk version "17.0.2" 2022-01-18

 Download the correct org.json jar version for your
 needs from: https://mvnrepository.com/artifact/org.json/json

 This example uses version 20220320 accessible here:
 https://repo1.maven.org/maven2/org/json/json/20220320/json-20220320.jar

 Instructions to run this program

 1. Put this code in a file named EKM.java
 2. Copy the downloaded org.json jar and EKM.java to the same directory
 3. Compile
  javac -cp .:./json-20220320.jar ./EKM.java
 4. Run
  java -cp .:./json-20220320.jar EKM
*/

//Import required classes
import java.net.*;
import java.io.*;
import org.json.*;

@java.lang.SuppressWarnings({"java:S106", "java:S112", "java:S125"})

public class EKM {
    public static JSONObject callApiPost(String apiRequest) throws Exception {

        // This code accesses the apiRequest URL and converts
        // the contents to a usable JSON object

        URL url = new URL(apiRequest);        
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("PUT");
        connection.setRequestProperty( "Content-type", "application/json");
        connection.setRequestProperty("Accept", "application/json");
        connection.setRequestProperty( "Authorization", "Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk");
        connection.setDoOutput(true);

        String reqData = "{\"trigger\": {\"trigger_name\": \"New trigger name\", \"trigger_uuid\": \"058f3dba18cb11edbdf452540000ef9a\"}}";
        try(OutputStream os = connection.getOutputStream()) {
            byte[] input = reqData.getBytes("utf-8");
            os.write(input, 0, input.length);           
        }

        try(BufferedReader br = new BufferedReader(
            new InputStreamReader(connection.getInputStream(), "utf-8"))) {
                StringBuilder response = new StringBuilder();
                String responseLine = null;
                while ((responseLine = br.readLine()) != null) {
                    response.append(responseLine.trim());
                }
                return new JSONObject(response.toString());
            }        
    }
    public static JSONObject callApi(String apiRequest) throws Exception {
        // This code accesses the apiRequest URL and converts
        // the contents to a usable JSON object
        URL url = new URL(apiRequest);
        URLConnection yc = url.openConnection();
        BufferedReader in = new BufferedReader(new InputStreamReader(
                                    yc.getInputStream()));
        String inputLine;
        while ((inputLine = in.readLine()) != null) 
            System.out.println(inputLine);
        in.close();
        return new JSONObject(inputLine.toString());
    }

    public static void main(String[] args) throws Exception {
        /*
         Call callApiPost to create a usable
         object named apiObject from the API request URL.
         Put the API request URL in the call
         */
        JSONObject apiObject = EKM.callApiPost("https://api.ekmpush.com/api/trigger?key=MTAxMDoyMDIw&gateway=4016fa0500cd");


        // This just displays the object but you can use what ever
        // code you would like to work with the object here
        System.out.println(apiObject.toString(4));
        }
}

/*
* Requirements
* NodeJS: v16.14.2
* Axios:  0.27.2
*/

// Load modules
const axios = require('axios');

// This code accesses the apiRequest query
// and logs the response data or the error
;(async () => {
  try {
    const params = {
      'trigger': {
        'trigger_name': 'New trigger name',
        'trigger_uuid': '058f3dba18cb11edbdf452540000ef9a',
      },
    };
    const headers = {
      headers: {
        'Content-Type': 'application/json',
        'Accept': 'application/json',
        // eslint-disable-next-line max-len
        'Authorization': 'Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk',
      },
    };
    const url = 'https://api.ekmpush.com/api/trigger?key=MTAxMDoyMDIw&gateway=4016fa0500cd';
    const res = await axios.put(url, params, headers);
    const apiResData = res.data;
    console.log(JSON.stringify(apiResData, null, 2));
  } catch (error) {
    console.error(error.message);
  }
})();

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">

// The example function is called from the
// body tag when the page loads
function example(){

// Call the callApi function to create a usable
// object named apiObject from the API request URL.
// Put the API request URL in the call
callApi('https://api.ekmpush.com/api/trigger?key=MTAxMDoyMDIw&gateway=4016fa0500cd',function(apiObject){         
       // This just displays the object in the result div
       // you can use what ever code you would like to work
       // with the object here
       document.getElementById("result").innerHTML = "<pre>"+JSON.stringify(apiObject, null, 4)+"</pre>";
       });

};

// This code accesses the apiRequest URL and converts
// the contents to a usable JSON object named apiObject
function callApi(apiRequest,callback) {
    var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
      if (xhttp.readyState == 4 && xhttp.status == 200) {
        var jsonObject = JSON.parse(xhttp.responseText);
        callback(jsonObject);
      }
    };
    const params = {
      "trigger": {
          "trigger_name": "New trigger name",
          "trigger_uuid": "058f3dba18cb11edbdf452540000ef9a",
      },
    };
    xhttp.open("PUT", apiRequest, true);
    xhttp.setRequestHeader("Accept", "application/json")
    xhttp.setRequestHeader("Content-Type", "application/json")
    xhttp.setRequestHeader("Authorization", "Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk")
    xhttp.send(JSON.stringify(params));
}
</script>

</head>
  <body onload="example()">
    <div id="result"/>
  </body>
</html>

To modify an existing trigger you will need to do a PUT request and follow the next steps:

  1. Set the URL
  2. Set the headers
  3. Set the Request JSON Object.

1. Set the URL

URL to use: https://api.ekmpush.com/api/trigger?key=MTAxMDoyMDIw


2. Set the headers

You have to set the request headers:

HEADERS PARAMETERS

HEADERS DESCRIPTION
Accept Sets output type to JSON (i.e. application/json).
“Content-Type” Original media type of the resource (i.e. application/json).
Authorization API Bearer Token to prove that the client is authorized to make the request (i.e. Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk).


3. Set the Request JSON Object

Also, you will need to set the Request JSON Object with the next structure:

{ "trigger": { "trigger_name": "New trigger name", "trigger_uuid": "058f3dba18cb11edbdf452540000ef9a" } }

JSON PARAMETERS

KEY DESCRIPTION
trigger (jsonobj) – The trigger attributes.
trigger_name (string) The new name of the trigger.
trigger_uuid (string) The UUID of the trigger you want to change.

Delete Trigger

curl -i -X DELETE 'https://api.ekmpush.com/api/trigger?key=MTAxMDoyMDIw' -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk" --data-raw '{"trigger_uuid": "058f3dba18cb11edbdf452540000ef9a"}'
# Ruby Version: 3.1.2

# Load required modules
require 'net/http'
require 'json'
require 'uri'

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call
def call_api(api_path, headers, data)
  uri = URI.parse("https://api.ekmpush.com#{api_path}")

  # Create the HTTP objects
  https = Net::HTTP.new(uri.host, uri.port)
  https.use_ssl = true
  request = Net::HTTP::Delete.new(uri.request_uri, headers)
  request.body = data

  # Send the request
  response = https.request(request)
  JSON.parse(response.body)
end

# Set headers
req_header = {
  'Authorization' => 'Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk',
  'Content-Type' => 'application/json'
}

# Set Request JSON Object
req_data = '{
  "trigger_uuid": "058f3dba18cb11edbdf452540000ef9a"
}'

# Call the call_api method to create a usable
# object named api_object from the API request URI
# Put the API request URI in the call
# URI only NOT URL - Do not include https://api.ekmpush.com
api_object = call_api('/api/trigger?key=MTAxMDoyMDIw&gateway=4016fa0500cd', req_header, req_data)

# This just displays the object but you can use what ever
# code you would like to work with the object here
require 'pp'
pp api_object

'''
Python version: 3.9.12
'''

# Required Python Modules
import urllib.request
import urllib.error
import urllib.parse
import json
import pprint

# This function accesses the api_request URL and converts
# the contents to a usable Python object and returns it
def call_api ( api_request, data):
    '''Make http request'''
    req = urllib.request.Request(api_request, method='DELETE')
    req.add_header('Accept', 'application/json')
    req.add_header('Content-Type', 'application/json')
    req.add_header('Authorization', 'Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk')
    jsondata = json.dumps(data)
    json_bytes = jsondata.encode('utf-8')   # Needs to be bytes
    response = urllib.request.urlopen(req, json_bytes)
    response = response.read()
    json_object = json.loads(response.decode())
    return json_object

# Request JSON Object
req_data = {
  "trigger_uuid": "058f3dba18cb11edbdf452540000ef9a"
}

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call
api_object = call_api("https://api.ekmpush.com/api/trigger"\
    "?key=MTAxMDoyMDIw&gateway=4016fa0500cd", req_data)

# This just displays the object but you can use what ever
# code you would like to work with the object here
pprint.pprint(api_object)

<?php
// PHP 8.0.17 (cli)

$reqData = '{
    "trigger_uuid": "058f3dba18cb11edbdf452540000ef9a"
  }';

// Call the callApi function to create a usable
// object named $apiObject from the API request URL.
// Put the API request URL in the call
$apiObject=callApi('https://api.ekmpush.com/api/trigger?key=MTAxMDoyMDIw&gateway=4016fa0500cd', $reqData);

// This just displays the object but you can use what ever
// code you would like to work with the object here
var_dump($apiObject);

// This function accesses the apiRequest URL and converts
// the contents to a usable PHP object and returns it
function callApi ($apiRequest='', $reqData='') {    
    $opts = array('http' =>
        array(
            'method'  => 'DELETE',
            'header'  => "Content-Type: application/json\r\n".
            "Accept: application/json\r\n".
            "Authorization: Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk\r\n",
            'content' => $reqData
        )
    );
    $context = stream_context_create($opts);
    $json = file_get_contents($apiRequest, false, $context,);
    $jsonObject = json_decode($json, true);
    return ($jsonObject);
}

?>
#!/usr/bin/perl
# Perl version: v5.34
# CPAN.pm version 2.2
# Perl Modules Version:
# JSON: 4.05
# LWP::Protocol::https: 6.10
# LWP::UserAgent: 6.43
#
# OS Prerequisites
# UBUNTU
# apt install cpanminus
#
# Install Perl Modules
#       cpan LWP::UserAgent
#       cpan LWP::Protocol::https
#       cpan JSON

# Required Perl Modules
use strict;
use warnings;
use LWP::UserAgent;
use JSON;
use Data::Dumper;

# This function accesses the api_request URL and converts
# the contents to a usable Perl object and returns it
sub call_api {
    my $req_json = {
        'trigger_uuid'=> '058f3dba18cb11edbdf452540000ef9a'
    };
    my $api_request = shift;
    my $req         = HTTP::Request->new( 'DELETE', $api_request );
    $req->header( 'Accept' => 'application/json' );
    $req->header( 'Content-Type' => 'application/json' );
    $req->header( 'Authorization' => 'Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk' );
    $req->content( encode_json $req_json );
    my $lwp         = LWP::UserAgent->new;
    my $res         = $lwp->request($req);
    my $content     = $res->decoded_content();
    my $json_object = JSON->new->utf8->decode($content);
    return $json_object;
}

# Call the call_api function to create a usable
# object named api_object from the API request URL.
# Put the API request URL in the call
my $api_object =
  call_api('https://api.ekmpush.com/api/trigger?key=MTAxMDoyMDIw&gateway=4016fa0500cd');

# This just displays the object but you can use what ever
# code you would like to work with the object here
print Dumper($api_object);    ## no critic (InputOutput::RequireCheckedSyscalls)


/*
 openjdk version "17.0.2" 2022-01-18

 Download the correct org.json jar version for your
 needs from: https://mvnrepository.com/artifact/org.json/json

 This example uses version 20220320 accessible here:
 https://repo1.maven.org/maven2/org/json/json/20220320/json-20220320.jar

 Instructions to run this program

 1. Put this code in a file named EKM.java
 2. Copy the downloaded org.json jar and EKM.java to the same directory
 3. Compile
  javac -cp .:./json-20220320.jar ./EKM.java
 4. Run
  java -cp .:./json-20220320.jar EKM
*/

//Import required classes
import java.net.*;
import java.io.*;
import org.json.*;

@java.lang.SuppressWarnings({"java:S106", "java:S112", "java:S125"})

public class EKM {
    public static JSONObject callApiPost(String apiRequest) throws Exception {

        // This code accesses the apiRequest URL and converts
        // the contents to a usable JSON object

        URL url = new URL(apiRequest);        
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("DELETE");
        connection.setRequestProperty( "Content-type", "application/json");
        connection.setRequestProperty("Accept", "application/json");
        connection.setRequestProperty( "Authorization", "Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk");
        connection.setDoOutput(true);

        String reqData = "{\"trigger_uuid\": \"058f3dba18cb11edbdf452540000ef9a\"}";
        try(OutputStream os = connection.getOutputStream()) {
            byte[] input = reqData.getBytes("utf-8");
            os.write(input, 0, input.length);
        }

        try(BufferedReader br = new BufferedReader(
            new InputStreamReader(connection.getInputStream(), "utf-8"))) {
                StringBuilder response = new StringBuilder();
                String responseLine = null;
                while ((responseLine = br.readLine()) != null) {
                    response.append(responseLine.trim());
                }
                return new JSONObject(response.toString());
            }        
    }
    public static JSONObject callApi(String apiRequest) throws Exception {
        // This code accesses the apiRequest URL and converts
        // the contents to a usable JSON object
        URL url = new URL(apiRequest);
        URLConnection yc = url.openConnection();
        BufferedReader in = new BufferedReader(new InputStreamReader(
                                    yc.getInputStream()));
        String inputLine;
        while ((inputLine = in.readLine()) != null) 
            System.out.println(inputLine);
        in.close();
        return new JSONObject(inputLine.toString());
    }

    public static void main(String[] args) throws Exception {
        /*
         Call callApiPost to create a usable
         object named apiObject from the API request URL.
         Put the API request URL in the call
         */
        JSONObject apiObject = EKM.callApiPost("https://api.ekmpush.com/api/trigger?key=MTAxMDoyMDIw&gateway=4016fa0500cd");


        // This just displays the object but you can use what ever
        // code you would like to work with the object here
        System.out.println(apiObject.toString(4));
        }
}
/*
* Requirements
* NodeJS: v16.14.2
* Axios:  0.27.2
*/

// Load modules
const axios = require('axios');

// This code accesses the apiRequest query
// and logs the response data or the error
;(async () => {
  try {
    const params = {
      'trigger_uuid': '058f3dba18cb11edbdf452540000ef9a',
    };
    const headers = {
      'Content-Type': 'application/json',
      'Accept': 'application/json',
      // eslint-disable-next-line max-len
      'Authorization': 'Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk',
    };
    const url = 'https://api.ekmpush.com/api/trigger?key=MTAxMDoyMDIw&gateway=4016fa0500cd';
    const res = await axios.delete(url, {data: params, headers: headers});
    const apiResData = res.data;
    console.log(JSON.stringify(apiResData, null, 2));
  } catch (error) {
    console.error(error.message);
  }
})();

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">

// The example function is called from the
// body tag when the page loads
function example(){

// Call the callApi function to create a usable
// object named apiObject from the API request URL.
// Put the API request URL in the call
callApi('https://api.ekmpush.com/api/trigger?key=MTAxMDoyMDIw&gateway=4016fa0500cd',function(apiObject){         
       // This just displays the object in the result div
       // you can use what ever code you would like to work
       // with the object here
       document.getElementById("result").innerHTML = "<pre>"+JSON.stringify(apiObject, null, 4)+"</pre>";
       });

};

// This code accesses the apiRequest URL and converts
// the contents to a usable JSON object named apiObject
function callApi(apiRequest,callback) {
    var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
      if (xhttp.readyState == 4 && xhttp.status == 200) {
        var jsonObject = JSON.parse(xhttp.responseText);
        callback(jsonObject);
      }
    };
    const params = {
      "trigger_uuid": "058f3dba18cb11edbdf452540000ef9a",
    };
    xhttp.open("DELETE", apiRequest, true);
    xhttp.setRequestHeader("Accept", "application/json")
    xhttp.setRequestHeader("Content-Type", "application/json")
    xhttp.setRequestHeader("Authorization", "Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk")
    xhttp.send(JSON.stringify(params));
}
</script>

</head>
  <body onload="example()">
    <div id="result"/>
  </body>
</html>

To delete an existing trigger you will need to do a DELETE request and follow the next steps:

  1. Set the URL
  2. Set the headers
  3. Set the JSON Object

1. Set the URL

URL to use: https://api.ekmpush.com/api/trigger?key=MTAxMDoyMDIw


2. Set the headers

You have to set the request headers:

HEADERS PARAMETERS

HEADERS DESCRIPTION
Accept Sets output type to JSON (i.e. application/json).
“Content-Type” Original media type of the resource (i.e. application/json).
Authorization API Bearer Token to prove that the client is authorized to make the request (i.e. Bearer BZTdu8_5iw62WQuDg4OHIMhG7mcEqJu8VrzHSywCkPk).


3. Set the JSON Object

Also, you will need to set the JSON Object with the UUID of the trigger to delete:

{ "trigger_uuid": "058f3dba18cb11edbdf452540000ef9a" }

JSON PARAMETERS

KEY DESCRIPTION
trigger_uuid (string) – The trigger UUID to remove.

Summary API

Click here to go to Summary Documentation

Our Summary API takes every Real-Time read, over 15 minute time periods, and summarizes them into single 15 minute summaries. We store this data forever to provide a long term historical dataset for each meter. Our system can then combine these summaries together to summarize hours, days, weeks, and months. This dataset is often the best way to get historical values like kWh, pulse counts, etc. It also provides averages, min. and max. values, difference, and more. We make this data available to you via our Summary API in a very similar way to our Real-Time API.

You can use the Summary API definition to access the data you need, from 15 minutes to years of data. We have gone to great lengths to provide this data for free in order to add value to our metering systems. The Summary API, the Real-Time API, great affordable hardware, and scalable access to your data are all components of the most powerful, and highest value metering system available in the world.

We also have a Summary API Request Builder Tool found here: Summary API Builder

RS-485 Communications

Click here to go to RS-485 Documentation

This section is for developers, or individuals, that want to communicate with their EKM Meters directly using their own software or embedded solution.

The code examples found in this section are in the simplest possible method to get you started. You are welcome to make them more robust.

First we start you out just connecting to the meter. You will find there is a very simple command line process to help you get started.

After that we cover the CRC method required for most communication to the meter.

Then we put it all together, in a simple test script that will show reads, and also open and close the relays.

Last we cover how to convert the 255 character strings that the meter responds with to a usable array containing field names and their values. It is our hope that after you go through these steps you will have all the information you need, to build whatever tools you like to access the meter.

Our meters use an IEC 62056-21 communication standard that has been optimized for our own needs. We are more than happy to share this with you. With this you can write your own software or embedded solution to access your meter data.

IEC 62056 is a set of standards for Electricity metering data exchange by International Electrotechnical Commission.

To learn more about the IEC 62056 standard click the button below to visit the WikiPedia website.

Additional PDF docs are available:

v.3 Meter Settings Protocol

v.3 Meter Parsing

v.4/v.5 Meter Settings Protocol

v.4/v.5 Meter Parsing

v.4/v.5 Meter Alternate Modbus Protocol

If you are coding in Python you can also make use of our ekmmeters.py API.

Status Codes

EKM uses conventional HTTP response codes in addition to our API Status Codes to indicate the success or failure of an API request. In general, codes in the 2xx range indicate success, codes in the 4xx range indicate an error that failed given the information provided, and codes in the 5xx range indicate an error with EKM’s servers (these are rare).

The EKM API uses the following API specific Status codes:

API Status Code Meaning
1000 There is not data for: {meters}
1001 There is not data for: {meters} between ${startDate} and ${endDate}
1002 There is not data for: {meters} This meter first reported on:
1003 There is not data for: {meters} This meter last reported on:
1004 Timezone is not supported for this date range request
1100 All invalid query requests
1101 Invalid format
1102 Invalid value
1103 Invalid parameter
1200 Found invalid meter: {meter} for key: MTAxMDoyMDIw
1300 Oops! It looks like there was an unexpected error. Try checking your query for issues or hold tight while we see what we can do. This error has been reported.

The EKM API also uses the following HTTP Status codes:

HTTP Status Code Meaning
200 OK – The request succeeded.
400 Bad Request – The server could not understand the request due to invalid syntax.
401 Unauthorized – Although the HTTP standard specifies “unauthorized”, semantically this response means “unauthenticated”. That is, the client must authenticate itself to get the requested response.
403 Forbidden – The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client’s identity is known to the server.
404 Not Found – The server can not find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web.
429 Too Many Requests – The user has sent too many requests in a given amount of time (“rate limiting”).
500 Internal Server Error – The server has encountered a situation it does not know how to handle.
501 Not Implemented – The Vertical Bar otherwise known as “pipe” request method is not supported by the server and cannot be handled. The only methods that servers are required to support (and therefore that must not return this code) are GET and HEAD.
502 Bad Gateway – This error response means that the server, while working as a gateway to get a response needed to handle the request, got an invalid response.
503 Service Unavailable – The server is not ready to handle the request. Common causes are a server that is down for maintenance or that is overloaded. Note that together with this response, a user-friendly page explaining the problem should be sent. This response should be used for temporary conditions and the Retry-After HTTP header should, if possible, contain the estimated time before the recovery of the service. The webmaster must also take care about the caching-related headers that are sent along with this response, as these temporary condition responses should usually not be cached.
504 Gateway Timeout – This error response is given when the server is acting as a gateway and cannot get a response in time.
505 HTTP Version Not Supported – The HTTP version used in the request is not supported by the server.
506 Variant Also Negotiates – The server has an internal configuration error: the chosen variant resource is configured to engage in transparent content negotiation itself, and is therefore not a proper end point in the negotiation process.
510 Not Extended – Further extensions to the request are required for the server to fulfill it.
511 Network Authentication Required – Indicates that the client needs to authenticate to gain network access.