Use Character API data to create image

API Discussion
I would like to have portraits on my guild's "roster" page that are updated via API. I can get character info data and everything but I don't exactly know what to do with it to get the portrait result.

I'm new to API's and willing to use any languages but prefer js if possible.

Any tips?
Hi,

you juste need to use this link:


https://render-api-eu.worldofwarcraft.com/static-render/[region]/[thumbnail]


Exemple with my character in php:


<?php
$region = "eu";
$thumbnail = "les-sentinelles/5/104588037-avatar.jpg";
$link = "https://render-api-eu.worldofwarcraft.com/static-render/";
?>
<img src="<?php echo $link.'/'.$region.'/'.$thumbnail; ?>" />
I don't think it's appropriate to make direct references on images on the render-api from your webpage. Instead, download a copy of it and serve it from your own webserver.

E.g:


$thumbnail = "les-sentinelles/5/104588037-avatar.jpg";
$link = "https://render-api-eu.worldofwarcraft.com/static-render/";
$local_img = str_replace('/', '-', $thumbnail);

// Download and store (cache) the image on your own server.
file_put_contents($local_img, file_get_contents($link . $thumbnail));

// Serve the image from _your_ server.
echo sprintf('<img src="%s">', $local_img);


You should check the modification or creation time of your file. If it's older than an x- amount of hours, you can choose to re-download the image to stay up-to-date.
Do you know if this still works - and if so - where is it documented? I'm having trouble getting it working.
06/19/2018 11:39 AMPosted by cfjedimaster
Do you know if this still works - and if so - where is it documented? I'm having trouble getting it working.


So this process will require that you replace pieces of the CRDN url based on the character you are currently using. For example we'll use my old mage, but if you use your API key and go to the Wow Character API https://dev.battle.net/io-docs and pull the information for a character, it will return an object on the body that contains a thumbnail key. You only need to replace the URL pieces for the CRDN to work. But as pointed our already, it would be best to store the image on your own server.

{
"lastModified": 1518918056000,
"name": "Kryo",
"realm": "Thunderlord",
"battlegroup": "Ruin",
"class": 8,
"race": 1,
"gender": 0,
"level": 110,
"achievementPoints": 15090,
"thumbnail": "thunderlord/167/138601383-avatar.jpg",
"calcClass": "e",
"faction": 0,
"totalHonorableKills": 51107
}


As per https://dev.battle.net/docs/read/community_apis/world_of_warcraft/Character_Renders ...

The available renders are:

    Avatar: http://render-us.worldofwarcraft.com/character/lightbringer/110/115539310-avatar.jpg

    Main: http://render-us.worldofwarcraft.com/character/lightbringer/110/115539310-main.jpg

    Inset: http://render-us.worldofwarcraft.com/character/lightbringer/110/115539310-inset.jpg


So you'd need to fill in the pieces...
http://render-<REGION>.worldofwarcraft.com/character/<THUMBNAIL KEY>
...turns into...
http://render-us.worldofwarcraft.com/character/thunderlord/167/138601383-avatar.jpg
...to get my Mage's avatar.
http://render-us.worldofwarcraft.com/character/thunderlord/167/138601383-avatar.jpg
...to get my Mage's avatar.[/quote]

@Kryo What if i wanted the main.jpg ? i cant figure out how to change that because im only getting from the thumbnail the avatar one i need the main image which is the whole character image
08/03/2018 12:23 PMPosted by spudnic072
@Smaw this documentation might help: https://dev.battle.net/docs/read/community_apis/world_of_warcraft/Character_Renders

@spudnic072 ya i read it but still cant figure out how to replace what im getting from the response from avatar to main, the thumbnail i mean when you grab it it only contains avatar and i want it to dynamically be main when users try to search for their character
..., the thumbnail i mean when you grab it it only contains avatar and i want it to dynamically be main when users try to search for their character


Maybe you figure out already, but you can use string replace
The API string variable for the images are saved, as an example, like "kilrogg/123/123456-avatar.jpg"

To change it from an avatar image to an inset or main image you string replace the word "avatar" to "inset" or "main" as in the example below.

The example below, will call the image directly from the WoW servers and change the word avatar in the url "kilrogg/123/123456-avatar.jpg" to "kilrogg/123/123456-main.jpg"

Example...

<img src="http://render-eu.worldofwarcraft.com/character/<?php echo str_replace("avatar","main", $apichar['thumbnail']);?>" alt="Character Image">

Join the Conversation

Return to Forum