League of Legends Wiki

Comments12

API project

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

This is a work in progress script that would convert the riot API in structured data:

api = api["data"];
var info;
for (var key in api) {
   if (api.hasOwnProperty(key)) {
      var obj = api[key];
      for (var prop in obj) {
         if(obj.hasOwnProperty(prop)){
            //console.log(prop + " = " + obj[prop]);
            if(prop === "id"){
               info += '<div id="'+ obj["id"] + '" class="item" name="' + obj["name"] + '" group="' + obj["group"] + '">';
            } else
            if(prop === "name"){
               info += '<h2 id="'+ prop +'">' + obj[prop] + '</h2>';
            } else
            if(prop === "into"){
               info += '<div id="'+ prop +'"><h3>Build Into</h3>';
               items = obj[prop];
               //console.log(items);
               for (i = 0; i < items.length; i++) { 
                  items2 = items[i];
                  console.log(api[items2].name);
                  info += '<li id="'+ items2 +'">' + api[items2].name + '</li>';
               }
               info += '</div>';
            } else
            if(prop === "stats"){
               info += '<h3>Stats</h3>';
               obj2 = api[key].stats;
               for (var prop2 in obj2) {
                  //console.log(prop2);
                  info += '<div id="'+ prop2 +'">' + obj2[prop2] + '</div>';
               }
            } else
            if(prop === "gold"){
               info += '<div id="'+ prop +'"><h3>Gold</h3><ul><li id="base">Base: ' + obj[prop]["base"] + '</li><li id="total">Total: ' + obj[prop]["total"] + '</li><li id="sell">Sell: ' + obj[prop]["total"] + '</li><li id="purchasable">Purchasable: ' + obj[prop]["purchasable"] + '</li></ul></div>';
            }
            else {
               info += '<div id="'+ prop +'">' + obj[prop] + '</div>';
            }
         }
      }
      info += '</div>';
   }
}
document.getElementById("items").innerHTML = info;

Also on Fandom

Random Wiki