-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Breaking API change 03/2024 - 404 Error #19
Comments
Hi, Also, a note: I'm not sure if they changed the market-ids in general. When I used your script I got a market-id back with even the right adress of the market etc., so I thought it was right, but it didn't work. Don't know if this will help you and if this is the solution you had in mind. But anyway I wanted to try to because your work here helped me anyway! Never had thought you could use the API of REWE just like that. Keep up the good work! :) |
If I interpret the first link of yours correctly, it shows all products from the Rewe Lieferdienst, which is unfortunately not a list of current discounts. My Rewe store for "testing the script" yields a NO_HIT response, so the URL is not globally valid. Regarding the market-ids, I could not reproduce your finding, as running the script with the PLZ from your store yields the correct market-id. Did you use the correct PLZ?
So thanks for your much appreciated feedback, but it's not the solution yet :( |
About the market-ids: Sorry, you're right! I actually had a typo and didn't notice... :D You're right, unfortunely my link doesn't show the current discounts. I'll keep trying to find a way to get them! :) |
I might have found something that could lead to a solution: This might be a good start. Now we have to find out how all discounted products can be requestet at once. What I didn't find yet: At the overview of the discounted products I don't find such a request for the data although it kind of has to be there. So I don't know how to make the request yet. I will try it further but maybe someone else will be faster than me with the API-request I posted. Edit: Noticed that you mentioned the URL-scheme in the other issue topic. But maybe it's at least good to know that it still works. |
I've been using the API you call "less elegant" for some time now and found this issue today, looking into why it stopped working. From what I can tell, all APIs (both browser and mobile) are now using fully cloudflare'd, WAF'd and fingerprinted endpoints. If you're curious, the app uses I've mostly given up on fighting cloudflare for projects that "just need to run", so I've gone back to just getting the raw html and parsing it with soup. This requires a vm and a sketchy ahk script, but I already have those things anyways and that has been working mostly well for similar projects for eons. |
Maybe the VM way is the way to go. Incidentally, for I'll check if the selenium approach still works (although it seriously inflates the dependencies). I can't give an estimation on the timeline, as I'm busy with other tasks at the moment. |
I suspect you will have issues with cloudflare using selenium aswell, but good luck nontheless. |
I've built something similar a few months ago - unfortuntately also stopped working. :( |
Addon not Working. |
I took a look at the rewe app which uses these two endpoints: https://mobile-api.rewe.de/api/v3/market/search?search="zipcode" for getting market ids in the area. You have to use the same headers that the app uses and you have to specify a certificate and private key (both are in the rewe.apk). But since I'm not sure if you are allowed to distribute the certificate and private key I haven't made a pull request yet. (Maybe somebody has some insight into that issue.) For now I just added a description on how to get the private key and the certificate. (in my fork) |
Very nice! May I ask how you debugged the issue? |
Have confirmed that calling the api works using the certs. I started automating the process (both extracting the certificates but also extracting the password) described by @torbenpfohl in powershell as a learning excercise (currently trying to get a bit better at ps). It's currently quite messy but if anyones interested in beta-testing it, please let me know. Otherwise I will probably publish it at some point in june. Personally, I would advise against publishing the certificates |
@modelD-svg The certificate and private key I found while looking through the resources of the decompiled apk (decompiled with apktool); there I found the mtls_prod.pfx file which was password protected. But searching for mtls_prod in the source code gave only a few classes and in one of them was the password (as a integer-array). But all in all I took a lot of time and poking around in the source code + hooking a lot of functions. (was my first reverse engineering project though) @ByteSizedMarius |
@torbenpfohl, thanks for your great work. As stated there, I'm currently not able to rewrite this program, so in case you want to create a new main repository for further development, go ahead. |
I will start adding to my repository over the weekend, however I'll do a first draft in Go. If someone else (maybe torben) wants to maintain a python script, I'll just do Go, otherwise I'll do both at some point |
Added a python script that gets the key and certificate. But I haven't done extensive testing yet. |
same :) |
Thanks @ByteSizedMarius, I added a link in the README to your repository as well. |
Does anyone know why they don't include GTINs/EANs in the mobile api? I have products in my database with their GTIN so that I can compare offers across different supermarkets. Unfortunately the API that provides GTINs doesn't work anymore |
Don't know -- probably because they don't need it for the discounts specifically ;) But theres a workaround: The discount api returns an article-no, for example
You can then just query this number to get the ean, like this:
This returns the ean
hope that helps! I also probably wouldn't say too loudly that you want to compare across stores because I suspect thats what they specifically don't want you to do ;) wouldn't want them to lock down even further ^^ |
Thank you! Hahah yes, probably you are right! Its a shame that it is made difficult on purpose for consumers. |
hey, is it possible to fetch products? i already tried this: https://mobile-clients-api.rewe.de/api/products?query=7181145&page=1&objectsPerPage=20&sorting=RELEVANCE_DESC but it isnt working for me i get a error { |
For the exact url you posted, I get 400 because of some missing headers (with the required certificates). You should get a 403 when missing the certs. Honestly no clue how you could be getting a 404 |
"ruleVersion": "2" gets me from a 400 response to a 404. |
no need to check as I was just playing around with them :) these are the special headers required for the request:
the rest is optional. zips can be anything, just not empty (they are only used if service-type is delivery). the other headers are like all the other requests. edit: sorry, youre right. marketid is required for the |
|
you need a marketid for the products endpoint, just corrected my response. sorry |
so how should the request look like? |
some of these headers are optional, this is just what I generate currently |
|
Yes, it's working. What is the response? It usually tells you what's wrong. Also don't reuse my rdfa/correlation-id. |
Maybe this is helping more thats my code written in py: |
there are headers missing |
thank you its working now ! |
Hey, it's me again, my website is finished, now I get problems when I want to fetch the products on the server, I get with the same api that works locally “{ |
I don't think there is a whitelist.. |
Hello, thats my py code:import os from get_creds import get_creds router = APIRouter() PRIVATE_KEY_FILENAME = "private.key" def fetch_products(
@router.get("/products") |
like exactly that code is working locally and on my vps not |
i also build a curl request thats working locally and on the vps not curl -X GET "https://mobile-clients-api.rewe.de/api/products?categorySlug=regional&objectsPerPage=30&page=1&query=*&sorting=TOPSELLER_DESC" -H "A-B-Test-Groups: productlist-citrusad" -H "Connection: Keep-Alive" -H "Correlation-Id: 03c04a7f-f3b2-45e7-a015-168f672c7341" -H "Host: mobile-clients-api.rewe.de" -H "Rd-Customer-Zip: 67065" -H "Rd-Is-Lsfk: false" -H "Rd-Market-Id: 831002" -H "Rd-Postcode: 67065" -H "Rd-Service-Types: PICKUP" -H "Rdfa: 3d85e18e-d6df-4f53-8e71-4b3d68c1b3ee" -H "User-Agent: REWE-Mobile-Client/3.18.5.33032 Android/14 Phone/Samsung_SM-S911B" -H "X-Rd-Customer-Zip: " -H "X-Rd-Market-Id: " -H "X-Rd-Service-Types: UNKNOWN" --cert private.pem --key private.key |
Can you show what the curl request (with --verbose added) on your VPS prints out? |
yes give me a min |
curl request: curl -X GET "https://mobile-clients-api.rewe.de/api/products?categorySlug=regional&objectsPerPage=30&page=1&query=*&sorting=TOPSELLER_DESC" -H "A-B-Test-Groups: productlist-citrusad" -H "Connection: Keep-Alive" -H "Correlation-Id: 03c04a7f-f3b2-45e7-a015-168f672c7341" -H "Host: mobile-clients-api.rewe.de" -H "Rd-Customer-Zip: 67065" -H "Rd-Is-Lsfk: false" -H "Rd-Market-Id: 831002" -H "Rd-Postcode: 67065" -H "Rd-Service-Types: PICKUP" -H "Rdfa: 3d85e18e-d6df-4f53-8e71-4b3d68c1b3ee" -H "User-Agent: REWE-Mobile-Client/3.18.5.33032 Android/14 Phone/Samsung_SM-S911B" -H "X-Rd-Customer-Zip: " -H "X-Rd-Market-Id: " -H "X-Rd-Service-Types: UNKNOWN" --cert private.pem --key private.key --verbose |
response: Note: Unnecessary use of -X or --request, GET is already inferred.
|
do you know how to fix it? |
Not sure, yet. |
okay i will try that, thank you |
but if its not working, are there other methods where i can host my py backend to use it? |
update: ok i saw now that you are already able to fetch the API just not on the VPS, in that case ignore my comment not sure if it helps but i am able to fetch the products (in my forked heissePreise repo) via:
and then
|
is the script hostet somewhere? |
Yes it is hosted in a docker container on my local server fetching prices every day from my home I. but not on a cloud server environment if that is the question. |
maybe check if the vps's IP is on a blacklist. https://mxtoolbox.com/blacklists.aspx if it's not the certificates (make sure its not the certificates somehow!) no idea |
Homeserver (e.g. raspberrypi) might be the way to go.. but honestly I have no experience. Adding to @ByteSizedMarius maybe check the route as well (traceroute mobile-clients-api.rewe.de). And try using a VPN (e.g. protonvpn has a free tier). |
The new API introduced in
v2.6
(#17, #18) seems to be broken due to a change by REWE, it now yields a 404 error:Right now, I have no solution available and the script will not work. If you find the correct API url, please let me know.
The text was updated successfully, but these errors were encountered: