energyworx

Energyworx API python client library


Keywords
api, energyworx, python client
License
Other
Install
pip install energyworx==1.0.1

Documentation

Energyworx SaaS python client

This repository contains the open source code of a python REST client that can be used to use the Energyworx API.

How to install the Energyworx Python Client

In a notebook just type:

%%bash pip install energyworx For updating an existing installation you can type:

%%bash pip install --upgrade energyworx

You will see output like this: Downloading/unpacking energyworx Downloading energyworx-client-0.3.tar.gz Running setup.py (path:/tmp/pip-build-Yt4Bxs/energyworx/setup.py) egg_info for package energyworx Installing collected packages: energyworx Running setup.py install for energyworx Successfully installed energyworx Cleaning up...

After it is successfully installed you can import the energyworx client using: from energyworx as ewx

Before you can invoke the API you need to define the authorization credentials, that will be used in the next section, we suggest to do this using the following code when using in interactive mode:

import getpass tenantDomain = raw_input("Enter your tenantDomain:") apiKey = getpass.getpass("Enter your API-KEY:")

How to use the Energyworx Python Client

First you need to import the energyworx client and other neccesary libraries:

import pandas as pd import datetime import energyworx as ewx

We currently support two methods for accessing the Energyworx API:

Fetching aggregations using datasets

Define the dataset(s) we want to retrieve and the start- and enddate and the aggregationInterval and -Period to use:

datasets = [ewx.DataSet("123456789", "GAS", "DELIVERY", "M3", "SUM")] aggregationInterval = "PER_HOUR" aggregationPeriod = "IN_GIVEN_PERIOD" startDate = "2015-01-01T00:00+01:00" endDate = "2016-01-01T00:00+01:00"

Fetching validated data using datasets

datasets = [ewx.DataSet("1234567", "GAS", "DELIVERY"),ewx.DataSet("345678", "POWER", "DELIVERY") ] startDate = "2015-01-01T00:00+01:00" endDate = "2016-01-01T00:00+01:00"

Next create the EnergyworxClient and the RequestObject with the apiKey, tenantDomain, startDate, endDate and aggregationInterval and -Period. Then invoke the client with ".request_aggregations()" and it will fetch the result from the API and returns it in pandas DataFrame format.

ewxclient = ewx.EnergyworxClient(ewx.RequestObject(apiKey, tenantDomain, datasets, startDate, endDate, aggregationInterval, aggregationPeriod)) timeseries_df = ewxclient.request_aggregations()

You could then for example plot the result in a line chart:

timeseries_df.plot(kind="line", figsize=(20, 10), legend=None) plot.show()