Help

API

TF2PlayerRankings.com provides a balancing api for any service that can make use of it. This is a simple rest api that accepts querystring values listing community ids, classes for those ids and an identifier for the service that the balancing should take it's performance records from.

The urls should be in the following format:
http://beta.tf2playerrankings.com/api/balancer?communityids=xxxx&classes=yyy&service=zzz
Where xxx is a comma delimited list of community ids, such as 76561197960274857,76561197960275138,76561197960269488... etc. This must be either 12 players long for 6v6 or 18 players long for Highlander. yyy must be a comma delimited list of classes with one entry for each corresponding community id. This sets the class for the player identified with the community id in the corresponding position in the communityids list, so if the first player in the communityids will be playing medic then the first entry in the classes list must be medic, and so on. zzz is a special hash value identifying the service, but to ensure the balancing api isn't open to just anyone this is an md5 hashed value. Add me to get the relevant hash for your project.

The id numbers that identify the classes in the url querystring are as follows:

  1. Medic
  2. Soldier
  3. Scout
  4. Demoman
  5. Sniper
  6. Pyro
  7. Spy
  8. Engineer
  9. Heavy
So for example the typical class list for a 6v6 team would look like 1, 2, 2, 3, 3, 4

The response from the balancer call can be in either xml or json format depending on the content of the Accepts header. By default this is usually xml, to get Json set the accepts header to Accept: application/json, text/json. If Xml is not being returned by default but you want it, try setting the Accepts header to: application/xml, text/xml

The response from the balancer api is relatively simple. There's a simple header (containing error information if there was a problem) and assuming things were successful a list of both teams. The layout should be similar to this, although in this example I've edited out most of the player entries:

<BalancedTeams>
   <ErrorMessage i:nil="true"/>
    <Team1>
        <BalancablePlayer>
            <classId>1</classId>  
            <commId>76561197960269488</commId>    
        </BalancablePlayer> 
        ...
    </Team1>
    <Team2>
        ...
    </Team2>
</BalancedTeams>
The Json version looks like this:
{
	"ErrorMessage":null,
	"Team1":[
            {"commId":76561197960269488,"classId":1},
            {"commId":76561197960274857,"classId":2},
            {"commId":76561197960274560,"classId":2},
            {"commId":76561197960274560,"classId":3},
            {"commId":76561197960274857,"classId":3},
            {"commId":76561197960274857,"classId":4}
	],
	"Team2":[
            {"commId":76561198036169670,"classId":1},
            {"commId":76561197960269488,"classId":2},		
            {"commId":76561197960274521,"classId":2},		
            {"commId":76561197960275138,"classId":3},				
            {"commId":76561197960269488,"classId":3},		
            {"commId":76561197960275138,"classId":4}
	]
}
Returned data is kept to the absolute minimum and no data about player's precise ratings or even their rank is given. It does show the most important thing however, which is the composition of the two most balanced teams.


TF2PlayerRankings.com © Gentleman Jon