PVKStats API

chillychilly Senior, Drunk and Disorderly
edited 11:11PM in PVKII Server Stats
With Bojero making custom sigs by scraping the stats page, I decided to open up the stats data a bit more, so I knocked up an API to allow access to player data.

The API is a simple HTTP GET based thing that returns JSON strings. Currently only player info is available, but if you would like other data, let me know and I'll slap it in there.

As an example of what player data is available atm, check this link: http://jbnc.net/stats/json.php

Access to the stats api is by application only, but it is of course free.

So, any developers out there feel like doing something interesting with the stats info, post in this thread or PM me and I'll provide you with an API key and a very brief PHP example of how to consume it.

Cheers,
Chilly
move along

Comments

  • BojeroBojero Senior
    edited May 2009
    The getData function used for my signature. It returns an array with all the information on the player with the steamID input via paramater.

    CODE
        function getData($steamID, $apiKey)
        {
            $JSON = file_get_contents('http://www.pvkstats.com/api/player.php?sid=' . $steamID . '&key=' . $apiKey);
            $data = json_decode($JSON, true);
            return $data;
        }


    That's basically all you need, then all the data is accessible via the array.
    Signature Coming Soon.
  • chillychilly Senior, Drunk and Disorderly
    edited 11:11PM
    cheers bojero, easy as pie!
    move along
  • MaydayMayday Engineering Supreme Senior
    edited 11:11PM
    what the fuck
  • BojeroBojero Senior
    edited 11:11PM
    QUOTE (Mayday @ May 3 2009, 12:56 AM) »
    what the fuck


    This be for programmers, don't worry yer head over it. biggrin.gif
    Signature Coming Soon.
  • chillychilly Senior, Drunk and Disorderly
    edited 11:11PM
    QUOTE (chilly @ May 2 2009, 07:58 PM) »
    cheers bojero, easy as pie!



    If it helps I can change all your names again.
    move along
  • MaydayMayday Engineering Supreme Senior
    edited 11:11PM
    please no
  • BojeroBojero Senior
    edited 11:11PM
    Here's an example in python using demjson to decode:

    CODE
    import urllib
    import demjson

    def getData(steamID, apiKey):
        url = 'http://www.pvkstats.com/api/player.php?sid=%s&key=%s' % (steamID, apiKey)
        connection = urllib.urlopen(url)
        data = demjson.decode(connection.read())
        return data

    player = getData('STEAM_0:1:13732759', 'yourKeyHere') #Using my SteamID as an example...

    server = player['favServers'][0]['name']
    name = player['name']

    print '%s\'s favourite server is %s!;)' % (name, server)
    Signature Coming Soon.
Sign In or Register to comment.