awattar
Installation
$ pip install awattar
This package is tested with Python 3.9, 3.10, 3.11
Command line
Use the command awattar --help and awattar fetch-prices --help to get more information.
$ awattar --help
Usage: awattar [OPTIONS] COMMAND [ARGS]...
Access aWATTar's energy prices API.
Options:
--country [DE|AT] the API's target country (either Germany or Austria),
default: AT
--help Show this message and exit.
Commands:
fetch-prices Fetch hourly energy prices
Command line example
$ awattar --country AT fetch-prices --day 2023-02-20
[
{
"start": "2023-02-20T00:00:00+01:00",
"end": "2023-02-20T01:00:00+01:00",
"price": 85.96,
"unit": "Eur/MWh",
"currency": "Eur",
"energy_unit": "MWh",
"price_per_kWh": 0.08596
},
...
]
Examples
from awattar.client import AwattarClient
print ('Connect to aWATTar')
client = AwattarClient('AT') # or DE for Germany
print ('Get marketdata from API')
data = client.request()
for item in data:
print(f'{item.start_datetime:%Y-%m-%d %H:%M:%S} - {item.end_datetime:%Y-%m-%d %H:%M:%S} - {(item.marketprice / 1000):.4f} EUR/kWh')
Output
Connect to aWATTar
Get marketdata from API
2020-08-11 13:00:00 - 2020-08-11 14:00:00 - 0.0350 EUR/kWh
2020-08-11 14:00:00 - 2020-08-11 15:00:00 - 0.0341 EUR/kWh
2020-08-11 15:00:00 - 2020-08-11 16:00:00 - 0.0340 EUR/kWh
2020-08-11 16:00:00 - 2020-08-11 17:00:00 - 0.0387 EUR/kWh
2020-08-11 17:00:00 - 2020-08-11 18:00:00 - 0.0417 EUR/kWh
2020-08-11 18:00:00 - 2020-08-11 19:00:00 - 0.0430 EUR/kWh
2020-08-11 19:00:00 - 2020-08-11 20:00:00 - 0.0465 EUR/kWh
2020-08-11 20:00:00 - 2020-08-11 21:00:00 - 0.0413 EUR/kWh
2020-08-11 21:00:00 - 2020-08-11 22:00:00 - 0.0400 EUR/kWh
2020-08-11 22:00:00 - 2020-08-11 23:00:00 - 0.0369 EUR/kWh
2020-08-11 23:00:00 - 2020-08-12 00:00:00 - 0.0309 EUR/kWh
Usage
Initialize Awattar Client
Currently only Austria and Germany are supported
client = AwattarClient('AT') # or DE for Germany
Get Market data
Get current Market data
data = client.request()
Get Market data from 2020-05-17
data = client.request(datetime.datetime(2020, 5, 17))
Get Market data between 2020-05-18 and 2020-05-19
data = client.request(datetime.datetime(2020, 5, 18), datetime.datetime(2020, 5, 19))
Analyse Market data
print ('Connect to aWATTar')
client = AwattarClient('AT')
print ('Get Market data from API')
client.request()
min_item = client.min()
print(f'Min: {min_item.start_datetime:%Y-%m-%d %H:%M:%S} - {min_item.end_datetime:%Y-%m-%d %H:%M:%S} - {(min_item.marketprice / 1000):.4f} EUR/kWh')
max_item = client.max()
print(f'Max: {max_item.start_datetime:%Y-%m-%d %H:%M:%S} - {max_item.end_datetime:%Y-%m-%d %H:%M:%S} - {(max_item.marketprice / 1000):.4f} EUR/kWh')
mean_item = client.mean()
print(f'Mean: {mean_item.start_datetime:%Y-%m-%d %H:%M:%S} - {mean_item.end_datetime:%Y-%m-%d %H:%M:%S} - {(mean_item.marketprice / 1000):.4f} EUR/kWh')
best_slot = client.best_slot(3)
if best_slot is None:
print("No slot found")
else:
print(f'Best slot 1: {best_slot.start_datetime:%Y-%m-%d %H:%M:%S} - {best_slot.end_datetime:%Y-%m-%d %H:%M:%S} - {(best_slot.marketprice / 1000):.4f} EUR/kWh')
best_slot = client.best_slot(1,datetime.datetime(2020, 10, 5, 0, 0, 0),datetime.datetime(2020, 10, 6, 3, 0, 0))
if best_slot is None:
print("No slot found")
else:
print(f'Best slot 2: {best_slot.start_datetime:%Y-%m-%d %H:%M:%S} - {best_slot.end_datetime:%Y-%m-%d %H:%M:%S} - {(best_slot.marketprice / 1000):.4f} EUR/kWh')
Output
Connect to aWATTar
Get Market data from API
Min: 2020-10-06 03:00:00 - 2020-10-06 04:00:00 - 0.0107 EUR/kWh
Max: 2020-10-05 19:00:00 - 2020-10-05 20:00:00 - 0.0544 EUR/kWh
Mean: 2020-10-05 17:00:00 - 2020-10-06 17:00:00 - 0.0349 EUR/kWh
Best slot 1: 2020-10-06 02:00:00 - 2020-10-06 05:00:00 - 0.0149 EUR/kWh
Best slot 2: 2020-10-06 02:00:00 - 2020-10-06 03:00:00 - 0.0190 EUR/kWh
Source code
The source code is currently available on Github: https://github.com/Gransi/awattar
Metadata
Release files for awattar 0.8.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| awattar-0.8.1.tar.gz | 27.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| awattar-0.8.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 49.8 kB
Release files / awattar-0.8.1.tar.gz
| Download URL | awattar-0.8.1.tar.gz |
|---|---|
| Size | 27.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8e33c64ece050f66672ab2724ee9a94895ad7cbe511e56a83ca868a140e0cb9b
|
|
BLAKE2b-256 checksum How to use checksums |
59d1ee2a988061abadac29f3df2ea55254138bbb49c169f3c365a0134a0e2086
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.18
|
Release files / awattar-0.8.1-py3-none-any.whl
| Download URL | awattar-0.8.1-py3-none-any.whl |
|---|---|
| Size | 22.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
73e576c309c980ea9ba3111819900bbc597dac9425f90514f341e71e1ff4c275
|
|
BLAKE2b-256 checksum How to use checksums |
6ce07cbada9567144795453892670d729d01d7e70dab25f2de410c6d66bf45d1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.18
|
Security for awattar 0.8.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.