import requests
import json

# Replace with your actual token
API_TOKEN = "v0GJaAVeefzV1lnx1jPCf2nFF7SuOPzzrL5tobPNsC7oCChXG4hahDYVb8Rdcex0"

# Example: download last 30 days of transactions in JSON
url = f"https://fioapi.fio.cz/v1/rest/periods/v0GJaAVeefzV1lnx1jPCf2nFF7SuOPzzrL5tobPNsC7oCChXG4hahDYVb8Rdcex0/2000-01-01/2025-07-23/transactions.json"

response = requests.get(url)
print(response)
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)
#
# # Print some info
# for trans in data['accountStatement']['transactionList']['transaction']:
#     print(f"Date: {trans['column0']['value']}")
#     print(f"Amount: {trans['column1']['value']}")
#     print(f"Currency: {trans['column14']['value']}")
#     print(f"Sender/Receiver: {trans['column10']['value']}")
#     print(f"Message: {trans['column16']['value']}")
#     print("-" * 40)
