import requests
import json
from datetime import date, timedelta
from dotenv import load_dotenv
import os

load_dotenv()

API_TOKEN = os.getenv("FIO_TOKEN")


# Last 30 days
start = (date.today() - timedelta(days=10000)).strftime("%Y-%m-%d")
end = date.today().strftime("%Y-%m-%d")

url = f"https://fioapi.fio.cz/v1/rest/periods/{API_TOKEN}/{start}/{end}/transactions.json"

response = requests.get(url)
print(response.status_code)

data = response.json()

with open(r"u:\Dropbox\!!!Days\Downloads Z230\Fio\pohyby.json", "w", encoding="utf-8") as f:
    json.dump(data, f, ensure_ascii=False, indent=4)
