import os
import requests
from dotenv import load_dotenv

load_dotenv()

BASE_URL = os.getenv("AKVORADO_BASE_URL", "http://localhost:8081/api/v0/console/widget")

def get_widget_data(endpoint: str):
    url = f"{BASE_URL}/{endpoint}?0"
    try:
        res = requests.get(url)
        res.raise_for_status()
        return res.json()
    except requests.RequestException as e:
        print(f"Fout bij ophalen van {endpoint}: {e}")
        return {"top": []}