import configparser
import json
import requests


API_ENDPOINT = "https://api.monzo.com"

config = configparser.ConfigParser()
config.read("config.ini")


def fetch_transaction_list_from_api():
    account_id = config["MONZO"]["account_id"]
    auth_token = config["MONZO"]["auth_token"]

    res = requests.get(
        url=f"{API_ENDPOINT}/transactions?expand[]=merchant&account_id={account_id}",
        headers={"Authorization": f"Bearer {auth_token}"},
    )

    return res.json()


def load_transaction_list(update_cache=False):
    try:
        with open("data/transaction_list.json", "r") as file:
            transaction_list = json.load(file)
    except FileNotFoundError:
        update_cache = True
        print("Missing cache file!")
    if update_cache:
        print("Downloading transaction list...")
        with open("data/transaction_list.json", "w") as file:
            transaction_list = fetch_transaction_list_from_api()
            json.dump(transaction_list, file)

    return transaction_list.get("transactions", [])

6b3c9dfbe0bb3823617b3e1bc83f646eca633a16
<mask token>


def fetch_transaction_list_from_api():
    account_id = config['MONZO']['account_id']
    auth_token = config['MONZO']['auth_token']
    res = requests.get(url=
        f'{API_ENDPOINT}/transactions?expand[]=merchant&account_id={account_id}'
        , headers={'Authorization': f'Bearer {auth_token}'})
    return res.json()


def load_transaction_list(update_cache=False):
    try:
        with open('data/transaction_list.json', 'r') as file:
            transaction_list = json.load(file)
    except FileNotFoundError:
        update_cache = True
        print('Missing cache file!')
    if update_cache:
        print('Downloading transaction list...')
        with open('data/transaction_list.json', 'w') as file:
            transaction_list = fetch_transaction_list_from_api()
            json.dump(transaction_list, file)
    return transaction_list.get('transactions', [])

<mask token>
config.read('config.ini')


def fetch_transaction_list_from_api():
    account_id = config['MONZO']['account_id']
    auth_token = config['MONZO']['auth_token']
    res = requests.get(url=
        f'{API_ENDPOINT}/transactions?expand[]=merchant&account_id={account_id}'
        , headers={'Authorization': f'Bearer {auth_token}'})
    return res.json()


def load_transaction_list(update_cache=False):
    try:
        with open('data/transaction_list.json', 'r') as file:
            transaction_list = json.load(file)
    except FileNotFoundError:
        update_cache = True
        print('Missing cache file!')
    if update_cache:
        print('Downloading transaction list...')
        with open('data/transaction_list.json', 'w') as file:
            transaction_list = fetch_transaction_list_from_api()
            json.dump(transaction_list, file)
    return transaction_list.get('transactions', [])

<mask token>
API_ENDPOINT = 'https://api.monzo.com'
config = configparser.ConfigParser()
config.read('config.ini')


def fetch_transaction_list_from_api():
    account_id = config['MONZO']['account_id']
    auth_token = config['MONZO']['auth_token']
    res = requests.get(url=
        f'{API_ENDPOINT}/transactions?expand[]=merchant&account_id={account_id}'
        , headers={'Authorization': f'Bearer {auth_token}'})
    return res.json()


def load_transaction_list(update_cache=False):
    try:
        with open('data/transaction_list.json', 'r') as file:
            transaction_list = json.load(file)
    except FileNotFoundError:
        update_cache = True
        print('Missing cache file!')
    if update_cache:
        print('Downloading transaction list...')
        with open('data/transaction_list.json', 'w') as file:
            transaction_list = fetch_transaction_list_from_api()
            json.dump(transaction_list, file)
    return transaction_list.get('transactions', [])

import configparser
import json
import requests
API_ENDPOINT = 'https://api.monzo.com'
config = configparser.ConfigParser()
config.read('config.ini')


def fetch_transaction_list_from_api():
    account_id = config['MONZO']['account_id']
    auth_token = config['MONZO']['auth_token']
    res = requests.get(url=
        f'{API_ENDPOINT}/transactions?expand[]=merchant&account_id={account_id}'
        , headers={'Authorization': f'Bearer {auth_token}'})
    return res.json()


def load_transaction_list(update_cache=False):
    try:
        with open('data/transaction_list.json', 'r') as file:
            transaction_list = json.load(file)
    except FileNotFoundError:
        update_cache = True
        print('Missing cache file!')
    if update_cache:
        print('Downloading transaction list...')
        with open('data/transaction_list.json', 'w') as file:
            transaction_list = fetch_transaction_list_from_api()
            json.dump(transaction_list, file)
    return transaction_list.get('transactions', [])

import configparser
import json
import requests


API_ENDPOINT = "https://api.monzo.com"

config = configparser.ConfigParser()
config.read("config.ini")


def fetch_transaction_list_from_api():
    account_id = config["MONZO"]["account_id"]
    auth_token = config["MONZO"]["auth_token"]

    res = requests.get(
        url=f"{API_ENDPOINT}/transactions?expand[]=merchant&account_id={account_id}",
        headers={"Authorization": f"Bearer {auth_token}"},
    )

    return res.json()


def load_transaction_list(update_cache=False):
    try:
        with open("data/transaction_list.json", "r") as file:
            transaction_list = json.load(file)
    except FileNotFoundError:
        update_cache = True
        print("Missing cache file!")
    if update_cache:
        print("Downloading transaction list...")
        with open("data/transaction_list.json", "w") as file:
            transaction_list = fetch_transaction_list_from_api()
            json.dump(transaction_list, file)

    return transaction_list.get("transactions", [])
