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/ioStack 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, Perl, 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/ioStack individually, and keys can be created to provide access to sub groups of meters/ioStacks upon request. These secondary keys can be used to share single meters/ioStacks, or a subset of meters/ioStacks, without sharing access to all meters/ioStacks in an account. For example, if you are a landlord with multiple rentals and meters/ioStacks, you could share specific meter/ioStack 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 1,000 latest meter readings for each of your meters/IOStack devices. If your device is being read once per minute, the data will be made available once per minute, per device. Whether you have one device or 10,000 devices, 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:
Account API
This API provides information for accounts and devices owned by the account.
Get information for the specified target, which can be account, gateway, meter or ioStack.
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.
HTTPS Request
HTTPS Request
curl -s "https://api.ekmpush.com/account/api/meter?key=MTAxMDoyMDIw&id=000350000900&state=true&indent=2"
# 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("https://api.ekmpush.com/account/api#{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 https://api.ekmpush.com
api_object = call_api('/meter?key=MTAxMDoyMDIw&id=000350000900&state=true&indent=2')
# 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("https://api.ekmpush.com/account/api/meter"\
"?key=MTAxMDoyMDIw&id=000350000900&state=true&indent=2")
# 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/account/api/meter?key=MTAxMDoyMDIw&id=000350000900&state=true&indent=2');
// 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(
'https://api.ekmpush.com/account/api/meter?key=MTAxMDoyMDIw&id=000350000900&state=true&indent=2'
);
# 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("https://api.ekmpush.com/account/api/meter?key=MTAxMDoyMDIw&id=000350000900&state=true&indent=2");
// 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');
const apiClient = axios.create({
baseURL: 'https://api.ekmpush.com/account/api/',
timeout: 1000 * 15,
})
// This code accesses the apiRequest query
// and logs the response data or the error
;(async () => {
try {
const res = await apiClient.get(
'meter?key=MTAxMDoyMDIw&id=000350000900&state=true&indent=2');
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/account/api/meter?key=MTAxMDoyMDIw&id=000350000900&state=true&indent=2', 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 example digs deaper into the JSON and displays the first
// kwh_tot value for the first read of the first meter
readmeter_json = apiObject['readmeter'];
readset_json = readmeter_json['ReadSet'];
readset_0_json = readset_json[0];
readdata_json = readset_0_json['ReadData'];
readdata_0_json = readdata_json[0];
});
};
// 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"> </div>
</body>
</html>
The above example returns the following results:
{
"meters": [
{
"key": "PkUzNEI6ZjI6eCFYaQVyeBO",
"key_type": "meter",
"address": "000350000900",
"version": "v4",
"name": "",
"read_interval": 60000,
"model": "1024",
"model_name": "Omnimeter Pulse v.4C",
"state": {
"timestamp": "2022-07-18T17:39:36.944000+00:00",
"kwh": 112587.14,
"watts": 9818.0,
"pulse_1": 1007,
"pulse_2": 999,
"pulse_3": 1010
}
}
]
}
{"meters"=>
[{"key"=>"PkUzNEI6ZjI6eCFYaQVyeBO",
"key_type"=>"meter",
"address"=>"000350000900",
"version"=>"v4",
"name"=>"",
"read_interval"=>60000,
"model"=>"1024",
"model_name"=>"Omnimeter Pulse v.4C",
"state"=>{"timestamp"=>"2022-07-18T17:40:37.340000+00:00", "kwh"=>112587.3, "watts"=>9828.0, "pulse_1"=>1007, "pulse_2"=>999, "pulse_3"=>1010}}]}
{'meters': [{'address': '000350000900',
'key': 'PkUzNEI6ZjI6eCFYaQVyeBO',
'key_type': 'meter',
'model': '1024',
'model_name': 'Omnimeter Pulse v.4C',
'name': '',
'read_interval': 60000,
'state': {'kwh': 112588.17,
'pulse_1': 1007,
'pulse_2': 999,
'pulse_3': 1010,
'timestamp': '2022-07-18T17:45:53.693000+00:00',
'watts': 9776.0},
'version': 'v4'}]}
object(stdClass)#3 (1) {
["meters"]=>
array(1) {
[0]=>
object(stdClass)#1 (9) {
["key"]=>
string(23) "PkUzNEI6ZjI6eCFYaQVyeBO"
["key_type"]=>
string(5) "meter"
["address"]=>
string(12) "000350000900"
["version"]=>
string(2) "v4"
["name"]=>
string(0) ""
["read_interval"]=>
int(60000)
["model"]=>
string(4) "1024"
["model_name"]=>
string(20) "Omnimeter Pulse v.4C"
["state"]=>
object(stdClass)#2 (6) {
["timestamp"]=>
string(32) "2022-07-18T17:46:55.947000+00:00"
["kwh"]=>
float(112588.34)
["watts"]=>
float(9776)
["pulse_1"]=>
int(1007)
["pulse_2"]=>
int(999)
["pulse_3"]=>
int(1010)
}
}
}
}
$VAR1 = {
'meters' => [
{
'name' => '',
'key_type' => 'meter',
'model' => '1024',
'version' => 'v4',
'state' => {
'pulse_3' => 1010,
'pulse_1' => 1007,
'timestamp' => '2022-07-18T17:50:00.667000+00:00',
'pulse_2' => 999,
'watts' => '9688',
'kwh' => '112588.84'
},
'read_interval' => 60000,
'address' => '000350000900',
'model_name' => 'Omnimeter Pulse v.4C',
'key' => 'PkUzNEI6ZjI6eCFYaQVyeBO'
}
]
};
{"meters": [{
"read_interval": 60000,
"address": "000350000900",
"key_type": "meter",
"model_name": "Omnimeter Pulse v.4C",
"name": "",
"model": "1024",
"state": {
"watts": 9734,
"pulse_1": 1007,
"pulse_2": 999,
"pulse_3": 1010,
"kwh": 112589.18,
"timestamp": "2022-07-18T17:52:05.096000+00:00"
},
"version": "v4",
"key": "PkUzNEI6ZjI6eCFYaQVyeBO"
}]}
{
"meters": [
{
"key": "PkUzNEI6ZjI6eCFYaQVyeBO",
"key_type": "meter",
"address": "000350000900",
"version": "v4",
"name": "",
"read_interval": 60000,
"model": "1024",
"model_name": "Omnimeter Pulse v.4C",
"state": {
"timestamp": "2022-07-18T17:54:07.057000+00:00",
"kwh": 112589.5,
"watts": 9766,
"pulse_1": 1007,
"pulse_2": 999,
"pulse_3": 1010
}
}
]
}
{
"meters": [
{
"key": "PkUzNEI6ZjI6eCFYaQVyeBO",
"key_type": "meter",
"address": "000350000900",
"version": "v4",
"name": "",
"read_interval": 60000,
"model": "1024",
"model_name": "Omnimeter Pulse v.4C",
"state": {
"timestamp": "2022-07-18T17:56:12.372000+00:00",
"kwh": 112589.86,
"watts": 10342,
"pulse_1": 1007,
"pulse_2": 999,
"pulse_3": 1010
}
}
]
}
All https requests will begin with the following information in the https address:
https://api.ekmpush.com/account/api/TARGET?
Depending on what you need you will have to change the TARGET for account, gateway, meter or ioStack.
The information that you provide, such as your EKM Push Key (i.e. MTAxMDoyMDIw), and all other associated information will follow the beginning https address.
Example below of what a typical https address will look like:
https://api.ekmpush.com/account/api/meter?key=MTAxMDoyMDIw&id=000350000900&state=true&indent=2
Example of the information that is in a typical https call is as follows:
HTTPS ADDRESS | DESCRIPTION |
---|---|
https://api.ekmpush.com/account/api/ | Beginning of the https address. |
meter | Target for calling the meter. |
key | Parameter for calling the key |
MTAxMDoyMDIw | EKM Push authorization key or Gateway Key. |
id | Parameter expecting the meter address. |
000350000900 | The meter address. There can be multiple ids. |
state | Parameter for include state data, such as last kWh meter reading. |
true | True to show state data. |
indent | Parameter for pretty print the JSON output. |
2 | Number of spaces to indent. |
Here is an example URL:
https://api.ekmpush.com/account/api/meter?key=MTAxMDoyMDIw&id=000350000900
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/account/api/account?key=MTAxMDoyMDIw&indent=
INDENT_NUMBER
To print the JSON with 4 spaces of indentation, your https address should look like the following:
https://api.ekmpush.com/account/api/account?key=MTAxMDoyMDIw&indent=4
URL PARAMETERS
PARAMETER | DESCRIPTION |
---|---|
indent | (int) – optional - pretty print the json output using the indent value. |
Target: account
Get information for the specified account.
The EKM Push Key is your own Authorization Key that you received for your Push Account. In the following examples of this API document, we will be using the following key MTAxMDoyMDIw in all of our https calls. You will need to change the example key, of MTAxMDoyMDIw, with your own private key in order to access your meters/ioStacks that you have associated with your account. Also you could use the Gateway Key instead of the EKM Push Key for more restricted access.
Get account information
HTTPS Request
curl -s "https://api.ekmpush.com/account/api/account?key=MTAxMDoyMDIw"
# 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("https://api.ekmpush.com/account/api/#{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 https://api.ekmpush.com
api_object = call_api('/account?key=MTAxMDoyMDIw')
# 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("https://api.ekmpush.com/account/api/account?key=MTAxMDoyMDIw")
# 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/account/api/account?key=MTAxMDoyMDIw');
// 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('https://api.ekmpush.com/account/api/account?key=MTAxMDoyMDIw');
# 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("https://api.ekmpush.com/account/api/account?key=MTAxMDoyMDIw");
// 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');
const apiClient = axios.create({
baseURL: 'https://api.ekmpush.com/account/api/',
timeout: 1000 * 15,
})
// This code accesses the apiRequest query
// and logs the response data or the error
;(async () => {
try {
const res = await apiClient.get(
'account?key=MTAxMDoyMDIw');
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/account/api/account?key=MTAxMDoyMDIw',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 example digs deaper into the JSON and displays the first
// kwh_tot value for the first read of the first meter
readmeter_json = apiObject['readmeter'];
readset_json = readmeter_json['ReadSet'];
readset_0_json = readset_json[0];
readdata_json = readset_0_json['ReadData'];
readdata_0_json = readdata_json[0];
});
};
// 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"> </div>
</body>
</html>
This endpoint retrieves all Push devices, meters and ioStacks associated for an specified account, or you could retrieve account information for specified Push device using the Gateway Key.
Example URL
https://api.ekmpush.com/account/api/account?key=
MY_KEY
Replace MY_KEY with the EKM Push Key (i.e. MTAxMDoyMDIw) if you want to list all Push devices, meters and ioStacks associated to your account, for example:
https://api.ekmpush.com/account/api/account?key=MTAxMDoyMDIw
If you want to list information related to specified Push device, you have to use the Gateway Key (i.e. gateway with mac address 4016fa050ecd has a Gateway Key: NjUyNjk0MzY6KDkkPVtXLUpQZyFmaDBrYTlJ
). Your HTTPS address should look like the following:
https://api.ekmpush.com/account/api/account?key=NjUyNjk0MzY6KDkkPVtXLUpQZyFmaDBrYTlJ
URL PARAMETERS
PARAMETERS | DESCRIPTION |
---|---|
key | (string) – the EKM Push authorization key or Gateway Key. |
Account Deep
HTTPS Request
curl -s "https://api.ekmpush.com/account/api/account?key=MTAxMDoyMDIw&deep=true"
# 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("https://api.ekmpush.com/account/api#{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 https://api.ekmpush.com
api_object = call_api('/account?key=MTAxMDoyMDIw&deep=true')
# 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("https://api.ekmpush.com/account/api/account?key=MTAxMDoyMDIw&deep=true")
# 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/account/api/account?key=MTAxMDoyMDIw&deep=true');
// 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('https://api.ekmpush.com/account/api/account?key=MTAxMDoyMDIw&deep=true');
# 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("https://api.ekmpush.com/account/api/account?key=MTAxMDoyMDIw&deep=true");
// 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');
const apiClient = axios.create({
baseURL: 'https://api.ekmpush.com/account/api/',
timeout: 1000 * 15,
})
// This code accesses the apiRequest query
// and logs the response data or the error
;(async () => {
try {
const res = await apiClient.get(
'account?key=MTAxMDoyMDIw&deep=true');
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/account/api/account?key=MTAxMDoyMDIw&deep=true',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 example digs deaper into the JSON and displays the first
// kwh_tot value for the first read of the first meter
readmeter_json = apiObject['readmeter'];
readset_json = readmeter_json['ReadSet'];
readset_0_json = readset_json[0];
readdata_json = readset_0_json['ReadData'];
readdata_0_json = readdata_json[0];
});
};
// 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"> </div>
</body>
</html>
This endpoint retrieves all Push devices associated to an account and it includes child device metadata.
In the example below the deep being used is: true
https://api.ekmpush.com/account/api/account?key=MTAxMDoyMDIw&deep=
true
The link below is an example of the deep data with the associated account:
https://api.ekmpush.com/account/api/account?key=MTAxMDoyMDIw&deep=true
URL PARAMETERS
PARAMETER | DESCRIPTION |
---|---|
deep | (boolean) – include child device metadata. |
Target: gateway
This endpoint retrieves a gateway information owned by an account.
The EKM Push Key is your own Authorization Key that you received for your Push Account. In the following examples of this API document, we will be using the following key MTAxMDoyMDIw in all of our https calls. You will need to change the example key, of MTAxMDoyMDIw, with your own private key in order to access your meters/ioStacks that you have associated with your account. Also you could use the Gateway Key instead of the EKM Push Key for more restricted access.
Get a specific gateway
HTTPS Request
curl -s "https://api.ekmpush.com/account/api/gateway?key=MTAxMDoyMDIw&id=4016fa0500cd"
# 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("https://api.ekmpush.com/account/api#{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 https://api.ekmpush.com
api_object = call_api('/gateway?key=MTAxMDoyMDIw&id=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'''
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("https://api.ekmpush.com/account/api/gateway"\
"?key=MTAxMDoyMDIw&id=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/account/api/gateway?key=MTAxMDoyMDIw&id=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='') {
$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(
'https://api.ekmpush.com/account/api/gateway?key=MTAxMDoyMDIw&id=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 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("https://api.ekmpush.com/account/api/gateway?key=MTAxMDoyMDIw&id=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');
const apiClient = axios.create({
baseURL: 'https://api.ekmpush.com/account/api/',
timeout: 1000 * 15,
})
// This code accesses the apiRequest query
// and logs the response data or the error
;(async () => {
try {
const res = await apiClient.get(
'gateway?key=MTAxMDoyMDIw&id=4016fa0500cd');
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/account/api/gateway?key=MTAxMDoyMDIw&id=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 example digs deaper into the JSON and displays the first
// kwh_tot value for the first read of the first meter
readmeter_json = apiObject['readmeter'];
readset_json = readmeter_json['ReadSet'];
readset_0_json = readset_json[0];
readdata_json = readset_0_json['ReadData'];
readdata_0_json = readdata_json[0];
});
};
// 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"> </div>
</body>
</html>
This endpoint retrieves a specific gateway and all the information associated with it. In this example we will be using key MTAxMDoyMDIw and gateway id (mac) 4016fa0500cd. Remember that you could use in the key parameter the Gateway Key instead the EKM Push Key.
If you would like to filter to just 1 gateway you can add the filter: id=GATEWAY_ID
In the example below the GATEWAY_ID being used is: 4016fa0500cd
https://api.ekmpush.com/account/api/gateway?key=MTAxMDoyMDIw&id=
4016fa0500cd
The link below is an example of the information data associated with the gateway.
https://api.ekmpush.com/account/api/gateway?key=MTAxMDoyMDIw&id=4016fa0500cd
URL PARAMETERS
PARAMETER | DESCRIPTION |
---|---|
id | (string) – The ID of the gateway you want to retrieve. |
Query multiple gateways
HTTPS Request
curl -s "https://api.ekmpush.com/account/api/gateway?key=MTAxMDoyMDIw&id=4016fa0500cd~4016fa010006"
# 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("https://api.ekmpush.com/account/api#{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 https://api.ekmpush.com
api_object = call_api('/gateway?key=MTAxMDoyMDIw&id=4016fa0500cd~4016fa010006')
# 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("https://api.ekmpush.com/account/api/gateway"\
"?key=MTAxMDoyMDIw&id=4016fa0500cd~4016fa010006")
# 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/account/api/gateway?key=MTAxMDoyMDIw&id=4016fa0500cd~4016fa010006');
// 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(
'https://api.ekmpush.com/account/api/gateway?key=MTAxMDoyMDIw&id=4016fa0500cd~4016fa010006'
);
# 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("https://api.ekmpush.com/account/api/gateway?key=MTAxMDoyMDIw&id=4016fa0500cd~4016fa010006");
// 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');
const apiClient = axios.create({
baseURL: 'https://api.ekmpush.com/account/api/',
timeout: 1000 * 15,
})
// This code accesses the apiRequest query
// and logs the response data or the error
;(async () => {
try {
const res = await apiClient.get(
'gateway?key=MTAxMDoyMDIw&id=4016fa0500cd~4016fa010006');
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/account/api/gateway?key=MTAxMDoyMDIw&id=4016fa0500cd~4016fa010006', 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 example digs deaper into the JSON and displays the first
// kwh_tot value for the first read of the first meter
readmeter_json = apiObject['readmeter'];
readset_json = readmeter_json['ReadSet'];
readset_0_json = readset_json[0];
readdata_json = readset_0_json['ReadData'];
readdata_0_json = readdata_json[0];
});
};
// 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"> </div>
</body>
</html>
To see multiple Push devices, i.e. Push gateway 4016fa0500cd and 4016fa010006, your https address should look like the following:
https://api.ekmpush.com/account/api/gateway?key=MTAxMDoyMDIw&id=
4016fa0500cd~4016fa010006
As you can see in the above example, all that was changed in the https address is the addition of the extra gateway to the end of the id parameter: 4016fa0500cd~4016fa010006. This will allow you to call multiple gateways to get their information.
https://api.ekmpush.com/account/api/gateway?key=MTAxMDoyMDIw&id=4016fa0500cd~4016fa010006
Gateway state
HTTPS Request
curl -s "https://api.ekmpush.com/account/api/gateway?key=MTAxMDoyMDIw&id=4016fa0500cd&state=true"
# 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("https://api.ekmpush.com/account/api#{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 https://api.ekmpush.com
api_object = call_api('/gateway?key=MTAxMDoyMDIw&id=4016fa0500cd&state=true')
# 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("https://api.ekmpush.com/account/api/gateway"\
"?key=MTAxMDoyMDIw&id=4016fa0500cd&state=true")
# 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/account/api/gateway?key=MTAxMDoyMDIw&id=4016fa0500cd&state=true');
// 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(
'https://api.ekmpush.com/account/api/gateway?key=MTAxMDoyMDIw&id=4016fa0500cd&state=true'
);
# 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("https://api.ekmpush.com/account/api/gateway?key=MTAxMDoyMDIw&id=4016fa0500cd&state=true");
// 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');
const apiClient = axios.create({
baseURL: 'https://api.ekmpush.com/account/api/',
timeout: 1000 * 15,
})
// This code accesses the apiRequest query
// and logs the response data or the error
;(async () => {
try {
const res = await apiClient.get(
'gateway?key=MTAxMDoyMDIw&id=4016fa0500cd&state=true');
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/account/api/gateway?key=MTAxMDoyMDIw&id=4016fa0500cd&state=true', 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 example digs deaper into the JSON and displays the first
// kwh_tot value for the first read of the first meter
readmeter_json = apiObject['readmeter'];
readset_json = readmeter_json['ReadSet'];
readset_0_json = readset_json[0];
readdata_json = readset_0_json['ReadData'];
readdata_0_json = readdata_json[0];
});
};
// 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"> </div>
</body>
</html>
If you want to see more details for the push device with mac: 4016fa0500cd you have to use the state parameter.
https://api.ekmpush.com/account/api/gateway?key=MTAxMDoyMDIw&id=4016fa0500cd&state=
STATE
The example link below will return the JSON data for the given parameters in the https address.
https://api.ekmpush.com/account/api/gateway?key=MTAxMDoyMDIw&id=4016fa0500cd&state=true
URL PARAMETERS
PARAMETER | DESCRIPTION |
---|---|
state | (boolean) – include state data. |
Gateway deep
HTTPS Request
curl -s "https://api.ekmpush.com/account/api/gateway?key=MTAxMDoyMDIw&id=4016fa0500cd&deep=true"
# 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("https://api.ekmpush.com/account/api#{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 https://api.ekmpush.com
api_object = call_api('/gateway?key=MTAxMDoyMDIw&id=4016fa0500cd&deep=true')
# 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_requesta)
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/account/api/gateway"\
"?key=MTAxMDoyMDIw&id=4016fa0500cd&deep=true")
# 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/account/api/gateway?key=MTAxMDoyMDIw&id=4016fa0500cd&deep=true');
// 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(
'https://api.ekmpush.com/account/api/gateway?key=MTAxMDoyMDIw&id=4016fa0500cd&deep=true'
);
# 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("https://api.ekmpush.com/account/api/gateway?key=MTAxMDoyMDIw&id=4016fa0500cd&deep=true");
// 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');
const apiClient = axios.create({
baseURL: 'https://api.ekmpush.com/account/api/',
timeout: 1000 * 15,
})
// This code accesses the apiRequest query
// and logs the response data or the error
;(async () => {
try {
const res = await apiClient.get(
'gateway?key=MTAxMDoyMDIw&id=4016fa0500cd&deep=true');
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/account/api/gateway?key=MTAxMDoyMDIw&id=4016fa0500cd&deep=true', 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 example digs deaper into the JSON and displays the first
// kwh_tot value for the first read of the first meter
readmeter_json = apiObject['readmeter'];
readset_json = readmeter_json['ReadSet'];
readset_0_json = readset_json[0];
readdata_json = readset_0_json['ReadData'];
readdata_0_json = readdata_json[0];
});
};
// 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"> </div>
</body>
</html>
If you would like to see child device metadata for the push device with mac: 4016fa0500cd, add the deep parameter.
https://api.ekmpush.com/account/api/gateway?key=MTAxMDoyMDIw&id=4016fa0500cd&deep=
true
Click the link below to see the child device metadata:
https://api.ekmpush.com/account/api/gateway?key=MTAxMDoyMDIw&id=4016fa0500cd&deep=true
If you want to get a more complete push device information you can add the state parameter:
https://api.ekmpush.com/account/api/gateway?key=MTAxMDoyMDIw&id=4016fa0500cd&state=true&deep=true
URL PARAMETERS
PARAMETER | DESCRIPTION |
---|---|
deep | (boolean) – include child device metadata. |
Target: meter
The following https format will provide information of the EKM Push Meter Number 000350000900 in the EKM Push account with key MTAxMDoyMDIw
.
The EKM Push Meter Number is the number of your meter that you have in service. In the following examples of this API document, we will be using the meter number 000350000900 in all of our https calls. To use your own meter number simply replace the example meter number, of 000350000900, with your own meter number.
The EKM Push Key is your own Authorization Key that you received for your Push Account. In the following examples of this API document, we will be using the following key MTAxMDoyMDIw in all of our https calls. You will need to change the example key, of MTAxMDoyMDIw, with your own private key in order to access your meters that you have associated with your account. Also you could use the Gateway Key instead of the EKM Push Key for more restricted access.
Meter information
HTTPS Request
curl -s "https://api.ekmpush.com/account/api/meter?key=MTAxMDoyMDIw&id=000350000900"
# 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("https://api.ekmpush.com/account/api#{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 https://api.ekmpush.com
api_object = call_api('/meter?key=MTAxMDoyMDIw&id=000350000900')
# 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("https://api.ekmpush.com/account/api/meter"\
"?key=MTAxMDoyMDIw&id=000350000900")
# 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/account/api/meter?key=MTAxMDoyMDIw&id=000350000900');
// 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(
'https://api.ekmpush.com/account/api/meter?key=MTAxMDoyMDIw&id=000350000900'
);
# 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("https://api.ekmpush.com/account/api/meter?key=MTAxMDoyMDIw&id=000350000900");
// 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');
const apiClient = axios.create({
baseURL: 'https://api.ekmpush.com/account/api/',
timeout: 1000 * 15,
})
// This code accesses the apiRequest query
// and logs the response data or the error
;(async () => {
try {
const res = await apiClient.get(
'meter?key=MTAxMDoyMDIw&id=000350000900');
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/account/api/meter?key=MTAxMDoyMDIw&id=000350000900', 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 example digs deaper into the JSON and displays the first
// kwh_tot value for the first read of the first meter
readmeter_json = apiObject['readmeter'];
readset_json = readmeter_json['ReadSet'];
readset_0_json = readset_json[0];
readdata_json = readset_0_json['ReadData'];
readdata_0_json = readdata_json[0];
});
};
// 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"> </div>
</body>
</html>
This endpoint retrieves a specific meter and all the data associated with it. In this example we will be using key MTAxMDoyMDIw and meter number 000350000900.
If you would like to filter to just 1 meter you can add the filter: id=METER_ID
In the example below the METER_ID being used is: 000350000900
https://api.ekmpush.com/account/api/meter?key=MTAxMDoyMDIw&id=
000350000900
The link below is an example of the data associated to the meter
https://api.ekmpush.com/account/api/meter?key=MTAxMDoyMDIw&id=000350000900
URL PARAMETERS
PARAMETER | DESCRIPTION |
---|---|
id | (string) – meter id. |
Query multiple meters
HTTPS Request
curl -s "https://api.ekmpush.com/account/api/meter?key=MTAxMDoyMDIw&id=000350000900~000000010389"
# 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("https://api.ekmpush.com/account/api#{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 https://api.ekmpush.com
api_object = call_api('/meter?key=MTAxMDoyMDIw&id=000350000900~000000010389')
# 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("https://api.ekmpush.com/account/api/meter"\
"?key=MTAxMDoyMDIw&id=000350000900~000000010389")
# 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/account/api/meter?key=MTAxMDoyMDIw&id=000350000900~000000010389');
// 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(
'https://api.ekmpush.com/account/api/meter?key=MTAxMDoyMDIw&id=000350000900~000000010389'
);
# 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("https://api.ekmpush.com/account/api/meter?key=MTAxMDoyMDIw&id=000350000900~000000010389");
// 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');
const apiClient = axios.create({
baseURL: 'https://api.ekmpush.com/account/api/',
timeout: 1000 * 15,
})
// This code accesses the apiRequest query
// and logs the response data or the error
;(async () => {
try {
const res = await apiClient.get(
'meter?key=MTAxMDoyMDIw&id=000350000900~000000010389');
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/account/api/meter?key=MTAxMDoyMDIw&id=000350000900~000000010389', 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 example digs deaper into the JSON and displays the first
// kwh_tot value for the first read of the first meter
readmeter_json = apiObject['readmeter'];
readset_json = readmeter_json['ReadSet'];
readset_0_json = readset_json[0];
readdata_json = readset_0_json['ReadData'];
readdata_0_json = readdata_json[0];
});
};
// 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"> </div>
</body>
</html>
To see multiple meter information, i.e. meter number 000350000900 and 000000010389, your https address should look like the following:
https://api.ekmpush.com/account/api/meter?key=MTAxMDoyMDIw&id=
000350000900~000000010389
As you can see in the above example, all that was changed in the https address is the addition of the extra meter to the end of the id parameter: 000350000900~000000010389. This will allow you to call multiple meters to get their information.
https://api.ekmpush.com/account/api/meter?key=MTAxMDoyMDIw&id=000350000900~000000010389
Meter state
HTTPS Request
curl -s "https://api.ekmpush.com/account/api/meter?key=MTAxMDoyMDIw&id=000350000900&state=true"
# 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("https://api.ekmpush.com/account/api#{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 https://api.ekmpush.com
api_object = call_api('/meter?key=MTAxMDoyMDIw&id=000350000900&state=true')
# 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("https://api.ekmpush.com/account/api/meter"\
"?key=MTAxMDoyMDIw&id=000350000900&state=true")
# 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/account/api/meter?key=MTAxMDoyMDIw&id=000350000900&state=true');
// 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(
'https://api.ekmpush.com/account/api/meter?key=MTAxMDoyMDIw&id=000350000900&state=true'
);
# 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("https://api.ekmpush.com/account/api/meter?key=MTAxMDoyMDIw&id=000350000900&state=true");
// 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');
const apiClient = axios.create({
baseURL: 'https://api.ekmpush.com/account/api/',
timeout: 1000 * 15,
})
// This code accesses the apiRequest query
// and logs the response data or the error
;(async () => {
try {
const res = await apiClient.get(
'meter?key=MTAxMDoyMDIw&id=000350000900&state=true');
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/account/api/meter?key=MTAxMDoyMDIw&id=000350000900&state=true', 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 example digs deaper into the JSON and displays the first
// kwh_tot value for the first read of the first meter
readmeter_json = apiObject['readmeter'];
readset_json = readmeter_json['ReadSet'];
readset_0_json = readset_json[0];
readdata_json = readset_0_json['ReadData'];
readdata_0_json = readdata_json[0];
});
};
// 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"> </div>
</body>
</html>
To include state data such as last kWh meter reading add state=true
.
https://api.ekmpush.com/account/api/meter?key=MTAxMDoyMDIw&id=000350000900&
state=true
To see the state data:
https://api.ekmpush.com/account/api/meter?key=MTAxMDoyMDIw&id=000350000900&state=true
URL PARAMETERS
PARAMETER | DESCRIPTION |
---|---|
state | (boolean) – optional - include state data (such as last kWh meter reading). |
Target: ioStack
The following https format provides information about the ioStack Number 55555 in your EKM Push account with the key MTAxMDoyMDIw
.
Your ioStack number is like the ID for your device in use. In our examples, we will use the ioStack number 55555 for all https requests. Just replace it with your own ioStack number when needed.
The EKM Push Key serves as your unique authorization key for your Push Account. In our examples, we’re using the key MTAxMDoyMDIw. Remember to replace it with your own private key to access the ioStacks associated with your account. Alternatively, for more restricted access, you can use the Gateway Key or the ioStack key.
Get a specific ioStack
HTTPS Request
curl -s "https://api.ekmpush.com/account/api/iostack?key=MTAxMDoyMDIw&id=55555"
# Ruby Version: 3.3.0
# 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("https://api.ekmpush.com/account/api#{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 https://api.ekmpush.com
api_object = call_api('/iostack?key=MTAxMDoyMDIw&id=55555')
# 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("https://api.ekmpush.com/account/api/iostack"\
"?key=MTAxMDoyMDIw&id=55555")
# 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.2.14 (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/account/api/iostack?key=MTAxMDoyMDIw&id=55555');
// 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(
'https://api.ekmpush.com/account/api/iostack?key=MTAxMDoyMDIw&id=55555'
);
# 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("https://api.ekmpush.com/account/api/iostack?key=MTAxMDoyMDIw&id=55555");
// 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: v20.10.0
* Axios: 0.27.2
*/
// Load modules
const axios = require('axios');
const apiClient = axios.create({
baseURL: 'https://api.ekmpush.com/account/api/',
timeout: 1000 * 15,
})
// This code accesses the apiRequest query
// and logs the response data or the error
;(async () => {
try {
const res = await apiClient.get(
'iostack?key=MTAxMDoyMDIw&id=55555');
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/account/api/iostack?key=MTAxMDoyMDIw&id=55555",
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 example digs deaper into the JSON and displays the first
// kwh_tot value for the first read of the first meter
readmeter_json = apiObject["readmeter"];
readset_json = readmeter_json["ReadSet"];
readset_0_json = readset_json[0];
readdata_json = readset_0_json["ReadData"];
readdata_0_json = readdata_json[0];
}
);
}
// 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"></div>
</body>
</html>
This endpoint retrieves data for a specific ioStack. In this example, we are using the key MTAxMDoyMDIw and ioStack number 55555. Alternatively, you can use the ioStack Key instead of the EKM Push Key in the key parameter.
To filter for only one ioStack, include the filter: id=IOSTACK_ID
.
In this instance, the IOSTACK_ID used is: 55555
:
https://api.ekmpush.com/account/api/iostack?key=MTAxMDoyMDIw&id=
55555
The link below is an example of the data associated to the ioStack
https://api.ekmpush.com/account/api/iostack?key=MTAxMDoyMDIw&id=55555
URL PARAMETERS
PARAMETER | DESCRIPTION |
---|---|
id | (string) – ioStack id. |
Query multiple ioStacks
HTTPS Request
curl -s "https://api.ekmpush.com/account/api/iostack?key=MTAxMDoyMDIw&id=55553~55555"
# Ruby Version: 3.3.0
# 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("https://api.ekmpush.com/account/api#{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 https://api.ekmpush.com
api_object = call_api('/iostack?key=MTAxMDoyMDIw&id=55553~55555')
# 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("https://api.ekmpush.com/account/api/iostack"\
"?key=MTAxMDoyMDIw&id=55553~55555")
# 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.2.14 (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/account/api/iostack?key=MTAxMDoyMDIw&id=55553~55555');
// 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(
'https://api.ekmpush.com/account/api/iostack?key=MTAxMDoyMDIw&id=55553~55555'
);
# 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("https://api.ekmpush.com/account/api/iostack?key=MTAxMDoyMDIw&id=55553~55555");
// 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: v20.10.0
* Axios: 0.27.2
*/
// Load modules
const axios = require('axios');
const apiClient = axios.create({
baseURL: 'https://api.ekmpush.com/account/api/',
timeout: 1000 * 15,
})
// This code accesses the apiRequest query
// and logs the response data or the error
;(async () => {
try {
const res = await apiClient.get(
'iostack?key=MTAxMDoyMDIw&id=55553~55555');
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/account/api/iostack?key=MTAxMDoyMDIw&id=55553~55555",
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"></div>
</body>
</html>
To view data for multiple ioStack devices, such as ioStack devices 55553 and 55555, your https address should be formatted like this:
https://api.ekmpush.com/account/api/iostack?key=MTAxMDoyMDIw&id=
55553~55555
As you can see in the above example, all that was changed in the https address is the addition of the extra ioStack to the end of the id parameter: 55553~55555. This will allow you to call multiple ioStacks to get their information.
https://api.ekmpush.com/account/api/iostack?key=MTAxMDoyMDIw&id=55553~55555
ioStack state
HTTPS Request
curl -s "https://api.ekmpush.com/account/api/iostack?key=MTAxMDoyMDIw&id=55555&state=true"
# Ruby Version: 3.3.0
# 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("https://api.ekmpush.com/account/api#{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 https://api.ekmpush.com
api_object = call_api('/iostack?key=MTAxMDoyMDIw&id=55555&state=true')
# 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("https://api.ekmpush.com/account/api/iostack"\
"?key=MTAxMDoyMDIw&id=55555&state=true")
# 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.2.14 (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/account/api/iostack?key=MTAxMDoyMDIw&id=55555&state=true');
// 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(
'https://api.ekmpush.com/account/api/iostack?key=MTAxMDoyMDIw&id=55555&state=true'
);
# 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("https://api.ekmpush.com/account/api/iostack?key=MTAxMDoyMDIw&id=55555&state=true");
// 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: v20.10.0
* Axios: 0.27.2
*/
// Load modules
const axios = require('axios');
const apiClient = axios.create({
baseURL: 'https://api.ekmpush.com/account/api/',
timeout: 1000 * 15,
})
// This code accesses the apiRequest query
// and logs the response data or the error
;(async () => {
try {
const res = await apiClient.get(
'iostack?key=MTAxMDoyMDIw&id=55555&state=true');
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/account/api/iostack?key=MTAxMDoyMDIw&id=55555&state=true",
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"></div>
</body>
</html>
To view additional details for your ioStack device with the address 55555, utilize the state parameter.
https://api.ekmpush.com/account/api/iostack?key=MTAxMDoyMDIw&id=55555&state=
STATE
The provided link example below will retrieve the JSON data based on the specified parameters in the https address.
https://api.ekmpush.com/account/api/iostack?key=MTAxMDoyMDIw&id=55555&state=true
URL PARAMETERS
PARAMETER | DESCRIPTION |
---|---|
state | (boolean) – include state data. |
Gateway Settings API
Click here to go to Gateway Settings API Documentation
This API is used to send commands and settings to devices connected to a Push3 gateway as well as the gateway device itself.
Trigger API
Click here to go to Trigger API Documentation
A REST API to lookup/create/update/delete triggers.
EKM Push3 gateway triggers are among the most powerful tools that EKM offers. You can automate how and when the EKM Push system reacts to metered values. For example, you can have the Push gateway send you an email, send a webhook to your server, or control a relay to turn on/off a switch or close a valve based on the metered data. Push3 gateways can trigger specific actions based on conditions you set up. These triggers reside on the Push3 gateways, allowing them to function even without an internet connection. Triggers can control the relays on v.4 Omnimeters to turn devices on or off, send webhooks to alert your software system, or email you notifications. You can set up new triggers in the Account Portal or via web APIs.
Please note: v.3 Omnimeters do not have controllable relays, so relay triggers will not work, but email triggers will.
Summary API [LEGACY]
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
Summary V2 API
Click here to go to Summary V2 Documentation
Summary V2 API is a new set of summary features, such as First/Last to get the first and/or last reported date for the given meter(s)/ioStack(s), GStat for getting the status of one or more gateways, IOStack for getting information from new sensors, and more.
The API V2 summary and documentation are currently in beta, signifying that they are subject to changes and updates. It’s important to note that the API V2 calls and specifications provided in this documentation may undergo modifications as the beta phase progresses. Users should stay informed and regularly check for updates to ensure compatibility and adherence to the latest specifications
MQTT Messaging
Click here to go to MQTT Documentation
MQTT (Message Queuing Telemetry Transport) is a lightweight messaging protocol designed for low-bandwidth, high-latency, or unreliable networks, often used in Internet of Things (IoT) applications. It follows a publish-subscribe model, where devices (clients) can publish messages to topics or subscribe to topics to receive messages.
MQTT will only work with Push3 Gateways. It is more efficient than making hundreds of API calls, allowing continuous realtime or summary data streaming (you can stream 24/7). However, it lacks message history, meaning that if you need past data, you will have to make an API request to retrieve realtime or summary information as far back as necessary, and then resume streaming via MQTT. If the connection is lost, you will need to request realtime or summary data again to fill in any gaps before continuing with the MQTT stream. This combination of API and MQTT helps ensure a smooth data flow while compensating for potential disruptions.
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.4/v.5 Meter Settings Protocol
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. |
Widget Documentation
Click here to go to Widget Documentation
Access free web-based real-time and historical graphs showcasing your EKM Push data, covering all your devices including meters and ioStacks. It’s quick, easy, and doesn’t require a login.
The EKM Widget offers a convenient means to gain visual insights into your systems’ performance. We utilize it to monitor our office’s current consumption and solar power generation in real-time. Additionally, the historical chart helps us track the impact of efficiency upgrades on our usage and monitor the energy consumption of our electric car over time.