A bare-bones Python API client for accessing Finnish electricity consumption data using the OmaMittari Electricity Consumer API v1.1. See https://kehitys.omamittari.fi/
With setuptools, install with python setup.py install
from omamittari import OMApi
# Get my customer ID
c = OMApi.Client()
r = c.asiakkaat()
id = r.json()[0]["Asiakastunnus"]
# Get hourly readings from 2 days ago
r = c.mittaussarja(
kohde=OMApi.TARGET_CUSTOMER,
tunnus=id,
pvm=date.today() - timedelta(2),
jakso=OMApi.PERIOD_HOUR)
print r.text
The API Token, username and subscription key can be configured:
- in the environment variables
OMAMITTARI_API_TOKEN
,OMAMITTARI_USERNAME
andOMAMITTARI_SUBSCRIPTION_KEY
- when instantiating the client:
OMApi.Client(api_token=x, username=y, subscription_key=z)
- with an INI-style configuration file. By default, the client will look for
omamittari.ini
in the current directory. An alternative location can be specified withOMApi.Client(config_path=/path/to/custom.ini)
. An example config file is provided inomamittari.ini.template
.
Tested with Python 2.7.