Skip to main content

terna-py

Python client for the Transparency API of Terna, the Italian electricity transmission system operator

PyPI Latest Release Downloads

Documentation of the API: https://developer.terna.it/docs/read/APIs_catalog#en

Installation

python3 -m pip install terna-py

Usage

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 = ["Centre-North", "Centre-South", "North", "Sardinia", "Sicily", "South", "Calabria", "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
## total load and market load, quarter-hourly data
df_tload = client.get_total_load(start=start, end=end, bzone=bzone)
df_mload = client.get_market_load(start=start, end=end, bzone=bzone)

## generation by source, renewable generation by source and energy balance, quarter-hourly data
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=type)

## installed capacity, annual data
df_cap = client.get_installed_capacity(year=year, gen_type=gen_type)

## cross-border commercial schedules and physical flows, quarter-hourly data
df_xborderschedule = client.get_scheduled_foreign_exchange(start=start, end=end)
df_xborderflow = client.get_physical_foreign_flow(start=start, end=end)

## cross-zonal commercial schedules and physical flows, quarter-hourly data
df_internalschedule = client.get_scheduled_internal_exchange(start=start, end=end)
df_internalflow = client.get_physical_internal_flow(start=start, end=end)

## use get_custom_item() to query any other API, see example below 
## demand coverage by source, select year(s) and region(s)
item = 'load/v2.0/demand-coverage-by-source'
data = {
            'year': [2022,2023],
            'region': ['Sardegna'],
            'source': [ 'Bioenergie', 'Eolico', 'Fotovoltaico', 'Geotermoelettrico', 'Termoelettrico tradizionale', 'Idrico rinnovabile', 'Idrico tradizionale', 'Saldo import/export' ]
        }
df = client.get_custom_item(item, data)

Metadata

Release files for terna-py 0.5.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for terna-py 0.5.6
File Size Uploaded
terna_py-0.5.6.tar.gz 6.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for terna-py 0.5.6
File Interpreter ABI Platform
terna_py-0.5.6-py3-none-any.whl Python 3 none any Details

Total release size: 13.3 kB

Release files / terna_py-0.5.6.tar.gz

Download URL terna_py-0.5.6.tar.gz
Size 6.8 kB
Tags Source
SHA-256 checksum
How to use checksums
b176a8cf7e5c60af9d77648d4112f5a5dd2ec0105c795b9ff152662d0d52dedd
BLAKE2b-256 checksum
How to use checksums
655b9349959d960ccbef2728dfb5ef8dd8371a9895810d77958cc462b6cfa628
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.23

Release files / terna_py-0.5.6-py3-none-any.whl

Download URL terna_py-0.5.6-py3-none-any.whl
Size 6.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4544d0949ebd7f262fca8ad779086584dcee132dd38d7bed1abfb58f90c71664
BLAKE2b-256 checksum
How to use checksums
25f418fb7c90b5cab70aa30ed13b2599497925afff4245696634241b554e4d73
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.23

Release history Release notifications | RSS feed

This release

0.5.6 This release

2 release files

0.5.5

2 release files

0.5.4

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.2

2 release files

0.3.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page