hledger/bin/simplefinjson

29 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
# simplefinjson 1.0 - (c) Simon Michael 2025
# Download accounts and recent transactions history from SimpleFIN, as JSON.
#
# Requirements:
# a SimpleFIN account with financial institution(s) and app connection configured
# GNU date
# jq to prettify
# Insert an access token here, acquired with simplefinsetup.
# (Or use a secrets manager, like https://bitwarden.com/help/secrets-manager-quick-start.)
SIMPLEFIN_ACCESS_URL=''
# Run GNU date, which is gdate on mac.
date() { if hash gdate 2>/dev/null; then gdate "$@"; else date "$@"; fi }
START=`date +%s -d '-30 days'`
curl -sL "$SIMPLEFIN_ACCESS_URL/accounts?start-date=$START" | jq
# https://www.simplefin.org/protocol.html#http-endpoints
# https://www.simplefin.org/protocol.html#get-accounts
# Parameter Required Description
# start-date optional If given, transactions will be restricted to those on or after this Unix epoch timestamp.
# end-date optional If given, transactions will be restricted to those before (but not on) this Unix epoch timestamp.
# pending optional If pending=1 is provided, pending transactions will be included (if supported). By default, pending transaction are NOT included.
# account optional If given, only return information related to the given account id. May be specified multiple times.
# balances-only optional If balances-only=1 is provided, no transaction data is returned.