1

I have found a lot of information about that, but it still doesn't work :/

So I have this steam page in JSON format and I want to get lowest_price variable w/o PHP because I'm using it for my chrome extension. Help me, please.

supermishboy
  • 99
  • 11
  • Unless that URL is CORS enabled, or returns data in JSONP format, you cannot access it via Javascript due to the [Same Origin Policy](http://en.wikipedia.org/wiki/Same-origin_policy). You would need to use PHP, or any other server-side language, to make the request for you. – Rory McCrossan Aug 09 '15 at 14:26
  • But PHP doesn't work with chrome extension :c – supermishboy Aug 09 '15 at 14:28
  • Then I'm afraid you may be out of luck. – Rory McCrossan Aug 09 '15 at 14:28
  • As far as I know steam does that. I've answered on a similar question on StackOverflow. Look for it. – Mr.Web Aug 09 '15 at 14:29
  • Sorry I was mistaking subject perhaps, see here: http://stackoverflow.com/a/26983323/1995006 – Mr.Web Aug 09 '15 at 14:31

1 Answers1

1
fetch("https://steamcommunity.com/market/priceoverview/?currency=5&appid=570&market_hash_name=Huntling").then(function(response){
  return response.json();
}).then(function(response){
  console.log(response.lowest_price);
});

Or since you're using jQuery:

$.get("https://steamcommunity.com/market/priceoverview/?currency=5&appid=570&market_hash_name=Huntling", function(response){
  console.log(response.lowest_price);
});

If you're making an extension you need to configure it for CORS in the manifest: https://developer.chrome.com/extensions/xhr#requesting-permission Something like this:

{
  "name": "My extension",
  ...
  "permissions": [
    "https://steamcommunity.com/*"
  ],
  ...
}
Kit Sunde
  • 35,972
  • 25
  • 125
  • 179