2

I see that the Walmart Android app has an ability to capture the receipt barcode (seems to be the traditional 1D barcode and not the 2D QR code), then retrieve the electronic version of that receipt. It then adds that receipt to your "purchase history" in the app. Is this receipt API available? I'd like to capture data from Walmart receipts, but the poor quality of the receipts themselves causes numerous OCR problems.

I've looked at the WalmartLabs Walmart.io APIs and do not see the receipt API. I tried to ask this question there, but their "ask a question" form is broken (Submit button does nothing).

Russell
  • 21
  • 2

1 Answers1

4

Found this while investigating a similar question, and stumbled upon an answer. I am trying to build a tool that allows me to auto-categorize some purchases. Unfortunately, Walmart takes their security quite seriously and has implemented several measures to prevent running automated tools on their website (even with things like puppeteer-stealth)

However, today I found out that if you go to https://walmart.com/receipt-lookup, and check out the network tab—you can actually see a request goes out to https://walmart.com/chcwebapp/api/receipts and it only requires a few parameters:

{
   "storeId": number;
   "purchaseDate": string - MM-DD-YYYY;
   "cardType": string (ex. "visa")
   "total": number (ex. 100.89)
   "lastFourDigits": string (ex. "1234")
}

For completeness, an example cURL request:

curl 'https://www.walmart.com/chcwebapp/api/receipts' \
  -H 'sec-ch-ua: "Chromium";v="98", " Not A;Brand";v="99", "Google Chrome";v="98"' \
  -H 'accept: application/json' \
  -H 'Referer: https://www.walmart.com/receipt-lookup' \
  -H 'content-type: application/json' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36' \
  -H 'sec-ch-ua-platform: "Mac OS X"' \
  --data-raw '{"storeId":"123","purchaseDate":"02-19-2022","cardType":"visa","total":"100.00","lastFourDigits":"1234"}' \
  --compressed

It doesn't appear to require any type of authentication as a quick glance at the request shows no cookies!

I am ecstatic to have found this. I'm not totally sure if it will fit your needs, but since my tool already has access to the total, last 4, and date all I need is the storeId which I can easily hard-code since we only shop at one Walmart!


As an aside, if anyone from Walmart's engineering team ever sees this—please consider allowing the develop community access to their own data. I totally get implementing PerimeterX Bot Defense for things like PS5 releases, but blocking login attempts just to look at my own receipts? It seems like taking out an anthill with a bazooka.

FooBar
  • 419
  • 5
  • 14
  • How very interesting. Thanks for the detailed breakdown! – Russell Feb 21 '22 at 14:59
  • Does not seem to work. It sends a redirectURL /blocked and also gives a blockScript link as captcha.js. I think it needs to pass the Captcha. Very frustrating. – Milind Apr 30 '23 at 07:04
  • @Milind, yeah unfortunately I gave up on this approach late last year. It appears Walmart has followed in every other retailer's shoes and closed off what little tooling we had. At this point, a chrome extension is how I'm getting around needing to authenticate to see my own receipt data. – FooBar May 09 '23 at 05:30
  • Thank you! I was able to get it to work by just copying your code block and then applying my own computer's information to it. – janksmap Aug 25 '23 at 21:29