matthew1232 / stockx-api

Easy access to StockX's unofficial API through promises.
173 stars 66 forks source link

Error scraping product details: Response code 403 (Forbidden) #26

Closed sswadkar closed 3 years ago

sswadkar commented 3 years ago

I just started using this API and wasn't able to scrape for product details.

I ran this snippet of code (yes I changed the user and password) and was able to successfully login.

const StockXAPI = require('stockx-api');
const stockX = new StockXAPI();

(async () => {
    try {
        console.log('Logging in...');

        //Logs in using account email and password
        await stockX.login({
            user: 'accountemailhere', 
            password: 'accountpassword'
        });

        console.log('Successfully logged in!');

        //Returns an array of products
        const productList = await stockX.newSearchProducts('yeezy');

        //Fetch variants and product details of the first product
        const product = await stockX.fetchProductDetails(productList[0]);

        console.log(product.name);
    }
    catch(e){
        console.log('Error: ' + e.message);
    }
})();

Unfortunately, I was met with this output

Logging in...
Successfully logged in!
Error: Response code 403 (Forbidden)

Then I tried running this snippet of code

const StockXAPI = require('stockx-api');
const stockX = new StockXAPI();

stockX.fetchProductDetails('https://stockx.com/adidas-yeezy-boost-700-magnet')
.then(product => console.log(product))
.catch(err => console.log(`Error scraping product details: ${err.message}`));

And was met with this output

Error scraping product details: Response code 403 (Forbidden)

I'm not sure if this is an error on my side, if there's some additional configuration I forgot to do or if it's an issue for multiple people (a similar issue from 2020 to this was unanswered).

sayansisodiya commented 3 years ago

I have the same problem. My program worked about a month ago but now I get "Response code 403 (Forbidden)"

mitjad123 commented 3 years ago

I have the same problem.

matthew1232 commented 3 years ago

Fixed in update 1.1.0, please download the new version and try again.

Anjal99 commented 11 months ago

Fixed in update 1.1.0, please download the new version and try again. @matthew1232 I am having trouble with running the API, ` const StockXAPI = require('stockx-api'); const stockX = new StockXAPI();

stockX.fetchProductDetails('https://stockx.com/adidas-yeezy-boost-700-magnet') .then(product => console.log(product)) .catch(err => console.log(Error scraping product details: ${err.message})); `

Ran this snippet and met with the following error:

Error scraping product details: Status code: 403 - body: ../node_modules/stockx-api/src/utils/../../test/body.txt Failed to write body: Error: ENOENT: no such file or directory, open '../node_modules/stockx-api/src/utils/../../test/body.txt'