StunlockStudios / battlerite-docs

Documentation and Guides
11 stars 1 forks source link

Filtering players by playerNames / steamIds #26

Closed jwells-github closed 6 years ago

jwells-github commented 6 years ago

Hi,

I'm trying to use the API to return player data from a given playername, but so far have been unable.

I have been able to receive player data by filtering by playerId, but this doesn't seem particularly useful as a player is unlikely to know their playerId.

Below is the code I have been using in Java to try and get player data

   URL url = new URL("https://api.dc01.gamelockerapp.com/shards/global/players?filter[playerNames]=Averse");
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();

    conn.setRequestMethod("GET");
    conn.setRequestProperty("Authorization"," Obviously removed my key");
    conn.setRequestProperty("Accept", "application/vnd.api+json");

    BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
    String inputLine;
    while ((inputLine = in.readLine()) != null) 
        System.out.println(inputLine);
    in.close();`

The response that I get from this request is as below, obviously this isn't the desired response.

{
   "data":[

   ],
   "links":{
      "self":"https://api.dc01.gamelockerapp.com/shards/global/players?filter[playerNames]=Averse"
   },
   "meta":{

   }
}

I have also tried filtering by steamId as a possible work around, but this results in a FileNotFoundException.

Any help would be appreciated!

jsmienk commented 6 years ago

Base URL endpoint is ‘https://api.developer.battlerite.com/‘, but sadly this was not updated in the docs yet. You will have to use this URL instead of the ‘dc01.gamelockerapp’ one.