-2

Ok, so I am relatively new to the javascript scene, and I just had a few questions based off of this post here: Getting CS:GO player stats. In the answer, Andy says "Your call will look like this" then he inserts this link:

http://api.steampowered.com/ISteamUserStats/GetUserStatsForGame/v0002/?appid=730&key=<<KEY>>&steamid=<<PROFILEID>>

What is the call he talks about and how do I use this link? Thanks!

Community
  • 1
  • 1
  • That's an API call, you will need to use AJAX or a framework like Angular (or Meteor, or Ember, list goes on) to that allows you to do HTTP requests. jQuery also comes with an $.ajax functionality out of the box. – Baruch Jun 08 '16 at 03:25
  • 1
    The expectation is to send an HTTP request to the address (this can be done client-side with [Ajax](https://developer.mozilla.org/en-US/docs/AJAX), barring the [SOP](https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy)), after replacing the `<>` and `<>` with appropriate values. – Jonathan Lonowski Jun 08 '16 at 03:25
  • https://en.m.wikipedia.org/wiki/Web_API – ale Jun 08 '16 at 03:25

1 Answers1

0

Assuming this is a RESTful API[1] then you need to make a HTTP GET, POST, PUT, or PATCH request to that URI to retreive or alter the resource (the concept of a "resource" is abstract is REST).

In JavaScript you use AJAX, which is shorthand for the built-in XMLHttpRequest object which makes HTTP requests for you. Using libraries like jQuery can further simplify this for you:

var xhr = new XMLHTTPRequest();
xhr.addEventListener("load", function() {
    console.log( this.responseText ); // got response, do processing here
});
xhr.open("GET", "http://api.steampowered.com/ISteamUserStats/GetUserStatsForGame/v0002/?appid=730&key=<<KEY>>&steamid=<<PROFILEID>>");
xhr.send();

[1]The endpoint you posted is not strictly RESTful because the resource path itself contains a verb: GetUserStatsForGame, if it were fully RESTful then the URI should look like this: /ISteamUserStats/Games/{gameId}/, but I digress.

Dai
  • 141,631
  • 28
  • 261
  • 374