Close
Showing results 1 to 10 of 17

Threaded View

  1. #1

    Default Google Docs script for pulling character information from the wow API

    This is a Google Apps Script I created to pull data about my toons from the wow/armory API.

    I use this to populate my google apps spreadsheet with my character lists and such with level/class/race/iLvl information.

    This is the second iteration and I am happy with it now. I might consider adding more, but it gets a bit convoluted and I almost prefer to just show anyone who wants more info how to modify it to show what they want...

    This gives output that looks like this now:

    Attachment 590
    This is what the second looks like, with per-item iLvl information. It gets very long horizontally, so I flipped it to vertical.

    Attachment 589

    The script's attached to this post and can also be seen here: (Installation instructions here)

    Code:
    /*
    
    Version 0.2 April 26 2012
    
    Changelog:
    
    0.2 - Added profession information
    
    --
    
    wow()function for google docs spreadsheet to gather information from the wow armory for a given toon-realm.
    
    Usage: =wow(toonName,realmName)
    
    This outputs Name, Class, Race, Level and iLvl for the given character.
    
    Example Output: (one in each cell in a row)
    
    Name: Destähd    Race: Blood Elf    Class: Paladin    Level: 85    iLvl: 368
    
    The Blizzard API is documented here:
    
    http://blizzard.github.com/api-wow-docs/
    
    Excerpts:
    
    Profile
    
    The Character Profile API is the primary way to access character information. This Character Profile API can be used to fetch a single character at a time through an HTTP GET request to a URL describing the character profile resource. By default, a basic dataset will be returned and with each request and zero or more additional fields can be retrieved. To access this API, craft a resource URL pointing to the character whos information is to be retrieved.
    URL = Host + "/api/wow/character/" + Realm + "/" + CharacterName
    
    Character Races
    The character races data API provides a list of character races.
    
    URL = Host + "/api/wow/data/character/races"
    
    Character Classes
    The character classes data API provides a list of character classes.
    
    URL = Host + "/api/wow/data/character/classes"
    
    The regions where this API is available are:
    
        us.battle.net
    
        eu.battle.net
    
        kr.battle.net
    
        tw.battle.net
    
        www.battlenet.com.cn
    
    */
    
    function wow(toonName,realmName) {
    //function wow(toonName,realmName) {
      
    //  var toonName = "Déstáhd"; //comment this out for actual usage... Tailor
    //  var toonName = "Destähd"; //comment this out for actual usage... no professions
      
    //  var realmName = "Magtheridon"; //comment this out for actual usage...
      
    // Character information
      var toonJSON = UrlFetchApp.fetch("us.battle.net/api/wow/character/"+realmName+"/"+toonName+"?fields=items,professions");
      var toon = Utilities.jsonParse(toonJSON.getContentText());
    
    // populate Race database
      var racesJSON = UrlFetchApp.fetch("us.battle.net/api/wow/data/character/races")
      var races = Utilities.jsonParse(racesJSON.getContentText());
          
    // populate Classes database
      var classesJSON = UrlFetchApp.fetch("us.battle.net/api/wow/data/character/classes")
      var classes = Utilities.jsonParse(classesJSON.getContentText());
    
    // Walk through races to find race name from the ID provided from the character dump.
      for (var r = 0; r < races.races.length; r++) {
        if (races.races[r].id == toon.race) {
          var toonRace = races.races[r].name;
        }
      }
    
    // Walk through classes to find class name from the ID provided from the character dump.
      for (var c = 0; c < classes.classes.length; c++) {
        if (classes.classes[c].id == toon.class) {
          var toonClass = classes.classes[c].name;
        }
      }
    
    // Professions information
      
      var ProfessionA = "none";
      var ProfessionB = "none";
      
      if (toon.professions.primary.length == 1) {
        ProfessionA = toon.professions.primary[0].name+" "+toon.professions.primary[0].rank;
      }
      
      if (toon.professions.primary.length == 2) {
        ProfessionA = toon.professions.primary[0].name+" "+toon.professions.primary[0].rank;
        ProfessionA = toon.professions.primary[1].name+" "+toon.professions.primary[1].rank;
      }
      
    // Collated information we're going to output...  
      var toonInfo = new Array(
        "Name: "+toon.name,
        "Race: "+toonRace,
        "Class: "+toonClass,
        "Level: "+toon.level,
        "iLvl: "+toon.items.averageItemLevel,
        "Profession: "+ProfessionA,
        "Profession: "+ProfessionB
      )
     
      Logger.log(toonInfo);
      return toonInfo;
    }
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by Destahd : 04-25-2012 at 09:14 PM

Posting Rules

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •