Import Starling Bank transactions in Beancount
Project description
starling-beancount
What is this
Use a Starling Developer account to programatically export your bank transactions to beancount files.
There are two main scripts:
- starling_beancount/extractor.py converts Starling API JSON to beancount Transactions and Balances.
- starling_beancount/importer.py contains the configuration for
bean-extractto parse that.
Setup
Get a Starling Personal Access Token with the following scopes:
account:read
balance:read
transaction:read
space:read
Save the provided token text in a file somewhere useful (near your beancount files probably).
Install this library:
pip install starling-beancount smart_importer
Configuration
Make a copy of config.yml and edit it to suit your needs.
- The
jointAccsanduserIdsfields are only needed if you have a joint account and you want to add metadata about which user made a transaction.
💪 Running the script
Then run the script:
Usage: starling [OPTIONS] ACC
Options:
--fr TEXT
--to TEXT [default: today]
--balance / --no-balance [default: no-balance]
Example to get the transactions from assets_starling (or whatever you called your token file) from a date until today:
starling assets_starling --fr=2021-01-01
Print the balance:
starling assets_starling --balance
🧠 As a beancount importer
You will need to add something like the following to your bean-extract configuration (eg config.py):
from starling_beancount.importer import StarlingImporter
from smart_importer import apply_hooks, PredictPostings
from smart_importer.detector import DuplicateDetector
CONFIG = [
...,
apply_hooks(StarlingImporter(
config_path="path/to/config.yml",
acc="assets_starling",
token_path="path/to/token.txt",
bean_path="path/to/ledger.bean",
), [DuplicateDetector(), PredictPostings()])
]
Then add a Note to your ledger, specifying the earliest date you would like starling-beancount to extract from.
It must have the text "bean-extract" somewhere in it.
A new note will be added each time you run the script, so that you don't have to deal with too many duplicates.
2022-03-01 note Assets:Starling "bean-extract"
Last thing! You must create the "target" file that bean-extract will look for.
Since we don't actually need a file (it all comes from the API), just add a file to wherever you would normally place them.
👉 Make sure to name this the same as the acc= argument to StarlingImporter above.
touch ./raw/assets_starling
So long as this file is there, bean-extract (and, by extension, the Fava importing tool) will find it and offer you to import that account.
Then run the following:
bean-extract config.py raw/assets_starling
Prior art
jorgeml/starlingbank does a similar thing, albeit more simply (probably for the better).
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file starling_beancount-2.0.1.tar.gz.
File metadata
- Download URL: starling_beancount-2.0.1.tar.gz
- Upload date:
- Size: 29.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea15f1f59db63e7883e389b774e4527a06daa4062d241c9aec07a059dc988801
|
|
| MD5 |
ce1cb577964792039d38e1cee19d4b09
|
|
| BLAKE2b-256 |
63cc033390a03589020c7530ab4d11133fa5a97eac81406725eaf85035dd37d2
|
File details
Details for the file starling_beancount-2.0.1-py3-none-any.whl.
File metadata
- Download URL: starling_beancount-2.0.1-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3438d1b07e80ddeef0870a50e3e28d594f056813e3e929af12380285d7f4ff4
|
|
| MD5 |
9732a511f93ca3d5c4a60bc50bddc079
|
|
| BLAKE2b-256 |
e735c51d31b792023f32e71eb23793d082a91b5b717c68a93cabc7c4d6559f09
|