This library is for the older ALSI API v1, a client for the newer v2 can be found here: ROITI-Ltd/roiti-gie
Python client for the ALSI API (Aggregated LNG Storage Inventory)
Documentation of the API can be found on: https://alsi.gie.eu/GIE_API_documentation_v004.pdf
Documentation of the client API can be found on: https://roiti-ltd.github.io/alsi-py/
python -m pip install alsi-py
The package is split in two clients:
from alsi.raw_client import AlsiRawClient
from alsi.pandas_client import AlsiPandasClient
from alsi.mappings import Area
from datetime import datetime
import asyncio
API_KEY = "<API_KEY>"
country_code = Area.ES # Also could be string: 'ES' or 'Spain'
company_code = "21X000000001254A"
facility_code = "21W0000000000370"
async def main():
client = AlsiRawClient(api_key=API_KEY)
# Raw client gets JSON from the API and parses it to a Python object.
await client.query_data_for_facility(
facility_code, company_code, country_code
)
await client.query_agg_data_for_europe_or_noneurope(europe="eu")
await client.query_agg_data_by_country(country_code="BE")
await client.query_data_by_company_and_country(company_code, country_code)
# Filter results by time
await client.query_agg_data_by_country(
country_code,
start=datetime(2017, 1, 1),
end=datetime(2018, 1, 1),
limit=10,
)
# Create pandas client. All functions have the same name as in the raw
# client, but return pandas dataframes instead.
pandas_client = AlsiPandasClient(api_key=API_KEY)
# Make sure to close the client sessions.
await client.close_session()
await pandas_client.close_session()
asyncio.run(main())
Tell pytest where to look for unit tests and create env for ALSI API key
On Unix
export PYTHONPATH=./alsi
export ALSI_KEY='...'
On Windows
$env:PYTHONPATH='./alsi'
$env:ALSI_KEY='<API_KEY>'
Run unit tests in coverage mode
python -m pytest ./tests --import-mode=append --cov
Pull the repository:
git clone https://github.com/ROITI-Ltd/alsi-py.git
cd ./alsi-py
Set up your working environment:
Create virtual environment
python -m venv env
Activate the virtual environment
On UNIX
source env/bin/activate
On Windows
.\env\Scripts\activate
Install required packages:
python -m pip install -r requirements.txt
python -m pip install -r requirements-dev.txt
Bumping the package version after making changes:
bumpversion major|minor|patch|build
For more general guidelines on contributing see: Contributing to alsi-py.
Many thanks to the entsoe-py library for serving as inspiration for this library.