1. How to use Warmane API

    Greetings warmane community,

    Before i start i want to thank a guy that started one thread ive seen long time ago where he posted website template with css already. Im Sorry i cant recall either thread link nor name. But if u r reading this, please tag yourself with a comment.

    What is exactly an api?

    You can think of API as a resource, a resource that is made by developers for you to use it and make an output with such resources.
    When it comes to warmane api, you get to have a huge json string or an array that will be displayed once you open an api URL such as:

    http://armory.warmane.com/api/guild/...stwolf/summary (example of my guild)



    You can notice that alot of player informations is there and free to use it on your external website or any kind of application.

    What can i do with warmane API?

    You can make a guild roster of your own that is fully automated as players join guild or leave.
    You can check whether the player is online or offline.
    You can display player informations such as race,level,achievement points, equipment, spec, professions,...

    Few images of how something like that looks like when warmane api is used.

    Guild roster:



    Player Armory:



    How do i use API?

    index.php


    Code:
    //Before the hmtl tag begin.
    //Rename "The+Sanctuary" with your guild name.
    <?php
            $json_string	=	file_get_contents("https://armory.warmane.com/api/guild/The+Sanctuary/Frostwolf/members");
    	$guild_string	=	json_decode($json_string);
    
    //TRANSLATIONS
    
    $var_name			=	"Name";
    $var_race			=	"Race";
    $var_class			=	"Class";
    $var_level			=	"Level";
    $var_achievementpoints  =	"Achievement Points";
    $var_online			= 	"Status";
    
    ?>
    
    //In HTML body tag.
    
    <html>
    <body>
    
    <table  class="sortable">
    	<thead>
    					
    		<tr>
    			<th><?php echo $var_online; ?></th>
    			<th><?php echo $var_name; ?></th>
    			<th><?php echo $var_race; ?></th>
    			<th><?php echo $var_class; ?></th>
    			<th><?php echo $var_level; ?></th>
    			<th><?php echo $var_achievementpoints; ?></th>					
    		</tr>
    	</thead>
    	<tbody>
    	<?php
                    //Decoding json string into an array.
    
    		$guild_roster = json_decode($json_string, true);
    		$guild_roster = $guild_roster['roster'];
    
                    //Looping trought an array and using its values.
    
    		foreach($guild_roster as $key => $value)
    		{
    			echo '<tr>';
    				echo '<td>' .($value['online'] > 0 ? "<font color='green'>Online</font>" : "<font color='red'>Offline</font>" ). '</td>';
    
                                    //What i did in next line of code is a link on a name to open a new page with user information. In my case the page is called 
                                    user_info.php with an ID extension which will be name, so its auto set for each name.(Check user_info.php tutorial how to fetch ID)
    
    				echo '<td><a href="user_info.php?id=' . $value['name'] . '">' . $value['name'] . '</a></td>'; 
    				echo '<td>' . $value['race'] . '</td>';
    				echo '<td>' . $value['class'] . '</td>';
    				echo '<td>' . $value['level'] . '</td>';
    				echo '<td>' . $value['achievementpoints'] . '</td>';
    			        echo '</tr>';
    				echo '</a>';
    		}
    	?>
    	</tbody>
    </table>
    </body>
    </html>
    user_info.php

    Code:
    //Before HTML tag.
    
    <script type="text/javascript" src="http://cdn.cavernoftime.com/api/tooltip.js"></script>
    
    <?php
    
    
    
    //In next 3 lines u can see how fetching an ID as a name works when its clicked on name of player at index table.So after we fetch it we push it to link so its generated for each name(at line 4)
    
    $url = $_SERVER['REQUEST_URI'];
    $url = explode("=", $url);
    $id = $url[count($url) - 1];
    $json_string	=	file_get_contents('http://armory.warmane.com/api/character/'.$id. '/Frostwolf/profile');
    $player_string	=	json_decode($json_string);
    
    ?>
    
    //In HTML tag
    
    <html>
    <head>
    
    <script>
    		var CoTTooltips = {
            /* Enable or disable the rename of URLs into item, spell and other names automatically */
            rename: true,
            /* Enable or disable icons appearing on the left of the tooltip links. */
            icons: true,
            /* Overrides the default icon size of 15x15, 13x13 as an example, icons must be true */
            iconsize: 15,
            /* Enable or disable link rename quality colors, an epic item will be purple for example. */
            qualitycolor: true,
            /* TBA */
            forcexpac: { },
            /* Override link colors, qualitycolor must be true. Example: spells: '#000' will color all renamed spell links black. */
            overridecolor: {
                spells: '',
                items: '',
                npcs: '',
                objects: '',
                quests: '',
                achievements: ''
            } 
    		};
    	</script>
    
    </head>
    <body>
    
    <table>
    	<thead>
    					
    		<tr>
    			<th align="center"><?php echo 'GEAR'; ?></th>
    			<th align="center"><?php echo 'MODEL VIEWER' ?></th>
    			<th align="center"><?php echo 'PLAYER INFORMATION' ?></th>
    						
    		</tr>
    	</thead>
    	<tbody>
    	<?php
    
                    //Equipment of player
    		$player = json_decode($json_string, true);
    		$player = $player['equipment'];	
    					
    										
    		foreach($player as $key => $value)
    		{	
    			echo '<tr>';
    
                            //This "a" link is basicly a warmanes cavernoftime tooltip and color changer.
    			echo '<td><a href="http://mop.cavernoftime.com/item=' . $value['item'] . '">' . $value['name'] . '</a></td>'; 
    			echo '</tr>';
    		}
    					
    					
    	   ?>
               </tbody>
               </table>
           //List that i use for player information right from viewmodel.
    
                <div class="playerinfo"">
    			<ul class="list-group">
    			<li class="list-group-item">Player name: <?php echo $player_string->name; ?> </li>
    			</br>
    			<li class="list-group-item">Race: <?php echo $player_string-->race; ?> </li>
    			</br>
    			<li class="list-group-item">Class: <?php echo $player_string-->class; ?> </li>
    			</br>
    			<li class="list-group-item">Level: <?php echo $player_string-->level; ?> </li>
    			</br>
    			<li class="list-group-item">Gender: <?php echo $player_string-->gender; ?> </li>
    			</br>
    			<li class="list-group-item">Honorable Kills: <?php echo $player_string-->honorablekills; ?></li>
    			</br>
    			<li class="list-group-item">Achievements: <?php echo $player_string-->achievementpoints; ?></li>
    			</br>
    			<li class="list-group-item">Professions: 
    			<?php
    			
                            //Professions and skill
     
    			$player= json_decode($json_string, true);
    			$player= $player['professions'];	
    					
    										
    					foreach($player as $key => $value)
    					{	
    						echo '<ul>';
    						echo '<li>';
    						echo  $value['name']; 
    						echo '(';
    						echo  $value['skill']; 
    						echo ') ';
    						echo '</li>';
    						echo '</ul>';
    						
    					}
    			
    			?>
    			</li>
    			</br>
    			<li class="list-group-item">Specializations: 
    			<?php
    			
                            //Player talents.
    
    			$player = json_decode($json_string, true);
    			$player = $player['talents'];	
    					
    										
    					foreach($player as $key => $value)
    					{	
    						echo  $value['tree']; 
    						echo ', ';
    					}
    			
    			?>
    			</li>
    			</ul>
    			</div>
    </body>
    </html>
    The viewmodel itself is just an iframe from warmanes armory. This is how i extracted it with iframe

    Code:
    //Im sure there was better way and more clear ,but i just wanted it to be done fast :D
    
    <div style="position:relative;width:410px;height:1000px; float:right;margin-top:10%;margin-right:-2%;z-index:1" align="right">
    			<div align="right" style="overflow: hidden; margin-top: -0px; margin-left: 35px;margin-right:50px;z-index:1">
    			<iframe scrolling="no" align="right" src="<?php echo "http://armory.warmane.com/character/" .$id . "/Frostwolf/profile" ?>" style="border: 0px none; margin-left: -0px; height: 983px; margin-top: -557px; width: 411px;z-index:2>" html=""></iframe>
    </div>
    </div>
    If you have any questions please comment bellow and ill try to answer asap.

  2. Available APIs that arent empty:

    -Guild roster http://armory.warmane.com/api/guild/...stwolf/summary
    -Player info http://armory.warmane.com/api/charac...stwolf/summary
    -Item tooltips http://mop.cavernoftime.com/api

    If u wonder why u cant add rank next to player. Its because its nonexistent in api.

    What i would like to be added to in next api update is:

    -Player Rank
    -Fix json string where player doesn't have profession or spec to be anything but nonexistent, so it can be added to loop.

    example with professions same as specialization:

    "professions":[]} to be professions":{"professions":[{"name":,"skill":},{"name":,"skill":}]}

    -Add player location aka Instance zone he currently is in. Im not talking about world zones. If player in world output location:world, else "zone name"(Good for tracking if the guild started some raid or not via mobile)

    -Latest achievements
    -2s,3s,5s ladder
    -Match history
    -Information about player won/lost games
    -Player stats as str,int,agi

  3. May 3, 2018  
    Kudos to you! This is nicely done, informative and handy.

  4. May 5, 2018  
    Appreciate it, make sure u post me results if u start any project of your own for your guild :)

  5. bumping. Edifice we need API update plez :(
    Edited: June 28, 2018 Reason: Adding edifice name will change nothing :D

  6. Ok, using php function preg_match, u can get all the other info there isnt api for. So until API is upgraded use preg_match on guild table and with foreach extract rank. Tested and working. Also made 2v2.php frostwolf ladder

  7. Man this is awesome. Was wondering for an API and boom here it is. Awesome.

  8. Awesome work i will be so glad to use it.
    Thanks for this, really awesome of you to share with us. +Karma

  9. Discord bot with armory,online status, roster, info is being evaluated to be posted as well. Should be up tomorrow(Source code c#)

  10. Hi. Is there any chance for adding guild notes and ranks to API? I want to create applikation for raid planner for my guild. Info in notes are like: Nickname of main character (from DKP addon).

  11. Is it possible to get the info on how much time until the next wintergrasp run on a server? I don't think so right?
    I was thinking about developing a small app to warn that wintergrasp is about to start.

  12. Hi, is it possible to add guild event list ? Maybe with specific token for each guild
    That could be good to planify raid out of the game.
    Edited: February 19, 2020

  13. Wow thanks mate helped a lot but How can I work with Arrays like professions ?

    I tried to follow your index.php, tried to add another column for profession. However couldn't find any solution for profession array, looks like multi dimensional array but couldn't really make it work.

  14. May 12, 2020  
    Was looking for a warmane API. Thanks for figuring this out!
    Shame they don't send CORS headers though, then you wouldn't even need a server side script.


    However couldn't find any solution for profession array, looks like multi dimensional array but couldn't really make it work.
    Professions is an array with objects:

    professions: [{name: "Tailoring", skill: "600"}, {name: "Engineering", skill: "600"}]

    You can iterate over it like this:
    Code:
    foreach($player['professions'] as $prof) {
        echo 'Profession: ' . $prof['name'] . '<br>';
        echo 'Skill level: ' . $prof['skill'] . '<br>';
    }

  15. May 12, 2020  
    I've been working on a simple character viewer.

    I'll post the code below. Features so far are:

    - Simple search and overview for Warmane characters
    - Tooltips from wotlkdb.com, so you can inspect people when COT is down
    - Uses localStorage to cache any character you last inspected

    There is still a lot of info missing, like gems, enchants, professions, etc.
    Some info can be added, but things like enchants are simply not provided by the API.

    Now for the best part, the code:

    index.php

    Code:
    <?php
    
    declare(strict_types=1);
    
    ini_set('display_errors', 'true');
    error_reporting(E_ALL);
    
    if('POST' === $_SERVER['REQUEST_METHOD'])
    {
        header('Content-type: application/json');
        $post = json_decode(file_get_contents('php://input'), true);
        $url = sprintf(
            'https://armory.warmane.com/api/character/%s/%s/summary',
            urlencode($post['name']),
            urlencode($post['realm'])
        );
        $raw = file_get_contents($url);
        if(json_decode($raw)) {
            exit($raw);
        }
        exit('{"error": "Response was not JSON"}');
    }
    
    ?><!DOCTYPE html>
    <html>
    
    <head>
        <meta charset='utf-8'>
        <meta http-equiv='X-UA-Compatible' content='IE=edge'>
        <title>Warmane armoury</title>
        <meta name='viewport' content='width=device-width, initial-scale=1'>
        <link rel='stylesheet' type='text/css' media='screen' href='main.css'>
    </head>
    <body>
        <h1>Warmane simple character viewer</h1>
        <form id="searchform">
            <label>
                <input name="search" />
                <select name="realm">
                    <option value="Outland">Outland</option>
                    <option value="Frostmourne">Frostmourne</option>
                    <option value="Lordaeron">Lordaeron</option>
                    <option value="Icecrown">Icecrown</option>
                    <option value="Blackrock">Blackrock</option>
                    <option value="Frostwolf">Frostwolf</option>
                </select>
                <button>Search</button>
            </label>
            <p id="statusbar">Status: <span id="status">Initializing</span></p>
            <div class="char-template">
                <h2 class="name"></h2>
                <h3 class="guild"></h3>
                <p>Level <span class="level"></span> <span class="race"></span> <span class="class"></span></p>
                <h4>Equipment</h4>
                <div class="equipment-container"></div>
            </div>
        </form>
        <script type="text/javascript" src="https://wotlkdb.com/static/widgets/power.js"></script>
        <script>var aowow_tooltips = { "colorlinks": true, "iconizelinks": true, "renamelinks": true }</script>
        <script src='main.js'></script>
    </body>
    
    </html>
    main.css

    Code:
    :root {
        --container-width: 40vw;
    }
    
    html {
        height: 100%;
    }
    
    body {
        font-size: 100%;
        min-height: 100%;
        font-family: Verdana, Geneva, Tahoma, sans-serif;
    }
    
    * {
        margin: 0;
    }
    
    h1,
    #statusbar {
        text-align: center;
    }
    
    #statusbar {
        font-size: 0.7em;
    }
    
    #searchform label {
        display: grid;
        max-width: var(--container-width);
        margin: 0 auto;
    }
    
    #searchform label input,
    #searchform label select,
    #searchform label button {
        padding: 5px;
    }
    
    .char-template {
        display: none;
    }
    
    .character {
        max-width: var(--container-width);
        margin: 0 auto;
    }
    
    .character h4 {
        margin-top: 1em;
    }
    
    .equipment-container {
        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
        grid-gap: 10px;
        max-width: var(--container-width);
        margin: 1em auto;
    }
    
    .equipment-container a {
        border: solid 1px silver;
        padding: 5px;
    }
    main.js

    Code:
    "use strict";
    
    document.addEventListener('DOMContentLoaded', () => {
        let form = document.getElementById('searchform'),
            search = form.elements.search,
            realm = form.elements.realm,
            status = document.getElementById('status'),
            lastFound = localStorage.getItem('lastfound'),
            charTemplate = document.querySelector('.char-template');
    
        lastFound = lastFound ? JSON.parse(lastFound) : null;
    
        function showCharacter(name, json) {
            console.log(json);
            if (json.error) {
                return status.textContent = json.error;
            }
    
            localStorage.setItem('lastfound', JSON.stringify(json));
            status.textContent = 'Found ' + name;
    
            let char = charTemplate.cloneNode(true),
                binding;
            char.className = 'character';
    
            for (let key in json) {
                binding = char.querySelector('.' + key);
                if (binding) {
                    binding.textContent = json[key];
                }
            }
    
            let item;
            for (let i = 0, l = json.equipment.length; i < l; i++) {
                console.log(json.equipment[i].name);
                item = document.createElement('a');
                item.textContent = json.equipment[i].name;
                item.setAttribute('rel', 'item=' + json.equipment[i].item);
                char.querySelector('.equipment-container').appendChild(item);
            }
            document.body.appendChild(char);
        }
    
        function fetchCharacter(name, realm) {
            fetch('index.php', {
                method: 'POST',
                body: JSON.stringify({
                    name: name,
                    realm: realm
                })
            }).then(
                response => response.json()
            ).then(
                json => {
                    json.fetchDate = new Date;
                    showCharacter(name, json);
                }
            ).catch(
                e => status.textContent = e.message
            );
        }
    
        status.textContent = 'Ready';
    
        if (lastFound) {
            search.value = lastFound.name;
            realm.value = lastFound.realm;
            showCharacter(lastFound.name, lastFound);
        }
    
        form.addEventListener('submit', (evt) => {
            evt.preventDefault();
            search.value = search.value.trim();
    
            if (search.value) {
                status.textContent = 'Fetching ' + search.value;
                fetchCharacter(search.value, realm.value);
            } else {
                status.textContent = 'Invalid name';
            }
        });
    });

12 Last

Posting Permissions

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