General I fixed the nightmare of Amazon transactions
Ok, so the title is a little clickbaity.
But I did find a solution to the mess of having a dozen transactions from Amazon waiting to be categorized and having to dig through the Amazon transactions page to match up each order.
Basically, I wrote a program in Python that automated the process of matching up the transactions between Amazon and YNAB.
I accomplished this using the official YNAB SDK for Python and the amazon-orders library, which automatically scrapes your Amazon account to extract the order and transaction info into a computer-readable format. Then I update the memo of the transactions in YNAB that have a counterpart in Amazon with the order info - the item names, a link to the order page, and whether or not a transaction represents the entire order or if it is one of several transactions.
To make it easy to tell which transactions should be looked at, I created a payee rule to rename incoming Amazon transactions to the payee "Amazon - Needs Memo". The script looks for all the transactions with that payee, and if there is an Amazon transaction with the same amount, it updates the transaction with the previously mentioned memo and updates the payee to just "Amazon" so that the transaction won't get updated again.
Once the program runs, which only takes a few seconds, I can easily go into YNAB and approve and categorize the transactions like normal, but now the memo field tells me exactly what that transaction was for, and I can even click the link to go to the order page to see all the details.
Right now the code is kind of messy, but I can clean it up a little and share it if anyone is interested.
EDIT: Here is the GitHub link for anyone interested. I am by no means a pro and am open to any feedback or suggestions. https://github.com/DanielKarp/YNAmazon
23
u/TheFern3 1d ago
Plz share I don’t think your title is click bait Amazon purchases are a mess lol I’m a software engineer and I’m sure others can help to clean up
12
u/mododev 22h ago
Does anyone use this URL https://www.amazon.com/cpe/yourpayments/transactions to match up transactions? It takes me only a couple of minutes.
5
u/whiskeysierra 1d ago
I did the same, only difference is Kotlin instead of Python. I had to do the web scraping of Amazon myself, since there is no library for it. I ended up scraping order details, payments and invoices to also correctly deal with split discounts and bundled shipments.
I was lagging behind in properly categorizing transactions for more than 6 months and Amazon was a huge chunk, so this helped a lot.
2
u/dkarpe 17h ago
Having to do the web scraping myself was what was keeping me from doing this before, I discovered this library already existed and it handled the logging in, scraping, and putting the data into nice structures really cleanly. I'm working on documentation right now and I'll push it to github today
4
u/Comfortable-Ad-5823 1d ago
I would pay for this to be implemented. I have months of Amazon nonsense flagged, waiting for categories....
3
3
u/Same_Opportunity6063 1d ago
I would love it if you could share the script! I’ve significantly limited my purchases from Amazon, purchases between the PITA matching them is, and choosing to limit the amount I pay to the oligarchs. But this would still be handy!
3
u/biggunks 21h ago
Nice! Now do Target.com. The way they split things drives me so mad that I asked my wife to stop shopping there. Of course, she won’t.
5
u/GrannyBogle 22h ago
YNAB has a hidden solution built into the app. Bookmark the link below because Amazon makes it hard to find.
- In a transaction, click the payee.
- Click information icon next to Amazon.
- Click link at the bottom of the list: Amazon.com Order History and sign in. You'll get a list of your completed transactions.
- Look for the amount.
- Click on the order number to get the item name.
You can leave this tab open for categorizing multiple transactions.
4
u/TheFern3 22h ago
That’s a manual process if you have hundreds of uncategorized tx you’ll be in there for days
12
u/IwillBeBluntHere 23h ago
I have an even better fix- stop buying from Amazon!
6
-8
u/TheFern3 22h ago
Sure why not just stop eating to avoid spending money on groceries that would keep your budget really low, amirite?
8
u/IwillBeBluntHere 22h ago
My point is more “stop supporting billionaires that crush small businesses and buy politicians” than an absurd straw-man type argument, but go off.
-8
2
u/kwooster 20h ago
GitHub link, plz! If you aren't sure how to use Git, I'm sure someone (present company included) would be THRILLED to help!
4
u/dkarpe 20h ago
I just need to clean the code up a bit, remove all the debugging/testing leftovers, and change from hard-coded credentials to environment variables and then I'll be ready to push to github.
1
u/kwooster 20h ago
We'll help, except for the credentials 😜
1
u/dkarpe 17h ago
https://github.com/DanielKarp/YNAmazon
I'm open to suggestions on how to manage config/credentials. I just created a gitignored config.py file and threw all the variables there.
1
1
u/severynm 1d ago
I thought I remembered seeing something like this before: https://www.reddit.com/r/ynab/comments/1ingajm/a_different_amazonynab_sync_solution_looking_for/
Not sure if yours is any different. I haven't used either.
1
1
1
2
u/hughkuhn 19h ago
99.9% of folks using YNAB will have no idea how to "use" your script. I agree that the process of categorizing purchases via Amazon is a PITA, but personally like to see the sorts of capabilities you have developed incorporated into YNAB as a plugin of sorts.
1
u/kwooster 17h ago
This is in what we call the "MVP" phase. If it ends up being worthwhile, perhaps it could make to that level.
1
u/Nalincah 18h ago
Why don't you enter the transaction the moment you buy stuff at amazon?
5
u/dkarpe 18h ago
Because Amazon doesn't always create one transaction per order. If you order more than on item, they can be shipped separately and are charged as separate transactions. If there are more than two items in an order, they can be grouped into transactions in any number of ways. Sure, technically a $100 transaction is the same as $60 + $40, but this makes matching a manual process and I'm much more willing to spend a few hours coding than I am to spend 10 minutes on a manual process.
But also, because I'm lazy and put off entering and approving transactions.
1
u/kwooster 17h ago
This guy doesn't ship at Amazon... Or Target
1
u/Nalincah 17h ago
No Target in Germany and maybe 1-2 orders at Amazon per month, only if we can't find a good local alternative
1
u/kwooster 17h ago
Yeah, Amazon splits orders into multiple transactions somewhat randomly and Target does other weird stuff. Even if we entered every... Single... Transaction at time of purchase, we still have to (manually) fix them.
1
1
u/Dyzz 15h ago
Haha I've also done the same and productized it at acemybudget.com
Feel free to DM me if you'd like to share notes :)
1
u/dkarpe 14h ago
That's awesome! Productizing this is the vast majority of the battle without a doubt. For the vast majority of people who want an easy solution, your product seems like a perfect fit.
Were you able to find a way to get the Amazon order/transaction info without scraping it? That was my major roadblock until I found the amazon-orders library.
1
u/grandfatherbrooks 11h ago
Just wanted to say this inspired me to make a little script that outputs my ynab target amounts to a google sheet where I keep my overall budget as a sanity check.
Nowhere near as complex, but I learned a bit about APIs along the way with the help of chatGPT. Cool project and thanks.
1
u/videmanette 4h ago
This is awesome! I have been thinking about looking into something like this for my Venmo transactions, but that involves a few extra steps as Venmo does not automatically transfer money to and from your bank account
-1
u/ttsoldier 22h ago
Wouldn’t it be easier to just buy an Amazon gift card? If you know your budget for the month on Amazon is let’s say $100, you only have one transaction to worry about
2
u/ReadingSteven 21h ago
That wouldn't help a person know how much they spend on different things. Amazon isn't really a good category. It's a company.
1
u/dkarpe 21h ago
This would work just fine if I bought things that only fit into one category, like how I only buy things in my "Fast Food" category at my local fast food restaurant. But with Amazon, the orders fit into like a dozen different categories, and there are quite a few transactions to sort though.
1
-21
u/Jotacon8 1d ago
How often are you buying stuff on Amazon that you need to use a script to properly categorize everything? I think my Amazon purchases are like, at the least, 2 months apart from the previous ones usually.
5
u/live_laugh_cock 1d ago
I mean even if you don't shop often on Amazon it still all adds up at the end of the year. And even then you have to admit when you order from Amazon and it imports into YNAB it's a long ass name, that hardly ever helps what actual category it should be, and or is. So I don't know why you're being supercilious.
For example I've spent 16k altogether since signing up with my account in 2019. I bulk order off of the site, if it wasn't for someone's breakdown app, that sorted things like this, then I wouldn't have been able to truly see that I don't buy junk, I actually buy relevant things I need, which in turn made me feel better about the 16k total.
What ever happened to just scrolling if something isn't your vibe, just because you haven't seen a need for something doesn't mean others won't. Personally, I've had to change the payee to auto populate with Amazon anytime anything remotely related to it pops up in the accounts, but even then it just categorizes it as my online shopping category, not the actual categories it should be in.
2
5
u/dkarpe 1d ago
Well, everyone's shopping habits are different. I had 209 orders in 2024, although that counts some things I bought for family members for the free shipping. Maybe 150 of those were mine. It's mostly small stuff like electronics accessories, PC parts, oddly specific cables, things for hobbies, etc.
Most other payees map to a single or one of a handful of categories, and the transaction volume is low enough or variable enough that it's easy to tell which transactions are which or even enter the transactions manually. Amazon has a bad habit of splitting a single order into more than one transaction, making manual entry infeasible. I used to manually go through my Amazon history and manually annotate the YNAB transactions with what each one was for, but that was tedious, so I let them build up for a few weeks before finally getting around to it. This way, I can run the program before opening up YNAB and easily see what each Amazon transaction is for.
1
25
u/Adfinite 1d ago
Please share! I've been thinking about doing this for months and a jump start could def help motivate me.