-
Notifications
You must be signed in to change notification settings - Fork 0
gordonta/mint_bulk_inserter
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Hello. I wrote this code because I was trying to build a Mint Budget but Mint would only allow me to upload 90 days worth of transactions from my Bank. I identified that you could manually add transactions and proxied the request to manually upload a transaction, which was a POST request to /updateTransaction.xevent So I tested manually editing that in burp repeater and sending it back- lo and behold it works. SO I built this python script to automate adding transactions that I bulk-exported from my bank account. If you dont have burp or a proxy, you can capture the request information from your browser. In firefox, click "+ Transaction". Inside the popup, right-click and select 'Inspect Element'. Select the 'Network" tab. Fill in fake data in the transaction popup then submit with "I'M DONE". A POST request to /updateTransaction.xevent will pop up in the Network log. Click that and then right click the request and select "copy -> Copy as cURL". Copy the cURL request and then go to a cURL to Python converter (I used the one at https://curl.trillworks.com/). Note that "Copy as cURL" does not copy the POST body, which is important, so manually add the body to the --data "" field. you can grab the data by going back to the network tab and clicking again on the /updateTransaction.xevent request. Right click and select "Edit and Resend". Firefox will put the POST request in a pane to the left, merely copy the raw body of the POST and go back to the cURL to Python converter. Put the body of the POST request into the --data field, between the "" quotes. Then copy the python converted request to the right and paste that inside the code here. Be sure to take the actual requests.post() function call and replace the current requests.post() call inside the while loop. Also watch to make sure you dont now have another "import requests" in your file. Alltogether, using a proxy is easier, but this works too. NOTE 1: The token and cookie expire periodically. You need to stay relatively active on mint in your browser otherwise the cookies will time out and your script will not work. /updateTransaction.xevent returns a 200 even if the session is inactive and POST requests to that endpoint do not "refresh" your cookie activity, so you need to manually stay and refresh your mint session while the script is running. NOTE 2: Categories are an impotant issue to talk about here. My bank exported its own category for each transaction, but Mint has a unique set of categories. More importantly, each of Mint's categories have a corresponding category ID that is needed to acurrately update the category when you insert a new transaction. Since there is a natural difference between my bank's categories and Mint's, I needed to do a fuzzy string comparison to see if my bank's categories were at all "similar" to one of mint's categories. I needed a new library to take care of this "similarity-ness", so I downloaded the fuzzywuzzy package which relies on The Levenshtein distance to determine how apart are two sequences of words. Full descriptions available at https://www.datacamp.com/community/tutorials/fuzzy-string-python, and I give full credit to those authors for this stuff. I just copied the code that compared a string with a list of strings and returns which string in the list is "closest". To this end, some of the strings arnt close at all, so I set a metric of 70 to determine how "close" I was comfortable with accepting (based on some rudimentary testing). This value can be changed of course. Ultimately, this all serves to get your new transactions "close" to a mint category. I recommend scrubbing them each manually to be sure its accurrate.
About
Rough code to insert bulk transactions into mint
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published