Documentation Index
Fetch the complete documentation index at: https://mintlify.com/lucavallini/wert-app/llms.txt
Use this file to discover all available pages before exploring further.
Wert App integrates with two external HTTP APIs to power its economic-data and currency-conversion features. Both integrations follow the same pattern: a lightweight class is instantiated in ventanaMain.__init__, and its methods wrap individual HTTP calls with try/except blocks so that network failures degrade gracefully rather than crashing the UI. Neither class holds state beyond the base URL and (for ChangeAPi) an API key.
Both WorldBankAPI and ChangeAPi return None on any failure — including HTTP status codes other than 200, network errors, and missing keys in the response JSON. Callers in logica_main_window.py always check for None before using the result.
The ExchangeRate-API key is hardcoded as a string literal in change_api.py. If the repository is made public, this key will be exposed. Consider loading it from an environment variable or a secrets file (following the same pattern used for the database password in conexion.py).
WorldBankAPI
File: api/world_bank_api.py
Base URL: http://api.worldbank.org/v2WorldBankAPI wraps the World Bank Open Data REST API. It is instantiated once in ventanaMain and its methods are called to populate country and indicator dropdowns on startup, then again each time the user requests economic data.class WorldBankAPI:
def __init__(self):
self._url = "http://api.worldbank.org/v2"
get_eco_info(country_code, indicator)
Fetches the 5 most recent data points for a given country and economic indicator. Returns None if either argument is None or if the HTTP request fails.def get_eco_info(self, country_code, indicator):
if country_code is None or indicator is None:
return None
endopoint = f'{self._url}/country/{country_code}/indicator/{indicator}'
params = { 'format': 'json', 'per_page': 5 }
try:
response = requests.get(endopoint, params=params)
if response.status_code == 200:
data = response.json()
return data
else:
return None
except:
return None
The raw JSON response is a two-element list: data[0] is pagination metadata and data[1] is the list of data-point objects. Each object contains at minimum a date (year string) and value (float or None).
get_countries()
Returns a list of (id, name) tuples for every non-aggregate country in the World Bank catalogue. Aggregate entries (regional groupings) are filtered out by checking that country['region']['value'] != 'Aggregates'.def get_countries(self):
endpoint = f'{self._url}/country'
params = { 'format': 'json', 'per_page': 500 }
try:
response = requests.get(endpoint, params=params)
if response.status_code == 200:
data = response.json()
countries = []
for country in data[1]:
if country['region']['value'] != 'Aggregates':
countries.append((country['id'], country['name']))
return countries
else:
return None
except:
return None
get_indicators()
Returns a hard-coded dictionary mapping World Bank indicator codes to human-readable Spanish labels. This avoids a network round-trip for data that rarely changes.def get_indicators(self):
indicators = {
'ALL': 'Ver todos',
"NY.GDP.MKTP.CD": "PIB total (US$)",
"NY.GDP.MKTP.KD.ZG": "Crecimiento del PIB (%)",
"NY.GDP.PCAP.CD": "PIB por persona (US$)",
"FP.CPI.TOTL.ZG": "Inflación anual (%)",
"SL.UEM.TOTL.ZS": "Desempleo (%)",
"SE.SEC.NENR": "Matriculación secundaria neta (%)",
"EG.ELC.ACCS.ZS": "Acceso a electricidad (%)",
"SH.H2O.SMDW.ZS": "Acceso a agua potable (%)",
"IT.NET.USER.ZS": "Usuarios de Internet (%)",
"NE.EXP.GNFS.ZS": "Exportaciones de bienes y servicios (% del PIB)",
"NE.IMP.GNFS.ZS": "Importaciones de bienes y servicios (% del PIB)",
}
return indicators
The special 'ALL' key triggers ventanaMain.show_all(), which iterates over every other indicator and issues one get_eco_info call per indicator to build a summary view.
Formats the raw JSON response from get_eco_info into a human-readable multi-line string. Values above 1000 are shown as US$ amounts with comma separators; values of 1000 or below are shown as percentages with two decimal places; missing values are reported as "Dato no disponible".def format_eco_data(self, datos):
if datos is None or len(datos) < 2:
return "No hay datos"
texto = ""
for item in datos[1]:
año = item['date']
valor = item['value']
if valor and valor > 1000:
texto += f"{año}: US${valor:,.0f} \n"
elif valor == None:
texto += f'{año}: Dato no disponible \n'
else:
texto += f"{año}: {valor:.2f} %\n"
return texto
ChangeAPi
File: api/change_api.py
Base URL: https://v6.exchangerate-api.com/v6/ChangeAPi wraps the ExchangeRate-API v6 service. It is instantiated once in ventanaMain alongside WorldBankAPI. The currency converter panel in the main window uses get_rate on every conversion request and get_monedas on startup to populate both currency dropdowns.class ChangeAPi:
def __init__(self):
self.url = "https://v6.exchangerate-api.com/v6/"
self.api_key = "f602a7d2eff20ba66b6f2953"
get_rate(moneda, cambio)
Returns the exchange rate from moneda to cambio as a float. The endpoint used is the latest/{base_currency} endpoint, and the target rate is read from conversion_rates[cambio] in the response JSON.def get_rate(self, moneda, cambio):
try:
response = requests.get(f'{self.url}{self.api_key}/latest/{moneda}')
if response.status_code == 200:
datos = response.json()
tasa = datos['conversion_rates'][cambio]
return tasa
return None
except:
return None
ventanaMain.show_convert_currency multiplies the user-entered amount by this rate and displays the result formatted to two decimal places.
get_monedas()
Returns a hard-coded dictionary of 30 currency codes mapped to their Spanish names. Like get_indicators() in WorldBankAPI, this avoids a network call for static reference data.def get_monedas(self):
total_monedas = {
"USD": "Dólar Estadounidense",
"EUR": "Euro",
"ARS": "Peso Argentino",
"BRL": "Real Brasileño",
"MXN": "Peso Mexicano",
"GBP": "Libra Esterlina",
"JPY": "Yen Japonés",
"CNY": "Yuan Chino",
"CAD": "Dólar Canadiense",
"AUD": "Dólar Australiano",
"CHF": "Franco Suizo",
"RUB": "Rublo Ruso",
"INR": "Rupia India",
"TRY": "Lira Turca",
"KRW": "Won Surcoreano",
"IDR": "Rupia Indonesia",
"ZAR": "Rand Sudafricano",
"NZD": "Dólar Neozelandés",
"HKD": "Dólar Hongkonés",
"SGD": "Dólar Singapurense",
"SEK": "Corona Sueca",
"NOK": "Corona Noruega",
"DKK": "Corona Danesa",
"PLN": "Zloty Polaco",
"THB": "Baht Tailandés",
"HUF": "Florín Húngaro",
"CZK": "Corona Checa",
"CLP": "Peso Chileno",
"PEN": "Sol Peruano",
"COP": "Peso Colombiano",
}
return total_monedas