Ephigenia / ikea-availability-checker

Command-Line-Script & Library for checking the availability of specific IKEA products in specific stores and/or countries.
MIT License
233 stars 39 forks source link

403 for all request to US stores #100

Closed ad2001 closed 2 years ago

ad2001 commented 2 years ago

Similar to https://github.com/Ephigenia/ikea-availability-checker/issues/93, All US stores are returning 403 error code starting probably a couple of days ago. Someone has already reported the same issue in that closed issue: https://github.com/Ephigenia/ikea-availability-checker/issues/93#issuecomment-1085531238

JK-TC commented 2 years ago

Looks like IKEA has changed up their API. Subscribing in hopes that somebody finds a workaround.

Ephigenia commented 2 years ago

Yes, more and more countries don’t work anymore. I’m planning to create a smoke test shell script that tests every country and puts the results in a table. If someone wants to contribute … it‘s welcome :)

okniazik commented 2 years ago

All PL stores are returning 403 error code too...

derpingit commented 2 years ago

subbed. same problem. hope this project gets revived.

JK-TC commented 2 years ago

For those that are just hopiing to check for availablity on a specific product, I found an endpoint that works. It's the one that is getting called from the product page on their site (USA). I'm sorry, I'm not able to see how this works for other countries right now, but hopefully it helps some people out or starts them down the right path.

Here's an example request: https://api.ingka.ikea.com/cia/availabilities/ru/us?itemNos=20487415&zip=32746&expand=Restocks,SalesLocations.

You'll need to pass some header params, here's what I'm usng just to mimic the web browser. Your client id needs to be unique and you can get one from inspecting requests to the same endpont in your browser.

'x-client-id': <insert client id here>
'accept': 'application/json;version=2',
'accept-encoding': 'gzip, deflate, br',
'accept-language': 'en-US,en;q=0.9',
'origin': 'https://www.ikea.com',
'referer': 'https://www.ikea.com/',
'sec-fetch-dest': 'empty',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'same-site',
'sec-gpc': '1',
'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36'
Ephigenia commented 2 years ago

@JK-TC thanks for that hint! I’ll investigate this

Ephigenia commented 2 years ago

The api.ingka.ikea.com API doesn’t support all details but at least the current stock available for pickup and the restore probability.

The API requires just the "x-client-id"-header to be present and contain a valid API key. For US stores the API key used in the Browser is "da465052-7912-43b2-82fa-9dc39cdccef8" and works:

curl 'https://api.ingka.ikea.com/cia/availabilities/ru/us?itemNos=00494394&expand=StoresList,Restocks&' \
-X 'GET' \
-H 'x-client-id: da465052-7912-43b2-82fa-9dc39cdccef8'
{
    "availabilities": [
        {
            "buyingOption": {
                "cashCarry": {
                    "availability": {
                        "probability": {
                            "thisDay": {
                                "messageType": "HIGH_IN_STOCK"
                            }
                        },
                        "quantity": 2
                    },
                    "unitOfMeasure": "PIECE"
                }
            }
            "classUnitKey": {
                "classUnitCode": "026", // store code
                "classUnitType": "STO"
            },
        }
    ]
}

I’ll make adjustments to the code so that this API also works.

Ephigenia commented 2 years ago

The ingka api works for all countries except for russia:

countryCode iows2 ingka
at
au
be
ca
ch
cn
cz
de
dk
es
fi
fr
gb
hk
hr
hu
ie
it
jo
jp
kr
kw
lt
my
nl
no
pl
pt
qa
ro
ru
sa
se
sg
sk
th
tw
us
derpingit commented 2 years ago

Hi @Ephigenia thank you very much for this wonderful project. Could you plz point me In the right direction on how to mod the script to use that API ? I'm a non-programmer searching us stores . Stay awesome

Ephigenia commented 2 years ago

This package uses the undocumented iows2 api by IKEA which doesn’t work for several countries anymore: be, cn, fi, fr, gb, hk, ie, jp, kr, my, pl, ru, sg, th, tw, us

If you want to get availabilities for those countries please consider testing the alpha channel of this package by installing the "2.0.0-alpha.1" version:

npm install -g ikea-availability-check@2.0.0-alpha.1

Please report any bugs related to this alpha in the issues: https://github.com/Ephigenia/ikea-availability-checker/issues

Ephigenia commented 2 years ago

Please consider rating this package: https://openbase.com/js/ikea-availability-checker 🙇‍♂️

BHSPitMonkey commented 2 years ago

Thank you!

Note: There's a typo in the npm command in the above comment. It should read:

npm install -g ikea-availability-checker@2.0.0-alpha.1

(check -> checker)

Ephigenia commented 2 years ago

@BHSPitMonkey thanks! Got it fixed.

okniazik commented 2 years ago

Hi, I'm trying to test the alpha channel, and I do npm run start -- stock --country pl 80382321. Got an error TypeError: Cannot read properties of undefined (reading 'stock') at C:\ikea\node_modules\ikea-availability-checker\source\cli-stock.js:152:65 at Array.filter (<anonymous>) at C:\ikea\node_modules\ikea-availability-checker\source\cli-stock.js:152:32 at processTicksAndRejections (node:internal/process/task_queues:96:5)

Ephigenia commented 2 years ago

@okniazik I’ve created an issue for this, will be fixed in a few minutes …