"""Minimal Viable Pathway calculate example. Set VIABLE_API_KEY in your environment — never commit the key. """ import json import os import urllib.request API_KEY = os.environ["VIABLE_API_KEY"] BASE = "https://app.viablepathway.net" URL = f"{BASE}/api/calculate?savePayload=false" with open("minimal-payload.json", encoding="utf-8") as f: payload = json.load(f) req = urllib.request.Request( URL, data=json.dumps(payload).encode("utf-8"), headers={ "Content-Type": "application/json", "Authorization": f"ApiKey {API_KEY}", }, method="POST", ) with urllib.request.urlopen(req) as resp: result = json.load(resp) print("projectionyears:", result.get("projectionyears")) print("BAU pathway (tCO2e):", result.get("ghgBAUsumperyear")) print("EXT pathway (tCO2e):", result.get("ghgEXTsumperyear")) print("INT pathway (tCO2e):", result.get("ghgINTsumperyear"))