# terna-py
Python client for the Transparency API of Terna, the Italian electricity transmission system operator
[![PyPI Latest Release](https://img.shields.io/pypi/v/terna-py.svg)](https://pypi.org/project/terna-py/)
[![Downloads](https://static.pepy.tech/badge/terna-py)](https://pypi.org/project/terna-py/)
Documentation of the API: https://developer.terna.it/docs/read/APIs_catalog#en
## Installation
`python3 -m pip install terna-py`
## Usage
```python
import terna as trn
import pandas as pd
# Please follow the API documentation to register an account and create credentials
key = '<YOUR API KEY>'
secret = '<YOUR API SECRET>'
client = trn.TernaPandasClient(api_key=key,api_secret=secret)
# Note: you specifically need to set a start= and end= parameter which should be a pandas timestamp with timezone
start = pd.Timestamp("20210101", tz='Europe/Rome')
end = pd.Timestamp("20210131", tz='Europe/Rome')
bzone = ['NORD', 'CNOR', 'SUD', 'CSUD', 'SARD', 'SICI', 'CALA', 'Italy']
gen_type = ['Thermal', 'Wind', 'Geothermal', 'Photovoltaic', 'Self-consumption', 'Hydro']
res_gen_type = ['Wind', 'Geothermal', 'Photovoltaic', 'Hydro']
type = ['Thermal', 'Wind', 'Geothermal', 'Photovoltaic', 'Self-consumption', 'Hydro', 'Pumping-consumption', 'Net Foreign Exchange']
year = 2022
# Note: all methods return Pandas DataFrames
df_tload = client.get_total_load(start=start, end=end, bzone=bzone)
df_mload = client.get_market_load(start=start, end=end, bzone=bzone)
df_act_gen = client.get_actual_generation(start=start, end=end, gen_type=gen_type)
df_res_gen = client.get_renewable_generation(start=start, end=end, res_gen_type=res_gen_type)
df_ener_bal = client.get_energy_balance(start=start, end=end, type=gen_type)
df_cap = client.get_installed_capacity(year=year, gen_type=gen_type)
df_xborderschedule = client.get_scheduled_foreign_exchange(start=start, end=end)
df_xborderflow = client.get_physical_foreign_flow(start=start, end=end)
df_internalschedule = client.get_scheduled_internal_exchange(start=start, end=end)
df_internalflow = client.get_physical_internal_flow(start=start, end=end)
```
Raw data
{
"_id": null,
"home_page": "https://github.com/fgenoese/terna-py",
"name": "terna-py",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "Terna data api energy",
"author": "fgenoese",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/56/04/9a006ed2c15727099a9b63a44cec56e5d2908c341bdfe470f5435936087d/terna-py-0.4.0.tar.gz",
"platform": null,
"description": "# terna-py\nPython client for the Transparency API of Terna, the Italian electricity transmission system operator\n\n[![PyPI Latest Release](https://img.shields.io/pypi/v/terna-py.svg)](https://pypi.org/project/terna-py/)\n[![Downloads](https://static.pepy.tech/badge/terna-py)](https://pypi.org/project/terna-py/)\n\nDocumentation of the API: https://developer.terna.it/docs/read/APIs_catalog#en\n\n## Installation\n`python3 -m pip install terna-py`\n\n## Usage\n```python\nimport terna as trn\nimport pandas as pd\n\n# Please follow the API documentation to register an account and create credentials\nkey = '<YOUR API KEY>'\nsecret = '<YOUR API SECRET>'\nclient = trn.TernaPandasClient(api_key=key,api_secret=secret)\n\n# Note: you specifically need to set a start= and end= parameter which should be a pandas timestamp with timezone\nstart = pd.Timestamp(\"20210101\", tz='Europe/Rome')\nend = pd.Timestamp(\"20210131\", tz='Europe/Rome')\nbzone = ['NORD', 'CNOR', 'SUD', 'CSUD', 'SARD', 'SICI', 'CALA', 'Italy']\ngen_type = ['Thermal', 'Wind', 'Geothermal', 'Photovoltaic', 'Self-consumption', 'Hydro']\nres_gen_type = ['Wind', 'Geothermal', 'Photovoltaic', 'Hydro']\ntype = ['Thermal', 'Wind', 'Geothermal', 'Photovoltaic', 'Self-consumption', 'Hydro', 'Pumping-consumption', 'Net Foreign Exchange']\nyear = 2022\n\n# Note: all methods return Pandas DataFrames\ndf_tload = client.get_total_load(start=start, end=end, bzone=bzone)\ndf_mload = client.get_market_load(start=start, end=end, bzone=bzone)\n\ndf_act_gen = client.get_actual_generation(start=start, end=end, gen_type=gen_type)\ndf_res_gen = client.get_renewable_generation(start=start, end=end, res_gen_type=res_gen_type)\ndf_ener_bal = client.get_energy_balance(start=start, end=end, type=gen_type)\ndf_cap = client.get_installed_capacity(year=year, gen_type=gen_type)\n\ndf_xborderschedule = client.get_scheduled_foreign_exchange(start=start, end=end)\ndf_xborderflow = client.get_physical_foreign_flow(start=start, end=end)\n\ndf_internalschedule = client.get_scheduled_internal_exchange(start=start, end=end)\ndf_internalflow = client.get_physical_internal_flow(start=start, end=end)\n```\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Python API wrapper for Terna transparency data",
"version": "0.4.0",
"project_urls": {
"Homepage": "https://github.com/fgenoese/terna-py"
},
"split_keywords": [
"terna",
"data",
"api",
"energy"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "a729c46f76c03160611f3360bbed8f9de99f0577f252eaeaeb91017254e2dd87",
"md5": "7605fac3308de3e1b0b8ee337ce6ac5a",
"sha256": "853ba8e2c90a5fee33bd83743c941b8ae8970346f34b177269e515b2bad6070f"
},
"downloads": -1,
"filename": "terna_py-0.4.0-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "7605fac3308de3e1b0b8ee337ce6ac5a",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 5203,
"upload_time": "2023-10-31T20:57:51",
"upload_time_iso_8601": "2023-10-31T20:57:51.786575Z",
"url": "https://files.pythonhosted.org/packages/a7/29/c46f76c03160611f3360bbed8f9de99f0577f252eaeaeb91017254e2dd87/terna_py-0.4.0-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "56049a006ed2c15727099a9b63a44cec56e5d2908c341bdfe470f5435936087d",
"md5": "07538a539715da91ae0c3f5ee5ec56f2",
"sha256": "50aedfb7a26dd124608a6e12ac705baf48bf899ccc86198ced166c3a8a3fa88d"
},
"downloads": -1,
"filename": "terna-py-0.4.0.tar.gz",
"has_sig": false,
"md5_digest": "07538a539715da91ae0c3f5ee5ec56f2",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 5118,
"upload_time": "2023-10-31T20:57:54",
"upload_time_iso_8601": "2023-10-31T20:57:54.673117Z",
"url": "https://files.pythonhosted.org/packages/56/04/9a006ed2c15727099a9b63a44cec56e5d2908c341bdfe470f5435936087d/terna-py-0.4.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-10-31 20:57:54",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "fgenoese",
"github_project": "terna-py",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "terna-py"
}