Development API - Create an app

Follow

This article lists the available documentation on the API and introduces the steps to take to develop an app for the platform by giving an overview on the platform's API and giving examples of queries to request data.

You will need a basic understanding of HTTP and APIs and a SuperAdmin user.

Contents:

  1. Introduction
  2. API v3 Technical documentation
  3. Registering an Application
  4. Installing an application
  5. Calls examples
  6. Data insertion API
  7. Datasource Type as a Service

Introduction

The API secures all queries by using a security token which is unique for each application and each account where the application is installed.

In order to obtain a security token, you will need to register an application, and install it in one of your accounts.

API v3 Technical documentation

All the technical documentation on the API is available in the platform's developer portal: developers.dexma.com.

Registering an application

If you want to register a new application, follow the steps described here.

Installing an application

Once the app has been registered in the platform you can install it in one of your accounts. The app should respond to the handshake performed by the platform when installing the app in order to obtain the security token 'x-dexcell-token' (also refered to as 'permanent token').

The handshake process is described in the API's technical documentation.

Call examples

With the app registered and successfully installed in one of your accounts, you should have received the x-dexcell-token and stored it in your app. With that token, you can perform queries to the different endpoints of the API.

Obtain a list of all my locations

url: https://api.dexcell.com/v3/locations

ae0297a62d7dc329423a6102fa876126ce49b6d75c7a60890ec31b9dd66b8df0.png

Obtain the specific information of one location

url: https://api.dexcell.com/v3/locations/XXX (where XXX is one of the IDs obtained in the previous call)

51df1b07e83cb95d52eca1d3186ed9c5c6c38a4503d7c85807cb75afa5a86023.png


 

Obtain electrical consumption data

url: http://api.dexcell.com/v3/readings?device_id=XXXXX&operation=DELTA&parameter_key=EACTIVE&resolution=D&from=2015-05-08T00:00:00&to=2015-05-09T23:59:59​

4c24fdc2426fd0e89c57a414e958a855549b1e9a8a5f64e065a295051de946e2.png


How do I create the call?

http://api.dexcell.com/v3/readings + “?” + all the parameters joint by “&”
- device_id: 3473 (id of the device)
- Operation: DELTA (delta readings) 
- Parameter_key: EACTIVE (key of the Active Energy parameter)
- Resolution: D (daily). Others: FM, TM, QH, HH, H, D, M
- From: 2016-05-08T00:00:00  (from date with the format YYYY-MM-DDT00:00:00)
- To: 2016-05-10T23:59:59 (to date with the format YYYY-MM-DDT00:00:00)
 

Obtain electricity cost for a specific device

url: http://api.dexcell.com/v3/cost/electrical/consumption?device_id=XXXX&from=2016-04-01T00:00:00&to=2015-12-31T23:59:59&resolution=M

2a97fc1c3b18e3e296146719ddda56b9c1993006faf86d806775f0303a2cbc07.png

How I create the call?

http://api.dexcell.com/v3/cost/electrical/consumption + “?” + all the parameters joint by “&”
- device_id: 3473 (id of the device)
- Resolution: M (monthly). Others: FM, TM, QH, HH, H, D, M
- From: 2016-05-08T00:00:00  (from date with the format YYYY-MM-DDT00:00:00)
- To: 2016-05-10T23:59:59 (to date with the format YYYY-MM-DDT00:00:00)

All available queries are described in the platform's developer portal: developers.dexma.com.

Data insertion API

The EM platform offers an API to insert data from external applications. This API is based in HTTPS and JSON.

Check this article to learn how to insert data into your account through the HTTPS/JSON API.

 

Datasource Type as a Service

In order to work as datasource type, an application needs to comply with the following requirements:

  1. Being able to register a virtual datasource for a deployment (via APIv3) and persist it locally
  2. Being able to update an already registered datasource (only name and status can be modified)
  3. Insert readings (via IS3) linked to the existing datasources.

Note: An app may request information of any given datasource to ensure the reading will be processed (IS3 will reject insertion requests if the datasource does not exist or it is not enabled and online), but requesting this information before inserting each reading will cause too many requests and the quota may be exceeded, causing the app to fail. That’s why persisting the information locally is mandatory. Keeping it in sync is the App’s responsibility.

Declaring a Datasource Type when registering or editing an App:

Note: This text completes the article Registering a Market App

When registering an app (or when updating its configuration), the form has a section named “Datasource Type” where we can declare a datasource type. The fields are:

marketapp.png

  • Name (mandatory): It will be used to identify the type when adding a new datasource to a deployment.
  • Icon: The logo/icon related to the datasource
  • URL (mandatory): The base URL used to communicate with the gateway. Appending /ping the system should be able to check if the gateway type is enabled and online, it may be the same URL used by the App
  • URL for UI (mandatory): The base URL used to load the different pages where a user can interact with the App:
  • Appending /datasources/new it must show a page to register a new datasource.
  • Appending /datasources/<id> it must show a page to edit an existing datasource.
  • Appending /datasources it may list the existing datasources for the current deployment.
  • Key (mandatory): All datasources generated will use this value as prefix for their name, it must be unique.

Was this article helpful?