Show HN: CLI to order groceries via reverse-engineered REWE API (Haskell) (github.com)

by wazHFsRy 85 comments 205 points
Read article View on HN

85 comments

[−] aweiher 44d ago
I hope REWE is seeing this and offers an official MCP server. In the end we pay real money there. :D

I wrote a skill some time ago to support me with "agentic groceries" on my own - it's the future of shopping I would say.

My workflow:

- I paste in urls or text for receipts I will cook this week - agent extracts the ingredients, calculates cups to ml and such, replaces meat with vegi ingredients, replaces some other things I prefer always (often also creates a nice markdown receipe at this steo I can put into Obsidian) - check my list of favs, check search cache (so not every time the api is called, I'm a good netizen :D ) - ask me which items I have at home (no need to add to the basket) - search rewe api for multiple candidates and let me choose. - after each recipe I enter /new to start with fresh context - also I have a list of things I buy every week

I still put everything manually in the basket in the end, but this is not the thing which is time intensive.

[−] wazHFsRy 44d ago
This is also my exact workflow here. Thank you. I'm adding things that should be in the basket via Siri to my Obsidian notes. I also add recipes to that list or anything else. Then Claude checks that list once I want to do the shopping, looks through my favorites, and fills the baskets with all the items needed. I also use Claude to list the most frequently bought items for a template that always gets filled in.
[−] robonot 44d ago
Awesome. Are you exposing the api to Claude or just copy pasting the data for it to analyze? How are you feeding it the data?
[−] wazHFsRy 44d ago
It is extremely simple. I just tell Claude: "Use korb to look at my order history and create a table with my most frequently bought items. Next time, fill my basket with the items I always buy." So something of that variation works.
[−] Bewelge 45d ago
Cool project, but have mixed feelings about publishing ever easier ways to access this API. They've locked down the API a while ago for a reason.

Also there already exists this reverse engineered project: https://github.com/ByteSizedMarius/rewerse-engineering/

I do have a suggestion for your app though: Have it compare your basket of goods across different markets in your region to show you the cheapest option. I'm pretty sure this possibility is actually one of the reasons they locked down the API.

I've used Data from REWE in the past and made a comparison between a couple of cities in Germany (I believe it was Frankfurt, cologne, Berlin, Munich and Hamburg). Hamburg was by far the most expensive, often as much as 10-20% more expensive.

[−] wazHFsRy 44d ago
The existing project was a great inspiration and helped me figure out the mTLS stuff. I totally get your mixed feelings, though.

I really like your suggestion. I will put it in an issue and look into that. https://github.com/yannick-cw/korb/issues/4

[−] Bewelge 44d ago
Just to be clear, my mixed feelings don't come from a moral standpoint. Just hoping they don't lock it down any further heh ;-)
[−] gigatexal 44d ago
An aggregator like this that could surface the same good for the cheapest price all inclusive of delivery would be something I would pay for!
[−] randomNumber7 44d ago

> I do have a suggestion for your app though: Have it compare your basket of goods across different markets in your region to show you the cheapest option.

This is a great idea. I just think the use case is not that big since REWE is the worst in the price/quality ration and just going to another shop would save you more.

[−] duskdozer 45d ago

>I do have a suggestion for your app though: Have it compare your basket of goods across different markets in your region to show you the cheapest option.

I'd settle for just being able to sort items by unit price... I'm sure this is a [regulation-]solved problem in Germany though

[−] Bewelge 44d ago

> I'd settle for just being able to sort items by unit price

What do you mean? The official REWE app and website provide just that.

> I'm sure this is a [regulation-]solved problem in Germany though

Not sure what you mean by that.

[−] duskdozer 44d ago
Sorry, yes, I'm not German and haven't used it. It was an idle complaint about how trying to use grocery store (or other similar) sites is difficult because they prevent you from being able to sort properly, for example by unit price. Sometimes they change the displayed unit per product so you also have to convert them to compare manually (less of a problem for metric, but like, drink brand 1 €2/100ml, drink brand 2 €13/1L etc).

As I was writing it, I realized that this kind of tactic just feels like it would be banned in Germany

[−] tstenner 44d ago
Stores are required by law to provide the price per unit/weight/volume alongside the price, so you can directly compare the price of a pint of beer to the 0.33 liter bottle without calculating anything.
[−] Bewelge 44d ago
Ah thanks, didn't think about that.

I just checked and REWE only lets you sort by absolute price. But honestly, you can compare prices so much better on their website than in a physical supermarket already [0].

[0] https://www.rewe.de/shop/c/frisches-obst/?sorting=PRICE_DESC You have to enter a random zip code eg 20249

[−] wazHFsRy 44d ago
there is this "400g (1 kg = 3,48 €)" - would be pretty easy to sort results by that I'd guess, good idea!
[−] abdusco 44d ago

> Compare process across different markets.

Check out smhaggle app on Android

https://play.google.com/store/apps/details?id=com.smhaggle.a...

[−] Bewelge 44d ago
Oh nice, thank you. Will check it out later!

What I suspect though: They mainly show current discounts. The REWE API exposes those as a separate list for each market. There's around 3.5k markets and each can set their own discounts and has their own product catalogue with their own pricing.

So it would be 3.5k API calls to fetch all offers for all markets. Which is doable.

But fetching all products takes like 100 calls per market. It's quite a bit of data. And I think most supermarket don't publish their catalogue at all since they don't have delivery options.

[−] aweiher 44d ago
2.8 rating in Play Store sounds bad
[−] vessenes 44d ago

  > The suggestion engine (korb suggestion threshold) is re-implemented in Lean 4 with five mathematically proven properties: suggestions have positive frequency, are sorted descending, come from ordered and available products, exclude basket items, and respect the count limit.
This is amazing. I mean this literally in that I am amazed, but also figuratively in that I am delighted to watch the type-safe-mad build cool shit.
[−] wazHFsRy 44d ago
Thank you. Though I have to say I'm really not an expert in that domain and just starting to explore it myself.
[−] atollk 44d ago
As a SWE at Rewe (at a completely different department), I can say that I find this pretty cool. I wonder if this is going to be a wakeup to management to relax the API restrictions.
[−] aweiher 44d ago
Please pitch internally for an official Rewe MCP server.

This is the future of doing groceries. Let us login with our credentials and let us do the search/filling the cart with agents.

Totally fine to do the payment only on the web, so everyone can be sure they only order what was wished, and not 300 avocados.

[−] atollk 43d ago
That's a good idea and actually was my first thought too. I sent a chat message so the product owner in charge is aware of the interest in something like it.

I think a big issue here is the lack of standard - there is no established way of where an MCP server should be hosted so that agents are easily able to find it. Right now, the best solution I could think of would be to serve it at something like rewe.de/shop/mcp and you'd manually have to register it with your agent.

[−] wazHFsRy 43d ago
Nice thank you. If something came out of this that would be amazing. I am not the biggest fan of mcp, as they are a waste of tokens though. I shot you a message on LinkedIn as well, was wondering if this caused some discussion internally at Rewe because it was immediately blocked.
[−] atollk 42d ago
I agree, regarding MCP. But also, it's the best thing we currently have, as far as I know. If you're aware of a better alternative, let me know.
[−] kleiba 44d ago
...or to tighten them.
[−] rvz 44d ago
You should tell them to charge for the API.
[−] wazHFsRy 44d ago
I mean, definitely leads to me buying more stuff on Rewe than before.
[−] splike 45d ago
That's funny, I've just built the same thing for Asda in the UK https://github.com/markDunne/asdabot

It can search for items, add them to the basket, picks a delivery slot and does the checkout.

With a little more scaffolding in markdown files, this now takes care of my weekly shopping.

[−] Latitude7973 45d ago
Even a CLI interface would be better than the sorry excuse of Asda's website. I wonder if entrusting an LLM is worth the trade off with the tedium of online shopping.
[−] wazHFsRy 44d ago
I want to add something else to this. In the process of writing this, I also played with formal verification and formally verified the suggestion engine, which was a really nice side discovery.

The basic idea is to write a prove in Lean4 and then test both the production implementation (Haskell) and the Lean implementation against random inputs. Compare if the results are the same.

If that is the case -> you can be pretty sure the unproven production version is as correct as the proven lean version.

https://www.dev-log.me/formal_verification_in_any_language_f...

[−] ramon156 44d ago
Serious good use of an AI. Just let them do the grey area (like repeated purchase). I'd even let an algo pick better groceries for me. Cools tuff!
[−] wazHFsRy 44d ago
Absolutely. For example, I want to ask it: Suggest me some vegetables I haven't ordered in recent weeks or stuff like this, and this is all possible.
[−] aprilnya 44d ago
Could even ask it to find recipes and then have it buy the ingredients needed for them next time it's doing your shopping!
[−] dewey 44d ago
Ideally it should also look up if they are currently in season in your location, so many possibilities!
[−] wazHFsRy 44d ago
You can already filter by isRegional. That's maybe close enough.
[−] son3tt 45d ago
Really cool, but this is also how you end with 300 avocados and 500 L of detergent.
[−] stavros 45d ago
Well of course, how else am I going to make my Tideamole?
[−] hk1337 44d ago
This reminds me of pizza party cli app way back late 90s or early 2000
[−] rmoriz 45d ago
Surprised how little the B2C and even B2B e-commerce segment is providing API access for automation and agentic coding. One could easily set up rate limits, fraud detection and KYC checks upfront initial access.
[−] PurpleRamen 44d ago
Normal customers are not paying for APIs, so there is little value in offering them for free, especially when it can be harmful. B2B sometimes does pay for them, but not always is it obvious from the outside that they even exist. Much commerce is also on tight numbers and thus kinda secretive about their stuff.
[−] wazHFsRy 44d ago
Yeah, absolutely. I think internally, everyone is cooking up some gigantic commerce. This is just bringing it to myself a bit earlier.
[−] Bewelge 44d ago
B2B: Look at chefkoch.de They do use the REWE API, and I'm guessing not without their knowledge

B2C: Is it really surprising that a busines has no interest in providing more price transparency to their customers?

[−] rmoriz 44d ago
When Amazon launches an API everyone cries. Same story over and over. Even better example: TakeAway-Group. The perfect MITM.
[−] Bewelge 44d ago
Think it's context dependent whether it's a good or bad thing.

The owners of German supermarket and car companies are really the richest of the rich in Germany (okay and maybe the SAP guy on top). It would definitely be a net positive if someone manages to scrape and compare their prices.

In the restaurant market it's one player abusing many small players.

And honestly, I think the reason everyone cries when "Amazon launches an API" is because Amazon would not dare to piss off the German supermarket oligopoly.

[−] dewey 44d ago

> It would definitely be a net positive if someone manages to scrape and compare their prices.

There's a few projects doing that for DE / AT at least.

[−] Bewelge 44d ago
Can you share them? I recently looked for such projects and didn't really find anything that works well.

The issue is that each market sets their own prices and I believe REWE is the only large one where you can fairly easily scrape the product catalogue. I thought about it in a shopping list context, so you'd need to make it location dependent to be useful. But you could do a lot of cool things with it. Like choose a basket of goods and it creates a route for you: "Go to supermarket A and buy goods XYZ, then to supermarket B and buy ABC"

[−] dewey 44d ago
There's this one which got some publicity, doesn't seem to be updated any more but it worked for all these retailers listed and is open source: https://github.com/badlogic/heissepreise

https://www.supermarkt.at https://preisrunter.at https://sparpionier.com

[−] traceroute66 44d ago

> B2C: Is it really surprising that a busines has no interest in providing more price transparency to their customers?

Might I suggest you remove your tin-foil hat and consider that:

   - 99% of REWE customers almost certainly have no clue what an API is
   - 99% of the remaining 1% know what an API is, but their day-job involves messing with APIs, so they don't want to spend their weekend-time messing with the REWE API, they just want to do their shopping at REWE.
   - The final 0.1% are those who come on HN and pretend its all some sort of big conspiracy to minimise transparency by $evil_corp. :)
If you think about it, imagine if REWE officially exposed an API B2C. This would mean they are obligated to provide support.

Do you really want the price of your shopping to increase because REWE now needs to find money to pay for a helpdesk for the millions of B2C API users ?

Businesses and services differentiating between B2C and B2B is nothing new, that is why the two different terminologies exist !

What next, you don't want to fill up your car at the petrol station (B2C) but you want to be permitted to buy a barrel crude oil direct from the drill and refine it yourself (B2B) ?

[−] Bewelge 44d ago

> Might I suggest you remove your tin-foil hat and consider that:

First up: Read and follow the rules. No need to insult me. Especially considering what you said shows that you both misunderstood AND misrepresented what I've said.

And frankly, my reasoning was simply saying "Company won't publicize internal info if they don't get an advantage from doing so". It's literally the same reason Google doesn't publish all of their source code. I'm struggling to see what part you are misunderstanding but it has to be something extremely basic to conclude I'm a conspiracy nut for basically stating "Company acts in their interest".

Opening an API to the public allows third parties to develop apps that can then be consumed by end-consumers. Not trying to be offensive here, but do you know what an API is? To conclude I meant every single end-consumers building their own app is at best disingenuously twisting my words.

Opening the API would allow new players like you and me to enter the market and take a piece of the pie. Why would a market, dominated and controlled by a few big players, opt for that? You don't even need to know that the German grocery market is incredibly price competitive, to understand that.

> If you think about it, imagine if REWE officially exposed an API B2C. This would mean they are obligated to provide support. Can you provide a source for that requirement? I'm pretty sure you just made that up.

> Businesses and services differentiating between B2C and B2B is nothing new, that is why the two different terminologies exist ! At this point I'm entirely lost what you read in my comment. Yes I know. I specifically made that distinction.

> What next, you don't want to fill up your car at the petrol station (B2C) but you want to be permitted to buy a barrel crude oil direct from the drill and refine it yourself (B2B) ? Yeah you definitely misunderstood something... What I said/meant:

The question: Why isn't the API open?

My answer: For B2B I gave an example where the API is used by another German firm, providing an example that the API is indeed consumed B2B.

For B2C: They have no reason to do so. They have a well functioning app where you can order stuff. They have one of the bigger recipe pages (at least it does very well SEO-wise) in Germany where you can immediately order ingredients from a recipe. The biggest recipe page in Germany (chefkoch) offers a direct link from recipes to their order page. Maybe you're missing this info? Thinking it's an internal API to data that isn't exposed anywhere at all would somehow explain whatever you tried to say here. But again, if you're that uninformed, don't insult people.

[−] traceroute66 44d ago

> Opening an API to the public allows third parties to develop apps that can then be consumed by end-consumers. Not trying to be offensive here, but do you know what an API is? To conclude I meant every single end-consumers building their own app is at best disingenuously twisting my words.

Here you are wrong too.

If you want to develop an app via an API that is only offered B2B, what do you do ?

Yes, that's right ...

You phone up REWE and negotiate a license to access to the B2B API to develop your application. B2B2C if you want to put it in simpler terms.

My original point stands. REWE clearly do not want to officially expose the API B2C, almost certainly for the exact reasons I already spelled out in my original post.

But no, its easier for you just to spread FUD, claiming "busines has no interest in providing more price transparency to their customers" just because they will not let you have access to the API as direct B2C.

[−] Bewelge 44d ago
Haha man, I think this is a cool project, the REWE API is cool, the REWE delivery App and Website are cool. Certainly not spreading fear, uncertainty or doubt.

What you describe as B2B2C is exactly what chefkoch does. And it's exactly what I initially said, so I'm not sure what point you're trying to make. But anyway. Doesn't feel like we're getting anywhere. Have a great day ;)

[−] rmoriz 42d ago
They will lose. The only areas Germany can compete, are that with broad APIs. Take HBCI/FinTS for banking. Go API or go out of business. I‘m pretty sure Piknik and Flaschenpost will offer agentic agent compatible APIs at some point.
[−] Dominik1001 45d ago
Very cool! Thanks for sharing, I’ll try it out.

Haskell is indeed an interesting choice. ;)

[−] rvz 45d ago

> Finally the best side projects are the ones you actually use and this one will be used for all my future grocery shopping.

Until it breaks in a few weeks.

[−] wazHFsRy 44d ago
I mean, fixing small issues is not a big deal – during my ordering sessions, if something comes up, I actually just let Claude create an issue for it, and then when I have time, I create a fix.
[−] rvz 44d ago
Well you don't control the API so it will still break.
[−] wazHFsRy 43d ago
It took hours not weeks. You were absolutely right.
[−] danielszlaski 45d ago
I love the idea of a CLI for groceries. Do you have plans to support 're-order' scripts or meal-plan integration? I can imagine a workflow where a recipes.yaml file gets piped into your CLI to automatically fill the cart with everything needed for the week. Much faster than clicking through a mobile UI.
[−] wazHFsRy 44d ago
Absolutely, that could just be a small script or something on top that calls the CLI tool
[−] wklm 45d ago
Nice! Do you know if the Austrian billa (REWE's subsidiary) is using the same api?
[−] elAhmo 45d ago
This could be helpful: https://heisse-preise.io
[−] fractallyte 45d ago
My friend works at Billa AT; I could ask her – but that would be cheating ;-)
[−] stavros 45d ago
What's the point of this comment!
[−] braedonwatkins 45d ago
I remember a friend and I in college were looking into ways to do this in the US but major grocery chains here are pretty sensitive about their product data being accessible by open APIs and web scraping...

It would have been a cool project!

[−] bronco21016 44d ago
Kroger does have an open API with some limitations that get you pretty far. Someone built a python wrapper and MCP for it awhile back. [1]

The workflow in our house is basically to use Siri to add items to an iOS Reminders list as the week goes on. Then, the day of or day before we plan to shop we fill-in with commonly purchased items or one-off things and go shop.

It's been on my TODO list to have an agent "skill" take the Reminders list, ask for additional items, and populate the cart to schedule a pickup. We tend to prefer going in the store though to browse the produce because our local Kroger isn't great about that. Pickup is generally reserved for the weeks where we're feeling a bit short on time.

[1] https://github.com/CupOfOwls/kroger-api

[−] kls0e 45d ago
this feels a bit like Sandra Bullock ordering pizza in „The Net“, impressive
[−] sigr_ 45d ago
Really cool to see things still being built in Haskell! How do you find using it compared to some of the newer languages that have more modern tooling?

Did you implement your own OAUTH2 flow in haskell for this?

[−] wazHFsRy 44d ago
For me, Haskell is the language of 2026. Having an agent available if you get stuck with some weird type error is a blessing. It also helps with the tooling. Though the modern tooling with cabal is pretty good.
[−] karim79 44d ago
I want to use this but I literally have a Rewe 20 meters (at most) from the entrance to my building. Still I might give it a go considering all the positive comments in the thread.
[−] ramonga 45d ago
Funny enough I was looking at rewe network requests for a personal app that suggests weekly meals and automatically orders the ingredients for you
[−] silbercue 42d ago
been ordering from REWE for years =) always wished the app was less annoying. all my programm skills - for what? lol. probs for reverse engineering the mTLS part, most people would have just given up.

how stable this is in practice? Internal APIs tend to break without warning when they update the app.

[−] a012 45d ago
It’s one step closer to have an agent to go shopping for my recipes or dinner, but hopefully unlike the Son of Anton
[−] tietjens 45d ago
Love this! Super cool.
[−] grimm8000 44d ago
Why say CLI instead of AI agent?
[−] kylex-ken 44d ago
supper cool, would be great if you can onboard different services.
[−] edinetdb 43d ago
[flagged]
[−] edinetdb 44d ago
[flagged]
[−] zephyrwhimsy 44d ago
[flagged]
[−] zephyrwhimsy 44d ago
[flagged]
[−] volume_tech 44d ago
[flagged]
[−] MORPHOICES 45d ago
[dead]
[−] zephyrwhimsy 44d ago
[flagged]