ckatzorke / howlongtobeat

A simple api for https://howlongtobeat.com/
Do What The F*ck You Want To Public License
338 stars 45 forks source link

403 error on requests #53

Closed alptonguc closed 1 year ago

alptonguc commented 1 year ago

While trying to get a response i am getting Error: Request failed with status code 403 the code was working fine 4 months ago but not anymore. Is it just me or this is normal?

alptonguc commented 1 year ago

Even npm.runkit is getting 403. I think there is a general problem.

ihascats commented 1 year ago

Same issue here, hopefully gonna be resolved soon?

ihascats commented 1 year ago

I couldnt wait tho, you can use this for searches (node.js fetch)

fetch('https://howlongtobeat.com/api/search', {
    headers: {
      accept: '*/*',
      'accept-language': 'en-US,en;q=0.9',
      'content-type': 'application/json',
      Referer: 'https://howlongtobeat.com/',
      'Referrer-Policy': 'no-referrer',
    },
    body: `{"searchType":"games","searchTerms":["${gameTitle}"],"searchPage":1,"size":20,"searchOptions":{"games":{"userId":0,"platform":"","sortCategory":"popular","rangeCategory":"main","rangeTime":{"min":null,"max":null},"gameplay":{"perspective":"","flow":"","genre":""},"rangeYear":{"min":"","max":""},"modifier":""},"users":{"sortCategory":"postcount"},"lists":{"sortCategory":"follows"},"filter":"","sort":0,"randomizer":0}}`,
    method: 'POST',
  });
bigjca commented 1 year ago

I ran into this issue as well and it appears to be happening because axios sets the user-agent header to 'axios', so if it is set to something else the call goes through. Opened PR to fix here: https://github.com/ckatzorke/howlongtobeat/pull/54

alptonguc commented 1 year ago

Fetch also did work but PR is working fine now.