How to get item icon name

HI all, in these days I’m trying to understand the algorithm that WoWHead and OpenWoW use to get the icon of an item (or an achievements etc.) anyone know how to obtain that?

the icon name should be like this “inv_fabric_purplefire_o01” (http://wow.zamimg.com/images/wow/icons/large/inv_fabric_purplefire_01.jpg)

EDIT: I did with this https://community.trinitycore.org/topic/11350-trinitycore-json-restful-api/?do=findComment&comment=77778

openwow probably uses the DBC data (see itemdisplayinfo.dbc)
wowhead on the other hand maybe uses methods like http://wowwiki.wikia.com/wiki/API_GetItemIcon and or they get the info by reading the UI data from client addons if they cant read / extract the DBC files for some (legal?) reasons.

For example if an achievement shows in the UI, we can access that UI element and read what the texture path is.