---
name: wow-api-unit-player
description: "Complete reference for WoW Retail Unit and Player APIs — UnitId tokens, GUIDs, health/power/stats, auras, roles, casting, threat, inspection, paper doll, death/resurrection, and player-specific functions. Use when querying unit identity, health, power, auras, stats, combat state, group membership, casting info, threat, or player character details."
---
# Unit & Player API (Retail — Patch 12.0.0)
Comprehensive reference for all Unit, Player, UnitAuras, UnitRole, PaperDollInfo, and PlayerInfo APIs. Covers unit identification (UnitId tokens, GUIDs), health, power, stats, auras, casting, threat, group membership, inspection, and player-specific character functions.
> **Source of truth:** https://warcraft.wiki.gg/wiki/World_of_Warcraft_API#Unit
> **UnitId reference:** https://warcraft.wiki.gg/wiki/UnitId
> **GUID reference:** https://warcraft.wiki.gg/wiki/GUID
> **Current as of:** Patch 12.0.0 (Build 65655) — January 28, 2026
> **Scope:** Retail only. No deprecated or removed functions.
## Scope
This skill covers these API systems:
- **Unit** — Core unit query functions (`UnitName`, `UnitHealth`, `UnitClass`, etc.)
- **UnitAuras** — Aura/buff/debuff system (`C_UnitAuras`)
- **UnitRole** — Group role assignment and queries
- **PlayerInfo** — Player-specific info (`C_PlayerInfo`)
- **PaperDollInfo** — Equipment, stats, inspection (`C_PaperDollInfo`)
- **PlayerScript** — Global player functions (stats, combat ratings, PvP, death, movement)
- **DeathInfo / IncomingSummon** — Death, resurrection, summoning
- **CreatureInfo** — Creature data helpers
## When to Use This Skill
Use this skill when you need to:
- Query unit identity: name, class, race, level, faction, GUID
- Read or display health, power (mana/rage/energy), or stats
- Work with auras (buffs, debuffs, private auras)
- Check unit state: alive, dead, ghost, combat, AFK, stealthed, flying
- Determine group membership, roles, or raid position
- Inspect other players (item level, spec, PvP data)
- Get player character stats: crit, haste, mastery, armor, attack power
- Handle casting info (what a unit is casting/channeling)
- Query threat situation
- Work with UnitId tokens or GUIDs
## Reference Files
| Reference | Contents |
|-----------|----------|
| [UNIT-IDENTITY.md](references/UNIT-IDENTITY.md) | UnitId tokens, GUIDs, name/class/race/level/faction |
| [UNIT-HEALTH-POWER.md](references/UNIT-HEALTH-POWER.md) | Health, power, stats, armor, combat ratings |
| [UNIT-STATE.md](references/UNIT-STATE.md) | Combat, dead/ghost, casting, vehicle, movement, group state |
| [UNIT-AURAS.md](references/UNIT-AURAS.md) | C_UnitAuras — buffs, debuffs, private auras |
| [UNIT-THREAT-COMBAT.md](references/UNIT-THREAT-COMBAT.md) | Threat, targeting, selection, inspection |
| [PLAYER-FUNCTIONS.md](references/PLAYER-FUNCTIONS.md) | Player-specific: XP, money, PvP, death, resurrection, stats |
---
## UnitId Tokens — Quick Reference
A UnitId (unit token) identifies a unit by relationship to the player. Case insensitive.
### Base Tokens
| Token | Description |
|-------|-------------|
| `"player"` | The current player |
| `"target"` | The current player's target |
| `"focus"` | The player's focus target (set by `/focus`) |
| `"pet"` | The player's pet |
| `"vehicle"` | The player's vehicle |
| `"mouseover"` | Unit currently (or most recently) moused over |
| `"none"` | Valid token that always refers to no unit |
| `"npc"` | NPC the player is interacting with (merchant/quest/gossip frame open) |
| `"questnpc"` | Quest giver NPC being interacted with |
### Indexed Tokens
| Pattern | Range | Description |
|---------|-------|-------------|
| `"partyN"` | 1–4 | Nth party member (excluding player) |
| `"raidN"` | 1–40 | Nth raid member |
| `"partypetN"` | 1–4 | Pet of Nth party member |
| `"raidpetN"` | 1–40 | Pet of Nth raid member |
| `"bossN"` | 1–8 | Active boss in current encounter |
| `"arenaN"` | 1–5 | Opposing arena member |
| `"nameplateN"` | 1–40 | Nth nameplate (cannot be targeted) |
### Soft Targeting (Patch 10.0+)
| Token | Description |
|-------|-------------|
| `"softenemy"` | Current soft target that is hostile |
| `"softfriend"` | Current soft target that is friendly |
| `"softinteract"` | Current soft target that can be interacted with |
| `"anyenemy"` | Resolves to `"target"` or `"softenemy"` (target priority) |
| `"anyfriend"` | Resolves to `"target"` or `"softfriend"` (target priority) |
| `"anyinteract"` | Resolves to `"target"` or `"softinteract"` (target priority) |
### Target Chaining
Append `target` to any UnitId to refer to its target. Can be repeated:
- `"targettarget"` — your target's target
- `"raid7target"` — 7th raid member's target
- `"pettarget"` — your pet's target
- `"Cogwheel-target"` — named player's target (if in group)
> **Source:** https://warcraft.wiki.gg/wiki/UnitId
---
## GUID (Globally Unique Identifier) — Quick Reference
GUIDs uniquely identify everything the player can interact with. Returned by `UnitGUID(unit)`.
### GUID Formats
| Type | Format | Example |
|------|--------|---------|
| Player | `Player-[serverID]-[playerUID]` | `Player-970-0002FD64` |
| Creature | `Creature-0-[serverID]-[instanceID]-[zoneUID]-[npcID]-[spawnUID]` | `Creature-0-1465-0-2105-448-000043F59F` |
| Pet | `Pet-0-[serverID]-[instanceID]-[zoneUID]-[npcID]-[spawnUID]` | `Pet-0-4234-0-6610-165189-0202F859E9` |
| Vehicle | `Vehicle-0-[serverID]-[instanceID]-[zoneUID]-[npcID]-[spawnUID]` | Same format as Creature |
| GameObject | `GameObject-0-[serverID]-[instanceID]-[zoneUID]-[objectID]-[spawnUID]` | Same format as Creature |
| Item | `Item-[serverID]-0-[spawnUID]` | `Item-1598-0-4000000A369860E1` |
| Vignette | `Vignette-0-[serverID]-[instanceID]-[zoneUID]-[vignetteID]-[spawnUID]` | — |
| BattlePet | `BattlePet-0-[ID]` | `BattlePet-0-00000338F951` |
| Cast | `Cast-[type]-[serverID]-[instanceID]-[zoneUID]-[spellID]-[castUID]` | — |
### Extracting NPC ID from GUID
```lua
local npcID = select(6, strsplit("-", UnitGUID("target")))
print(tonumber(npcID)) -- e.g., 448 for Hogger
Key Rules
- Players keep their GUID forever (unless faction change/transfer)
- Creatures get a new GUID each spawn cycle
- Pets get a new GUID each time summoned
- GUIDs are recycled after server/instance restart
Source: https://warcraft.wiki.gg/wiki/GUID
Core Unit Functions — Overview
Identity
| Function |
Returns |
Description |
UnitName(unit) |
unitName, unitServer |
Unit's name and realm |
UnitFullName(unit) |
unitName, unitServer |
Full name with server |
UnitNameUnmodified(unit) |
unitName, unitServer |
Name without modifications |
UnitNameFromGUID(guid) |
unitName, unitServer |
Name from GUID |
UnitGUID(unit) |
guid |
GUID string |
UnitTokenFromGUID(guid) |
unitToken |
UnitId from GUID |
UnitClass(unit) |
className, classFilename, classID |
Class info |
UnitClassBase(unit) |
classFilename, classID |
Non-localized class |
UnitClassFromGUID(guid) |
className, classFilename, classID |
Class from GUID |
UnitRace(unit) |
localizedRace, englishRace, raceID |
Race info |
UnitSex(unit) |
sex |
Gender (1=unknown, 2=male, 3=female) |
UnitLevel(unit) |
level |
Unit level |
UnitEffectiveLevel(unit) |
level |
Scaled level |
UnitFactionGroup(unit [, checkDisplayRace]) |
factionTag, localized |
Horde/Alliance |
UnitClassification(unit) |
class |
"normal", "elite", "worldboss", etc. |
UnitCreatureType(unit) |
name, id |
Beast, Humanoid, Undead, etc. |
UnitCreatureFamily(unit) |
name, id |
Creature family (e.g., Crab) |
UnitCreatureID(unit) |
creatureID |
NPC ID |
UnitPVPName(unit) |
name |
Name with title |
GetPlayerInfoByGUID(guid) |
class, engClass, race, engRace, sex, name, realm |
Info from GUID |
Health
| Function |
Returns |
Notes |
UnitHealth(unit [, usePredicted]) |
health |
Returns secret value in 12.0 — pass directly to widgets |
UnitHealthMax(unit) |
maxHealth |
Returns secret value in 12.0 |
UnitHealthMissing(unit [, usePredicted]) |
missing |
Health deficit |
UnitHealthPercent(unit [, usePredicted [, curve]]) |
percent |
Health percentage |
UnitPercentHealthFromGUID(guid) |
percent |
Health % from GUID |
UnitGetIncomingHeals(unit [, healer]) |
amount |
Predicted heals |
UnitGetTotalAbsorbs(unit) |
amount |
Damage absorb shield |
UnitGetTotalHealAbsorbs(unit) |
amount |
Healing absorb shield |
GetUnitHealthModifier(unit) |
modifier |
Health modifier |
GetUnitMaxHealthModifier(unit) |
modifier |
Max health modifier |
Power (Mana/Rage/Energy/etc.)
| Function |
Returns |
Notes |
UnitPower(unit [, powerType [, unmodified]]) |
power |
Current power |
UnitPowerMax(unit [, powerType [, unmodified]]) |
maxPower |
Maximum power |
UnitPowerMissing(unit [, powerType [, unmodified]]) |
missing |
Power deficit |
UnitPowerPercent(unit [, powerType [, ...]]) |
percent |
Power percentage |
UnitPartialPower(unit [, powerType [, unmodified]]) |
partialPower |
Fractional power |
UnitPowerType(unit [, index]) |
powerType, token, r, g, b |
e.g., 0=Mana, 1=Rage |
UnitPowerDisplayMod(powerType) |
mod |
Display modifier |
GetUnitPowerModifier(unit) |
modifier |
Power modifier |
Power Types (Enum.PowerType)
| Value |
Token |
Description |
| 0 |
Mana |
Mana |
| 1 |
Rage |
Rage |
| 2 |
Focus |
Focus (Hunter pets) |
| 3 |
Energy |
Energy (Rogues, Monks, etc.) |
| 4 |
ComboPoints |
Combo Points |
| 5 |
Runes |
Death Knight Runes |
| 6 |
RunicPower |
Runic Power |
| 7 |
SoulShards |
Warlock Soul Shards |
| 8 |
LunarPower |
Balance Druid |
| 9 |
HolyPower |
Paladin Holy Power |
| 11 |
Maelstrom |
Shaman Maelstrom |
| 12 |
Chi |
Monk Chi |
| 13 |
Insanity |
Shadow Priest |
| 16 |
ArcaneCharges |
Arcane Mage |
| 17 |
Fury |
Demon Hunter Fury |
| 18 |
Pain |
Vengeance DH (legacy) |
| 19 |
Essence |
Evoker Essence |
State Checks
| Function |
Returns |
Description |
UnitExists([unit]) |
bool |
Unit exists and can be targeted |
UnitIsVisible([unit]) |
bool |
Visible to client (not necessarily line of sight) |
UnitIsConnected(unit) |
bool |
Not offline |
UnitIsDead(unit) |
bool |
Dead |
UnitIsDeadOrGhost(unit) |
bool |
Dead or ghost form |
UnitIsGhost(unit) |
bool |
Ghost form |
UnitAffectingCombat(unit) |
bool |
In combat |
UnitIsAFK(unit) |
bool |
AFK (friendly only) |
UnitIsDND(unit) |
bool |
Do Not Disturb |
UnitIsPlayer([unit]) |
bool |
Is a player character |
UnitIsEnemy(unit, target) |
bool |
Units are hostile |
UnitIsFriend(unit, target) |
bool |
Units are friendly |
UnitCanAttack(unit, target) |
bool |
First can attack second |
UnitCanAssist(unit, target) |
bool |
First can assist second |
UnitCanCooperate(unit, target) |
bool |
Can cooperate |
UnitIsUnit(unit1, unit2) |
bool |
Same unit |
UnitIsPVP(unit) |
bool |
PvP flagged |
UnitIsCharmed([unit]) |
bool |
Charmed / mind controlled |
UnitIsFeignDeath(unit) |
bool |
Feigning death (group only) |
UnitIsTapDenied(unit) |
bool |
Tap denied (grey health bar) |
UnitIsTrivial(unit) |
bool |
Grey to player |
UnitIsBossMob(unit) |
bool |
Boss unit |
IsFalling([unit]) |
bool |
Currently falling |
IsFlying([unit]) |
bool |
On flying mount |
IsSwimming([unit]) |
bool |
Swimming |
IsStealthed() |
bool |
Player is stealthed |
PlayerIsInCombat() |
bool |
Player in combat |
Group Membership
| Function |
Returns |
Description |
UnitInParty([unit]) |
bool |
In your party |
UnitInRaid([unit]) |
index |
In your raid (returns index) |
UnitInAnyGroup([unit]) |
bool |
In any group |
UnitPlayerOrPetInParty([unit]) |
bool |
Player or pet in party |
UnitPlayerOrPetInRaid([unit]) |
bool |
Player or pet in raid |
UnitInRange(unit) |
inRange, checked |
Within 40yd (25yd Evoker) #grouponly |
UnitIsGroupLeader(unit [, cat]) |
bool |
Is group leader |
UnitIsGroupAssistant(unit) |
bool |
Is assist |
UnitGroupRolesAssigned([unit]) |
role |
"TANK", "HEALER", "DAMAGER", "NONE" |
UnitIsInMyGuild(unit) |
bool |
Same guild |
Casting Info
| Function |
Returns |
Description |
UnitCastingInfo(unit) |
name, displayName, textureID, startTimeMs, endTimeMs, isTradeskill, castID, notInterruptible, castingSpellID, castBarID |
Current cast info |
UnitChannelInfo(unit) |
name, displayName, textureID, startTimeMs, endTimeMs, isTradeskill, notInterruptible, spellID, isEmpowered, numEmpowerStages, castBarID |
Channel info |
UnitCastingDuration(unit) |
duration |
Cast duration |
UnitChannelDuration(unit) |
duration |
Channel duration |
UnitEmpoweredChannelDuration(unit [, includeHold]) |
duration |
Empower duration |
12.0.0 Change: notInterruptible in UnitCastingInfo is now nilable. New castBarID return added.
Threat
| Function |
Returns |
Description |
UnitThreatSituation(unit [, mob]) |
status |
0=low, 1=close, 2=unsafe, 3=tanking |
UnitDetailedThreatSituation(unit, mob) |
isTanking, status, scaledPct, rawPct, rawThreat |
Detailed threat |
UnitThreatPercentageOfLead(unit, mob) |
percent |
% of lead |
UnitThreatLeadSituation(unit, mob) |
status |
Lead situation |
C_UnitAuras — Aura System
The aura API provides buff/debuff data for units. Returns AuraData tables.
Key Functions
| Function |
Returns |
Description |
C_UnitAuras.GetAuraDataByIndex(unit, index [, filter]) |
aura |
Aura by index |
C_UnitAuras.GetAuraDataByAuraInstanceID(unit, auraInstanceID) |
aura |
Aura by instance ID |
C_UnitAuras.GetAuraDataBySlot(unit, slot) |
aura |
Aura by slot |
C_UnitAuras.GetAuraDataBySpellName(unit, spellName [, filter]) |
aura |
Aura by spell name |
C_UnitAuras.GetBuffDataByIndex(unit, index [, filter]) |
aura |
Buff specifically |
C_UnitAuras.GetDebuffDataByIndex(unit, index [, filter]) |
aura |
Debuff specifically |
C_UnitAuras.GetPlayerAuraBySpellID(spellID) |
aura |
Player aura by spell ID |
C_UnitAuras.GetAuraSlots(unit [, filter [, max [, token]]]) |
continuation, slots... |
Iterate aura slots |
C_UnitAuras.GetUnitAuraInstanceIDs(unit, filter [, max [, sort [, dir]]]) |
auraInstanceIDs |
All aura instance IDs |
C_UnitAuras.GetUnitAuras(unit, filter [, max [, sort [, dir]]]) |
auras |
All aura data |
C_UnitAuras.GetAuraDuration(unit, auraInstanceID) |
duration |
Remaining duration |
C_UnitAuras.GetAuraBaseDuration(unit, auraID [, spellID]) |
duration |
Base duration |
C_UnitAuras.DoesAuraHaveExpirationTime(unit, auraID) |
bool |
Has timer |
C_UnitAuras.IsAuraFilteredOutByInstanceID(unit, auraID, filter) |
bool |
Filtered by current filter |
C_UnitAuras.WantsAlteredForm(unit) |
bool |
Wants altered form |
Aura Filter Strings
Filters are space-separated strings passed to aura query functions:
| Filter |
Description |
"HELPFUL" |
Buffs only |
"HARMFUL" |
Debuffs only |
"PLAYER" |
Only auras cast by the player |
"RAID" |
Only auras relevant to the raid |
"CANCELABLE" |
Only cancelable auras |
"NOT_CANCELABLE" |
Only non-cancelable auras |
"INCLUDE_NAME_PLATE_ONLY" |
Include nameplate-only auras |
"MAW" |
Maw-specific auras |
Combine with spaces: "HELPFUL PLAYER" = buffs cast by player.
AuraData Structure
Fields returned in an AuraData table:
| Field |
Type |
Description |
name |
string |
Aura name |
icon |
number |
Texture file ID |
applications |
number |
Stack count |
dispelName |
string? |
Dispel type: "Magic", "Curse", "Disease", "Poison" |
duration |
number |
Total duration (0 = indefinite) |
expirationTime |
number |
GetTime() when it expires |
isFromPlayerOrPlayerPet |
bool |
Cast by player or player's pet |
isHarmful |
bool |
Is a debuff |
isHelpful |
bool |
Is a buff |
isNameplateOnly |
bool |
Only shows on nameplates |
isRaid |
bool |
Shows in raid frames |
isStealable |
bool |
Can be spellstolen |
sourceUnit |
UnitId? |
Caster |
spellId |
number |
Spell ID |
points |
table |
Aura effect values |
auraInstanceID |
number |
Unique instance ID for this application |
timeMod |
number |
Time modifier |
charges |
number |
Number of charges |
isBossAura |
bool |
Boss aura |
nameplateShowAll |
bool |
Show all stacks on nameplate |
nameplateShowPersonal |
bool |
Show personal on nameplate |
Private Auras
Private auras are auras where the spell data is hidden from addons. Used for encounter mechanics.
| Function |
Description |
C_UnitAuras.AddPrivateAuraAnchor(args) |
Anchor a frame to a private aura's display position → anchorID |
C_UnitAuras.RemovePrivateAuraAnchor(anchorID) |
Remove private aura anchor |
C_UnitAuras.AddPrivateAuraAppliedSound(sound) |
Play sound when private aura applied → soundID |
C_UnitAuras.RemovePrivateAuraAppliedSound(soundID) |
Remove private aura sound |
C_UnitAuras.AuraIsPrivate(spellID) |
Check if spell is private |
C_UnitAuras.AuraIsBigDefensive(spellID) |
Check if big defensive CD |
C_UnitAuras.SetPrivateWarningTextAnchor(parent [, anchor]) |
Set warning text anchor |
C_UnitAuras.TriggerPrivateAuraShowDispelType(show) |
Toggle dispel type display |
Aura Iteration Pattern
-- Modern pattern: iterate by aura instance IDs
local function GetAllAuras(unit, filter)
local auras = {}
local ids = C_UnitAuras.GetUnitAuraInstanceIDs(unit, filter)
for _, id in ipairs(ids) do
local aura = C_UnitAuras.GetAuraDataByAuraInstanceID(unit, id)
if aura then
table.insert(auras, aura)
end
end
return auras
end
-- Get all player debuffs
local debuffs = GetAllAuras("player", "HARMFUL")
UNIT_AURA Event
-- UNIT_AURA fires when any aura changes on a unit
-- Payload: unitTarget, updateInfo
-- updateInfo contains: addedAuras, updatedAuraInstanceIDs, removedAuraInstanceIDs
-- isFullUpdate (bool) — if true, full refresh is needed
local frame = CreateFrame("Frame")
frame:RegisterUnitEvent("UNIT_AURA", "player")
frame:SetScript("OnEvent", function(self, event, unit, updateInfo)
if updateInfo.isFullUpdate then
-- re-scan all auras
return
end
if updateInfo.addedAuras then
for _, aura in ipairs(updateInfo.addedAuras) do
print("Added:", aura.name, aura.spellId)
end
end
if updateInfo.removedAuraInstanceIDs then
for _, id in ipairs(updateInfo.removedAuraInstanceIDs) do
print("Removed aura instance:", id)
end
end
end)
C_PlayerInfo — Player Information
| Function |
Returns |
Description |
C_PlayerInfo.GUIDIsPlayer(guid) |
bool |
GUID belongs to a player |
C_PlayerInfo.GetClass(playerLocation) |
className, classFilename, classID |
Player class |
C_PlayerInfo.GetName(playerLocation) |
name |
Player name |
C_PlayerInfo.GetRace(playerLocation) |
raceID |
Player race |
C_PlayerInfo.GetSex(playerLocation) |
sex |
Player sex |
C_PlayerInfo.GetContentDifficultyCreatureForPlayer(unit) |
difficulty |
Content difficulty |
C_PlayerInfo.GetPlayerMythicPlusRatingSummary(unit) |
ratingSummary |
M+ rating |
Source: https://warcraft.wiki.gg/wiki/World_of_Warcraft_API#PlayerLocationInfo
C_PaperDollInfo — Equipment & Inspection
| Function |
Returns |
Description |
C_PaperDollInfo.GetInspectItemLevel(unit) |
itemLevel |
Inspected unit's avg ilvl |
C_PaperDollInfo.GetInspectGuildInfo(unit) |
achPoints, numMembers, guildName, realm |
Guild info for inspected |
C_PaperDollInfo.GetArmorEffectiveness(armor, attackerLvl) |
effectiveness |
Armor DR % |
C_PaperDollInfo.GetArmorEffectivenessAgainstTarget(armor) |
effectiveness |
Armor DR vs target |
C_PaperDollInfo.GetStaggerPercentage(unit) |
stagger, staggerVsTarget |
Monk stagger % |
C_PaperDollInfo.GetMinItemLevel() |
minItemLevel |
Minimum ilvl |
C_PaperDollInfo.CanAutoEquipCursorItem() |
bool |
Can auto-equip |
C_PaperDollInfo.CanCursorCanGoInSlot(slot) |
bool |
Cursor item fits slot |
C_PaperDollInfo.IsInventorySlotEnabled(slotName) |
bool |
Slot enabled |
C_PaperDollInfo.GetInspectRatedBGData() |
data |
Inspected rated BG info |
C_PaperDollInfo.GetInspectRatedSoloShuffleData() |
data |
Inspected solo shuffle info |
Inspection Flow
-- 1. Request inspection data
NotifyInspect("target")
-- 2. Wait for INSPECT_READY event
local frame = CreateFrame("Frame")
frame:RegisterEvent("INSPECT_READY")
frame:SetScript("OnEvent", function(self, event, inspecteeGUID)
local spec = GetInspectSpecialization("target")
local ilvl = C_PaperDollInfo.GetInspectItemLevel("target")
print("Spec:", spec, "iLvl:", ilvl)
ClearInspectPlayer() -- Clean up
self:UnregisterEvent("INSPECT_READY")
end)
UnitRole — Group Roles
| Function |
Returns |
Description |
UnitGroupRolesAssigned([unit]) |
"TANK"/"HEALER"/"DAMAGER"/"NONE" |
Assigned role |
UnitGroupRolesAssignedEnum([unit]) |
enum |
Role as enum value |
UnitGetAvailableRoles(unit) |
tank, healer, dps |
Available roles (booleans) |
UnitSetRole(unit [, roleStr]) |
success |
Set role |
UnitSetRoleEnum(unit [, role]) |
success |
Set role by enum |
CanShowSetRoleButton() |
bool |
Role button available |
InitiateRolePoll() |
success |
Start role poll |
AreClassRolesSoftSuggestions() |
bool |
Roles are soft suggestions |
Player Character Stats
These global functions query the player's character stats.
Combat Ratings & Stats
| Function |
Returns |
Description |
GetCritChance() |
percent |
Melee crit % |
GetRangedCritChance() |
percent |
Ranged crit % |
GetHaste() |
percent |
Haste % |
GetMeleeHaste() |
percent |
Melee haste % |
GetRangedHaste() |
percent |
Ranged haste % |
UnitSpellHaste(unit) |
percent |
Spell haste % |
GetMastery() |
percent |
Base mastery % |
GetMasteryEffect() |
effect, coefficient |
Effective mastery |
GetDodgeChance() |
percent |
Dodge % |
GetParryChance() |
percent |
Parry % |
GetBlockChance() |
percent |
Block % |
GetLifesteal() |
percent |
Leech % |
GetAvoidance() |
percent |
Avoidance % |
GetCombatRating(ratingIndex) |
rating |
Raw combat rating value |
GetCombatRatingBonus(ratingIndex) |
bonus |
Bonus % from rating |
UnitStat(unit, index) |
cur, eff, posBuff, negBuff |
Primary stat (1=Str, 2=Agi, 3=Sta, 4=Int) |
UnitArmor(unit) |
base, effective, real, bonus |
Armor values |
UnitAttackPower(unit) |
ap, posBuff, negBuff |
Melee attack power |
UnitAttackSpeed(unit) |
mainhand, offhand |
Attack speed |
UnitDamage(unit) |
min, max, ohMin, ohMax, posBuff, negBuff, pct |
Damage range |
UnitRangedAttackPower(unit) |
ap, posBuff, negBuff |
Ranged AP |
UnitRangedDamage(unit) |
speed, min, max, posBuff, negBuff, pct |
Ranged damage |
GetManaRegen() |
base, casting |
Mana regen/sec |
GetPowerRegen() |
base, casting |
Power regen/sec |
Player XP & Level
| Function |
Returns |
Description |
UnitXP("player") |
xp |
Current XP |
UnitXPMax("player") |
maxXP |
XP to next level |
GetMaxPlayerLevel() |
level |
Level cap |
GetRestState() |
exhaustionID, name, factor |
Rested state |
IsXPUserDisabled() |
bool |
XP frozen |
Money & Economy
| Function |
Returns |
Description |
GetMoney() |
copper |
Total money in copper |
Movement
| Function |
Returns |
Description |
GetUnitSpeed(unit) |
current, run, flight, swim |
Movement speeds |
GetPlayerFacing() |
radians |
Direction facing #noinstance |
UnitPosition(unit) |
x, y, z, mapID |
World position #noinstance |
UnitDistanceSquared(unit) |
distSq, checked |
Squared distance #noinstance |
UnitOnTaxi(unit) |
bool |
On flight path |
Death & Resurrection
| Function |
Returns |
Description |
RepopMe() |
— |
Release spirit |
RetrieveCorpse() |
— |
Resurrect at corpse |
AcceptResurrect() |
— |
Accept rez offer |
DeclineResurrect() |
— |
Decline rez offer |
ResurrectGetOfferer() |
name |
Who is offering rez |
ResurrectHasSickness() |
bool |
Rez will give sickness |
ResurrectHasTimer() |
bool |
Must wait before accepting |
GetCorpseRecoveryDelay() |
seconds |
Delay before rez |
GetReleaseTimeRemaining() |
seconds |
Time until forced release |
C_IncomingSummon.HasIncomingSummon(unit) |
bool |
Has pending summon |
C_IncomingSummon.IncomingSummonStatus(unit) |
status |
Summon status |
UnitHasIncomingResurrection(unit) |
bool |
Being resurrected |
Secret Values — 12.0.0 Impact on Unit APIs
Many unit functions now return secret values under certain conditions. See the wow-api-important instructions for full details.
Functions Returning Secrets
| Function |
When Secret |
UnitHealth(unit) |
When health is restricted |
UnitHealthMax(unit) |
When health is restricted |
UnitName(unit) |
When unit identity restricted in combat (non-player units in instances) |
UnitClass(unit) |
First return conditionally secret |
UnitPower(unit) |
When power is restricted |
Safe Pattern: Display Health
-- CORRECT: Pass secret values directly to widgets
local hp = UnitHealth("target")
local maxHp = UnitHealthMax("target")
myStatusBar:SetMinMaxValues(0, maxHp) -- accepts secrets
myStatusBar:SetValue(hp) -- accepts secrets
-- WRONG: Do NOT compare or do math
-- if hp < maxHp * 0.3 then -- ERROR: cannot compare secrets
Checking Restrictions
-- Check if unit identity is restricted
local isSecret = C_Secrets.ShouldUnitIdentityBeSecret("target")
local isHealthSecret = C_Secrets.ShouldUnitHealthMaxBeSecret("target")
local isPowerSecret = C_Secrets.ShouldUnitPowerBeSecret("target")
Common Patterns
Unit Frame Health Bar
local frame = CreateFrame("Frame", nil, UIParent)
local healthBar = CreateFrame("StatusBar", nil, frame)
healthBar:SetStatusBarTexture("Interface\\TargetingFrame\\UI-StatusBar")
healthBar:SetMinMaxValues(0, 1)
local function UpdateHealth(unit)
local hp = UnitHealth(unit)
local maxHp = UnitHealthMax(unit)
healthBar:SetMinMaxValues(0, maxHp)
healthBar:SetValue(hp)
end
frame:RegisterUnitEvent("UNIT_HEALTH", "target")
frame:RegisterUnitEvent("UNIT_MAXHEALTH", "target")
frame:SetScript("OnEvent", function(self, event, unit)
UpdateHealth(unit)
end)
Check if Unit is a Healable Friendly
local function IsHealableUnit(unit)
return UnitExists(unit)
and UnitCanAssist("player", unit)
and not UnitIsDeadOrGhost(unit)
and UnitIsConnected(unit)
end
Get NPC ID from Target
local function GetNPCID(unit)
local guid = UnitGUID(unit)
if not guid then return nil end
local unitType, _, _, _, _, npcID = strsplit("-", guid)
if unitType == "Creature" or unitType == "Vehicle" then
return tonumber(npcID)
end
end
Related Events
| Event |
Payload |
Description |
UNIT_HEALTH |
unitTarget |
Health changed |
UNIT_MAXHEALTH |
unitTarget |
Max health changed |
UNIT_POWER_UPDATE |
unitTarget, powerType |
Power changed |
UNIT_POWER_FREQUENT |
unitTarget, powerType |
Power changed (frequent) |
UNIT_MAXPOWER |
unitTarget, powerType |
Max power changed |
UNIT_AURA |
unitTarget, updateInfo |
Auras changed |
UNIT_TARGET |
unitTarget |
Target changed |
UNIT_LEVEL |
unitTarget |
Level changed |
UNIT_NAME_UPDATE |
unitTarget |
Name updated |
UNIT_FACTION |
unitTarget |
Faction changed |
UNIT_FLAGS |
unitTarget |
Flags changed (PvP, AFK, etc.) |
UNIT_SPELLCAST_START |
unitTarget, castGUID, spellID |
Cast started |
UNIT_SPELLCAST_STOP |
unitTarget, castGUID, spellID |
Cast stopped |
UNIT_SPELLCAST_SUCCEEDED |
unitTarget, castGUID, spellID |
Cast succeeded |
UNIT_SPELLCAST_CHANNEL_START |
unitTarget, castGUID, spellID |
Channel started |
UNIT_SPELLCAST_CHANNEL_STOP |
unitTarget, castGUID, spellID |
Channel stopped |
UNIT_SPELLCAST_EMPOWER_START |
unitTarget, castGUID, spellID |
Empower started |
UNIT_SPELLCAST_EMPOWER_STOP |
unitTarget, castGUID, spellID, complete |
Empower stopped |
UNIT_THREAT_SITUATION_UPDATE |
unitTarget |
Threat changed |
UNIT_THREAT_LIST_UPDATE |
unitTarget |
Threat list changed |
UNIT_CONNECTION |
unitTarget, isConnected |
Online/offline |
UNIT_STATS |
unitTarget |
Stats changed |
UNIT_ATTACK_POWER |
unitTarget |
AP changed |
UNIT_SPELL_HASTE |
unitTarget |
Spell haste changed |
UNIT_COMBAT |
unitTarget, event, flagText, amount, schoolMask |
Combat text event |
UNIT_INVENTORY_CHANGED |
unitTarget |
Equipped items changed |
PLAYER_TARGET_CHANGED |
— |
Player target changed |
PLAYER_FOCUS_CHANGED |
— |
Focus target changed |
PLAYER_ENTERING_WORLD |
isInitialLogin, isReloadingUi |
Zone/instance load |
PLAYER_DEAD |
— |
Player died |
PLAYER_ALIVE |
— |
Player alive (accept rez) |
PLAYER_UNGHOST |
— |
Player no longer ghost |
PLAYER_REGEN_ENABLED |
— |
Left combat |
PLAYER_REGEN_DISABLED |
— |
Entered combat |
INSPECT_READY |
inspecteeGUID |
Inspection data available |
GROUP_ROSTER_UPDATE |
— |
Group composition changed |
ROLE_CHANGED_INFORM |
changedName, from, oldRole, newRole |
Role changed |
Restrictions & Gotchas
| Restriction |
Details |
#noinstance |
UnitPosition, UnitDistanceSquared, GetPlayerFacing blocked in instances |
#grouponly |
UnitInRange only works for group members |
#nocombat |
CheckInteractDistance blocked in combat |
| Secret values (12.0) |
Health, name, power may be secret — cannot compare/branch, only pass to widgets |
NotifyInspect throttle |
Inspecting too fast will be throttled by the server |
UnitIsPlayer |
Charmed players may return false for some APIs |
Sources:
1---2name: wow-api-unit-player3description: ```skill4---5```skill6---7name: wow-api-unit-player8description: "Complete reference for WoW Retail Unit and Player APIs — UnitId tokens, GUIDs, health/power/stats, auras, roles, casting, threat, inspection, paper doll, death/resurrection, and player-specific functions. Use when querying unit identity, health, power, auras, stats, combat state, group membership, casting info, threat, or player character details."9---1011# Unit & Player API (Retail — Patch 12.0.0)1213Comprehensive reference for all Unit, Player, UnitAuras, UnitRole, PaperDollInfo, and PlayerInfo APIs. Covers unit identification (UnitId tokens, GUIDs), health, power, stats, auras, casting, threat, group membership, inspection, and player-specific character functions.1415> **Source of truth:** https://warcraft.wiki.gg/wiki/World_of_Warcraft_API#Unit16> **UnitId reference:** https://warcraft.wiki.gg/wiki/UnitId17> **GUID reference:** https://warcraft.wiki.gg/wiki/GUID18> **Current as of:** Patch 12.0.0 (Build 65655) — January 28, 202619> **Scope:** Retail only. No deprecated or removed functions.2021## Scope2223This skill covers these API systems:24- **Unit** — Core unit query functions (`UnitName`, `UnitHealth`, `UnitClass`, etc.)25- **UnitAuras** — Aura/buff/debuff system (`C_UnitAuras`)26- **UnitRole** — Group role assignment and queries27- **PlayerInfo** — Player-specific info (`C_PlayerInfo`)28- **PaperDollInfo** — Equipment, stats, inspection (`C_PaperDollInfo`)29- **PlayerScript** — Global player functions (stats, combat ratings, PvP, death, movement)30- **DeathInfo / IncomingSummon** — Death, resurrection, summoning31- **CreatureInfo** — Creature data helpers3233## When to Use This Skill3435Use this skill when you need to:36- Query unit identity: name, class, race, level, faction, GUID37- Read or display health, power (mana/rage/energy), or stats38- Work with auras (buffs, debuffs, private auras)39- Check unit state: alive, dead, ghost, combat, AFK, stealthed, flying40- Determine group membership, roles, or raid position41- Inspect other players (item level, spec, PvP data)42- Get player character stats: crit, haste, mastery, armor, attack power43- Handle casting info (what a unit is casting/channeling)44- Query threat situation45- Work with UnitId tokens or GUIDs4647## Reference Files4849| Reference | Contents |50|-----------|----------|51| [UNIT-IDENTITY.md](references/UNIT-IDENTITY.md) | UnitId tokens, GUIDs, name/class/race/level/faction |52| [UNIT-HEALTH-POWER.md](references/UNIT-HEALTH-POWER.md) | Health, power, stats, armor, combat ratings |53| [UNIT-STATE.md](references/UNIT-STATE.md) | Combat, dead/ghost, casting, vehicle, movement, group state |54| [UNIT-AURAS.md](references/UNIT-AURAS.md) | C_UnitAuras — buffs, debuffs, private auras |55| [UNIT-THREAT-COMBAT.md](references/UNIT-THREAT-COMBAT.md) | Threat, targeting, selection, inspection |56| [PLAYER-FUNCTIONS.md](references/PLAYER-FUNCTIONS.md) | Player-specific: XP, money, PvP, death, resurrection, stats |5758---5960## UnitId Tokens — Quick Reference6162A UnitId (unit token) identifies a unit by relationship to the player. Case insensitive.6364### Base Tokens6566| Token | Description |67|-------|-------------|68| `"player"` | The current player |69| `"target"` | The current player's target |70| `"focus"` | The player's focus target (set by `/focus`) |71| `"pet"` | The player's pet |72| `"vehicle"` | The player's vehicle |73| `"mouseover"` | Unit currently (or most recently) moused over |74| `"none"` | Valid token that always refers to no unit |75| `"npc"` | NPC the player is interacting with (merchant/quest/gossip frame open) |76| `"questnpc"` | Quest giver NPC being interacted with |7778### Indexed Tokens7980| Pattern | Range | Description |81|---------|-------|-------------|82| `"partyN"` | 1–4 | Nth party member (excluding player) |83| `"raidN"` | 1–40 | Nth raid member |84| `"partypetN"` | 1–4 | Pet of Nth party member |85| `"raidpetN"` | 1–40 | Pet of Nth raid member |86| `"bossN"` | 1–8 | Active boss in current encounter |87| `"arenaN"` | 1–5 | Opposing arena member |88| `"nameplateN"` | 1–40 | Nth nameplate (cannot be targeted) |8990### Soft Targeting (Patch 10.0+)9192| Token | Description |93|-------|-------------|94| `"softenemy"` | Current soft target that is hostile |95| `"softfriend"` | Current soft target that is friendly |96| `"softinteract"` | Current soft target that can be interacted with |97| `"anyenemy"` | Resolves to `"target"` or `"softenemy"` (target priority) |98| `"anyfriend"` | Resolves to `"target"` or `"softfriend"` (target priority) |99| `"anyinteract"` | Resolves to `"target"` or `"softinteract"` (target priority) |100101### Target Chaining102103Append `target` to any UnitId to refer to its target. Can be repeated:104- `"targettarget"` — your target's target105- `"raid7target"` — 7th raid member's target106- `"pettarget"` — your pet's target107- `"Cogwheel-target"` — named player's target (if in group)108109> **Source:** https://warcraft.wiki.gg/wiki/UnitId110111---112113## GUID (Globally Unique Identifier) — Quick Reference114115GUIDs uniquely identify everything the player can interact with. Returned by `UnitGUID(unit)`.116117### GUID Formats118119| Type | Format | Example |120|------|--------|---------|121| Player | `Player-[serverID]-[playerUID]` | `Player-970-0002FD64` |122| Creature | `Creature-0-[serverID]-[instanceID]-[zoneUID]-[npcID]-[spawnUID]` | `Creature-0-1465-0-2105-448-000043F59F` |123| Pet | `Pet-0-[serverID]-[instanceID]-[zoneUID]-[npcID]-[spawnUID]` | `Pet-0-4234-0-6610-165189-0202F859E9` |124| Vehicle | `Vehicle-0-[serverID]-[instanceID]-[zoneUID]-[npcID]-[spawnUID]` | Same format as Creature |125| GameObject | `GameObject-0-[serverID]-[instanceID]-[zoneUID]-[objectID]-[spawnUID]` | Same format as Creature |126| Item | `Item-[serverID]-0-[spawnUID]` | `Item-1598-0-4000000A369860E1` |127| Vignette | `Vignette-0-[serverID]-[instanceID]-[zoneUID]-[vignetteID]-[spawnUID]` | — |128| BattlePet | `BattlePet-0-[ID]` | `BattlePet-0-00000338F951` |129| Cast | `Cast-[type]-[serverID]-[instanceID]-[zoneUID]-[spellID]-[castUID]` | — |130131### Extracting NPC ID from GUID132133```lua134local npcID = select(6, strsplit("-", UnitGUID("target")))135print(tonumber(npcID)) -- e.g., 448 for Hogger136```137138### Key Rules139140- Players keep their GUID forever (unless faction change/transfer)141- Creatures get a new GUID each spawn cycle142- Pets get a new GUID each time summoned143- GUIDs are recycled after server/instance restart144145> **Source:** https://warcraft.wiki.gg/wiki/GUID146147---148149## Core Unit Functions — Overview150151### Identity152153| Function | Returns | Description |154|----------|---------|-------------|155| `UnitName(unit)` | `unitName, unitServer` | Unit's name and realm |156| `UnitFullName(unit)` | `unitName, unitServer` | Full name with server |157| `UnitNameUnmodified(unit)` | `unitName, unitServer` | Name without modifications |158| `UnitNameFromGUID(guid)` | `unitName, unitServer` | Name from GUID |159| `UnitGUID(unit)` | `guid` | GUID string |160| `UnitTokenFromGUID(guid)` | `unitToken` | UnitId from GUID |161| `UnitClass(unit)` | `className, classFilename, classID` | Class info |162| `UnitClassBase(unit)` | `classFilename, classID` | Non-localized class |163| `UnitClassFromGUID(guid)` | `className, classFilename, classID` | Class from GUID |164| `UnitRace(unit)` | `localizedRace, englishRace, raceID` | Race info |165| `UnitSex(unit)` | `sex` | Gender (1=unknown, 2=male, 3=female) |166| `UnitLevel(unit)` | `level` | Unit level |167| `UnitEffectiveLevel(unit)` | `level` | Scaled level |168| `UnitFactionGroup(unit [, checkDisplayRace])` | `factionTag, localized` | Horde/Alliance |169| `UnitClassification(unit)` | `class` | "normal", "elite", "worldboss", etc. |170| `UnitCreatureType(unit)` | `name, id` | Beast, Humanoid, Undead, etc. |171| `UnitCreatureFamily(unit)` | `name, id` | Creature family (e.g., Crab) |172| `UnitCreatureID(unit)` | `creatureID` | NPC ID |173| `UnitPVPName(unit)` | `name` | Name with title |174| `GetPlayerInfoByGUID(guid)` | `class, engClass, race, engRace, sex, name, realm` | Info from GUID |175176### Health177178| Function | Returns | Notes |179|----------|---------|-------|180| `UnitHealth(unit [, usePredicted])` | `health` | **Returns secret value in 12.0** — pass directly to widgets |181| `UnitHealthMax(unit)` | `maxHealth` | **Returns secret value in 12.0** |182| `UnitHealthMissing(unit [, usePredicted])` | `missing` | Health deficit |183| `UnitHealthPercent(unit [, usePredicted [, curve]])` | `percent` | Health percentage |184| `UnitPercentHealthFromGUID(guid)` | `percent` | Health % from GUID |185| `UnitGetIncomingHeals(unit [, healer])` | `amount` | Predicted heals |186| `UnitGetTotalAbsorbs(unit)` | `amount` | Damage absorb shield |187| `UnitGetTotalHealAbsorbs(unit)` | `amount` | Healing absorb shield |188| `GetUnitHealthModifier(unit)` | `modifier` | Health modifier |189| `GetUnitMaxHealthModifier(unit)` | `modifier` | Max health modifier |190191### Power (Mana/Rage/Energy/etc.)192193| Function | Returns | Notes |194|----------|---------|-------|195| `UnitPower(unit [, powerType [, unmodified]])` | `power` | Current power |196| `UnitPowerMax(unit [, powerType [, unmodified]])` | `maxPower` | Maximum power |197| `UnitPowerMissing(unit [, powerType [, unmodified]])` | `missing` | Power deficit |198| `UnitPowerPercent(unit [, powerType [, ...]])` | `percent` | Power percentage |199| `UnitPartialPower(unit [, powerType [, unmodified]])` | `partialPower` | Fractional power |200| `UnitPowerType(unit [, index])` | `powerType, token, r, g, b` | e.g., 0=Mana, 1=Rage |201| `UnitPowerDisplayMod(powerType)` | `mod` | Display modifier |202| `GetUnitPowerModifier(unit)` | `modifier` | Power modifier |203204### Power Types (Enum.PowerType)205206| Value | Token | Description |207|-------|-------|-------------|208| 0 | Mana | Mana |209| 1 | Rage | Rage |210| 2 | Focus | Focus (Hunter pets) |211| 3 | Energy | Energy (Rogues, Monks, etc.) |212| 4 | ComboPoints | Combo Points |213| 5 | Runes | Death Knight Runes |214| 6 | RunicPower | Runic Power |215| 7 | SoulShards | Warlock Soul Shards |216| 8 | LunarPower | Balance Druid |217| 9 | HolyPower | Paladin Holy Power |218| 11 | Maelstrom | Shaman Maelstrom |219| 12 | Chi | Monk Chi |220| 13 | Insanity | Shadow Priest |221| 16 | ArcaneCharges | Arcane Mage |222| 17 | Fury | Demon Hunter Fury |223| 18 | Pain | Vengeance DH (legacy) |224| 19 | Essence | Evoker Essence |225226### State Checks227228| Function | Returns | Description |229|----------|---------|-------------|230| `UnitExists([unit])` | `bool` | Unit exists and can be targeted |231| `UnitIsVisible([unit])` | `bool` | Visible to client (not necessarily line of sight) |232| `UnitIsConnected(unit)` | `bool` | Not offline |233| `UnitIsDead(unit)` | `bool` | Dead |234| `UnitIsDeadOrGhost(unit)` | `bool` | Dead or ghost form |235| `UnitIsGhost(unit)` | `bool` | Ghost form |236| `UnitAffectingCombat(unit)` | `bool` | In combat |237| `UnitIsAFK(unit)` | `bool` | AFK (friendly only) |238| `UnitIsDND(unit)` | `bool` | Do Not Disturb |239| `UnitIsPlayer([unit])` | `bool` | Is a player character |240| `UnitIsEnemy(unit, target)` | `bool` | Units are hostile |241| `UnitIsFriend(unit, target)` | `bool` | Units are friendly |242| `UnitCanAttack(unit, target)` | `bool` | First can attack second |243| `UnitCanAssist(unit, target)` | `bool` | First can assist second |244| `UnitCanCooperate(unit, target)` | `bool` | Can cooperate |245| `UnitIsUnit(unit1, unit2)` | `bool` | Same unit |246| `UnitIsPVP(unit)` | `bool` | PvP flagged |247| `UnitIsCharmed([unit])` | `bool` | Charmed / mind controlled |248| `UnitIsFeignDeath(unit)` | `bool` | Feigning death (group only) |249| `UnitIsTapDenied(unit)` | `bool` | Tap denied (grey health bar) |250| `UnitIsTrivial(unit)` | `bool` | Grey to player |251| `UnitIsBossMob(unit)` | `bool` | Boss unit |252| `IsFalling([unit])` | `bool` | Currently falling |253| `IsFlying([unit])` | `bool` | On flying mount |254| `IsSwimming([unit])` | `bool` | Swimming |255| `IsStealthed()` | `bool` | Player is stealthed |256| `PlayerIsInCombat()` | `bool` | Player in combat |257258### Group Membership259260| Function | Returns | Description |261|----------|---------|-------------|262| `UnitInParty([unit])` | `bool` | In your party |263| `UnitInRaid([unit])` | `index` | In your raid (returns index) |264| `UnitInAnyGroup([unit])` | `bool` | In any group |265| `UnitPlayerOrPetInParty([unit])` | `bool` | Player or pet in party |266| `UnitPlayerOrPetInRaid([unit])` | `bool` | Player or pet in raid |267| `UnitInRange(unit)` | `inRange, checked` | Within 40yd (25yd Evoker) `#grouponly` |268| `UnitIsGroupLeader(unit [, cat])` | `bool` | Is group leader |269| `UnitIsGroupAssistant(unit)` | `bool` | Is assist |270| `UnitGroupRolesAssigned([unit])` | `role` | "TANK", "HEALER", "DAMAGER", "NONE" |271| `UnitIsInMyGuild(unit)` | `bool` | Same guild |272273### Casting Info274275| Function | Returns | Description |276|----------|---------|-------------|277| `UnitCastingInfo(unit)` | `name, displayName, textureID, startTimeMs, endTimeMs, isTradeskill, castID, notInterruptible, castingSpellID, castBarID` | Current cast info |278| `UnitChannelInfo(unit)` | `name, displayName, textureID, startTimeMs, endTimeMs, isTradeskill, notInterruptible, spellID, isEmpowered, numEmpowerStages, castBarID` | Channel info |279| `UnitCastingDuration(unit)` | `duration` | Cast duration |280| `UnitChannelDuration(unit)` | `duration` | Channel duration |281| `UnitEmpoweredChannelDuration(unit [, includeHold])` | `duration` | Empower duration |282283> **12.0.0 Change:** `notInterruptible` in `UnitCastingInfo` is now nilable. New `castBarID` return added.284285### Threat286287| Function | Returns | Description |288|----------|---------|-------------|289| `UnitThreatSituation(unit [, mob])` | `status` | 0=low, 1=close, 2=unsafe, 3=tanking |290| `UnitDetailedThreatSituation(unit, mob)` | `isTanking, status, scaledPct, rawPct, rawThreat` | Detailed threat |291| `UnitThreatPercentageOfLead(unit, mob)` | `percent` | % of lead |292| `UnitThreatLeadSituation(unit, mob)` | `status` | Lead situation |293294---295296## C_UnitAuras — Aura System297298The aura API provides buff/debuff data for units. Returns `AuraData` tables.299300### Key Functions301302| Function | Returns | Description |303|----------|---------|-------------|304| `C_UnitAuras.GetAuraDataByIndex(unit, index [, filter])` | `aura` | Aura by index |305| `C_UnitAuras.GetAuraDataByAuraInstanceID(unit, auraInstanceID)` | `aura` | Aura by instance ID |306| `C_UnitAuras.GetAuraDataBySlot(unit, slot)` | `aura` | Aura by slot |307| `C_UnitAuras.GetAuraDataBySpellName(unit, spellName [, filter])` | `aura` | Aura by spell name |308| `C_UnitAuras.GetBuffDataByIndex(unit, index [, filter])` | `aura` | Buff specifically |309| `C_UnitAuras.GetDebuffDataByIndex(unit, index [, filter])` | `aura` | Debuff specifically |310| `C_UnitAuras.GetPlayerAuraBySpellID(spellID)` | `aura` | Player aura by spell ID |311| `C_UnitAuras.GetAuraSlots(unit [, filter [, max [, token]]])` | `continuation, slots...` | Iterate aura slots |312| `C_UnitAuras.GetUnitAuraInstanceIDs(unit, filter [, max [, sort [, dir]]])` | `auraInstanceIDs` | All aura instance IDs |313| `C_UnitAuras.GetUnitAuras(unit, filter [, max [, sort [, dir]]])` | `auras` | All aura data |314| `C_UnitAuras.GetAuraDuration(unit, auraInstanceID)` | `duration` | Remaining duration |315| `C_UnitAuras.GetAuraBaseDuration(unit, auraID [, spellID])` | `duration` | Base duration |316| `C_UnitAuras.DoesAuraHaveExpirationTime(unit, auraID)` | `bool` | Has timer |317| `C_UnitAuras.IsAuraFilteredOutByInstanceID(unit, auraID, filter)` | `bool` | Filtered by current filter |318| `C_UnitAuras.WantsAlteredForm(unit)` | `bool` | Wants altered form |319320### Aura Filter Strings321322Filters are space-separated strings passed to aura query functions:323324| Filter | Description |325|--------|-------------|326| `"HELPFUL"` | Buffs only |327| `"HARMFUL"` | Debuffs only |328| `"PLAYER"` | Only auras cast by the player |329| `"RAID"` | Only auras relevant to the raid |330| `"CANCELABLE"` | Only cancelable auras |331| `"NOT_CANCELABLE"` | Only non-cancelable auras |332| `"INCLUDE_NAME_PLATE_ONLY"` | Include nameplate-only auras |333| `"MAW"` | Maw-specific auras |334335Combine with spaces: `"HELPFUL PLAYER"` = buffs cast by player.336337### AuraData Structure338339Fields returned in an AuraData table:340341| Field | Type | Description |342|-------|------|-------------|343| `name` | string | Aura name |344| `icon` | number | Texture file ID |345| `applications` | number | Stack count |346| `dispelName` | string? | Dispel type: "Magic", "Curse", "Disease", "Poison" |347| `duration` | number | Total duration (0 = indefinite) |348| `expirationTime` | number | `GetTime()` when it expires |349| `isFromPlayerOrPlayerPet` | bool | Cast by player or player's pet |350| `isHarmful` | bool | Is a debuff |351| `isHelpful` | bool | Is a buff |352| `isNameplateOnly` | bool | Only shows on nameplates |353| `isRaid` | bool | Shows in raid frames |354| `isStealable` | bool | Can be spellstolen |355| `sourceUnit` | UnitId? | Caster |356| `spellId` | number | Spell ID |357| `points` | table | Aura effect values |358| `auraInstanceID` | number | Unique instance ID for this application |359| `timeMod` | number | Time modifier |360| `charges` | number | Number of charges |361| `isBossAura` | bool | Boss aura |362| `nameplateShowAll` | bool | Show all stacks on nameplate |363| `nameplateShowPersonal` | bool | Show personal on nameplate |364365### Private Auras366367Private auras are auras where the spell data is hidden from addons. Used for encounter mechanics.368369| Function | Description |370|----------|-------------|371| `C_UnitAuras.AddPrivateAuraAnchor(args)` | Anchor a frame to a private aura's display position → `anchorID` |372| `C_UnitAuras.RemovePrivateAuraAnchor(anchorID)` | Remove private aura anchor |373| `C_UnitAuras.AddPrivateAuraAppliedSound(sound)` | Play sound when private aura applied → `soundID` |374| `C_UnitAuras.RemovePrivateAuraAppliedSound(soundID)` | Remove private aura sound |375| `C_UnitAuras.AuraIsPrivate(spellID)` | Check if spell is private |376| `C_UnitAuras.AuraIsBigDefensive(spellID)` | Check if big defensive CD |377| `C_UnitAuras.SetPrivateWarningTextAnchor(parent [, anchor])` | Set warning text anchor |378| `C_UnitAuras.TriggerPrivateAuraShowDispelType(show)` | Toggle dispel type display |379380### Aura Iteration Pattern381382```lua383-- Modern pattern: iterate by aura instance IDs384local function GetAllAuras(unit, filter)385 local auras = {}386 local ids = C_UnitAuras.GetUnitAuraInstanceIDs(unit, filter)387 for _, id in ipairs(ids) do388 local aura = C_UnitAuras.GetAuraDataByAuraInstanceID(unit, id)389 if aura then390 table.insert(auras, aura)391 end392 end393 return auras394end395396-- Get all player debuffs397local debuffs = GetAllAuras("player", "HARMFUL")398```399400### UNIT_AURA Event401402```lua403-- UNIT_AURA fires when any aura changes on a unit404-- Payload: unitTarget, updateInfo405-- updateInfo contains: addedAuras, updatedAuraInstanceIDs, removedAuraInstanceIDs406-- isFullUpdate (bool) — if true, full refresh is needed407408local frame = CreateFrame("Frame")409frame:RegisterUnitEvent("UNIT_AURA", "player")410frame:SetScript("OnEvent", function(self, event, unit, updateInfo)411 if updateInfo.isFullUpdate then412 -- re-scan all auras413 return414 end415 if updateInfo.addedAuras then416 for _, aura in ipairs(updateInfo.addedAuras) do417 print("Added:", aura.name, aura.spellId)418 end419 end420 if updateInfo.removedAuraInstanceIDs then421 for _, id in ipairs(updateInfo.removedAuraInstanceIDs) do422 print("Removed aura instance:", id)423 end424 end425end)426```427428---429430## C_PlayerInfo — Player Information431432| Function | Returns | Description |433|----------|---------|-------------|434| `C_PlayerInfo.GUIDIsPlayer(guid)` | `bool` | GUID belongs to a player |435| `C_PlayerInfo.GetClass(playerLocation)` | `className, classFilename, classID` | Player class |436| `C_PlayerInfo.GetName(playerLocation)` | `name` | Player name |437| `C_PlayerInfo.GetRace(playerLocation)` | `raceID` | Player race |438| `C_PlayerInfo.GetSex(playerLocation)` | `sex` | Player sex |439| `C_PlayerInfo.GetContentDifficultyCreatureForPlayer(unit)` | `difficulty` | Content difficulty |440| `C_PlayerInfo.GetPlayerMythicPlusRatingSummary(unit)` | `ratingSummary` | M+ rating |441442> **Source:** https://warcraft.wiki.gg/wiki/World_of_Warcraft_API#PlayerLocationInfo443444---445446## C_PaperDollInfo — Equipment & Inspection447448| Function | Returns | Description |449|----------|---------|-------------|450| `C_PaperDollInfo.GetInspectItemLevel(unit)` | `itemLevel` | Inspected unit's avg ilvl |451| `C_PaperDollInfo.GetInspectGuildInfo(unit)` | `achPoints, numMembers, guildName, realm` | Guild info for inspected |452| `C_PaperDollInfo.GetArmorEffectiveness(armor, attackerLvl)` | `effectiveness` | Armor DR % |453| `C_PaperDollInfo.GetArmorEffectivenessAgainstTarget(armor)` | `effectiveness` | Armor DR vs target |454| `C_PaperDollInfo.GetStaggerPercentage(unit)` | `stagger, staggerVsTarget` | Monk stagger % |455| `C_PaperDollInfo.GetMinItemLevel()` | `minItemLevel` | Minimum ilvl |456| `C_PaperDollInfo.CanAutoEquipCursorItem()` | `bool` | Can auto-equip |457| `C_PaperDollInfo.CanCursorCanGoInSlot(slot)` | `bool` | Cursor item fits slot |458| `C_PaperDollInfo.IsInventorySlotEnabled(slotName)` | `bool` | Slot enabled |459| `C_PaperDollInfo.GetInspectRatedBGData()` | `data` | Inspected rated BG info |460| `C_PaperDollInfo.GetInspectRatedSoloShuffleData()` | `data` | Inspected solo shuffle info |461462### Inspection Flow463464```lua465-- 1. Request inspection data466NotifyInspect("target")467468-- 2. Wait for INSPECT_READY event469local frame = CreateFrame("Frame")470frame:RegisterEvent("INSPECT_READY")471frame:SetScript("OnEvent", function(self, event, inspecteeGUID)472 local spec = GetInspectSpecialization("target")473 local ilvl = C_PaperDollInfo.GetInspectItemLevel("target")474 print("Spec:", spec, "iLvl:", ilvl)475 ClearInspectPlayer() -- Clean up476 self:UnregisterEvent("INSPECT_READY")477end)478```479480---481482## UnitRole — Group Roles483484| Function | Returns | Description |485|----------|---------|-------------|486| `UnitGroupRolesAssigned([unit])` | `"TANK"/"HEALER"/"DAMAGER"/"NONE"` | Assigned role |487| `UnitGroupRolesAssignedEnum([unit])` | `enum` | Role as enum value |488| `UnitGetAvailableRoles(unit)` | `tank, healer, dps` | Available roles (booleans) |489| `UnitSetRole(unit [, roleStr])` | `success` | Set role |490| `UnitSetRoleEnum(unit [, role])` | `success` | Set role by enum |491| `CanShowSetRoleButton()` | `bool` | Role button available |492| `InitiateRolePoll()` | `success` | Start role poll |493| `AreClassRolesSoftSuggestions()` | `bool` | Roles are soft suggestions |494495---496497## Player Character Stats498499These global functions query the player's character stats.500501### Combat Ratings & Stats502503| Function | Returns | Description |504|----------|---------|-------------|505| `GetCritChance()` | `percent` | Melee crit % |506| `GetRangedCritChance()` | `percent` | Ranged crit % |507| `GetHaste()` | `percent` | Haste % |508| `GetMeleeHaste()` | `percent` | Melee haste % |509| `GetRangedHaste()` | `percent` | Ranged haste % |510| `UnitSpellHaste(unit)` | `percent` | Spell haste % |511| `GetMastery()` | `percent` | Base mastery % |512| `GetMasteryEffect()` | `effect, coefficient` | Effective mastery |513| `GetDodgeChance()` | `percent` | Dodge % |514| `GetParryChance()` | `percent` | Parry % |515| `GetBlockChance()` | `percent` | Block % |516| `GetLifesteal()` | `percent` | Leech % |517| `GetAvoidance()` | `percent` | Avoidance % |518| `GetCombatRating(ratingIndex)` | `rating` | Raw combat rating value |519| `GetCombatRatingBonus(ratingIndex)` | `bonus` | Bonus % from rating |520| `UnitStat(unit, index)` | `cur, eff, posBuff, negBuff` | Primary stat (1=Str, 2=Agi, 3=Sta, 4=Int) |521| `UnitArmor(unit)` | `base, effective, real, bonus` | Armor values |522| `UnitAttackPower(unit)` | `ap, posBuff, negBuff` | Melee attack power |523| `UnitAttackSpeed(unit)` | `mainhand, offhand` | Attack speed |524| `UnitDamage(unit)` | `min, max, ohMin, ohMax, posBuff, negBuff, pct` | Damage range |525| `UnitRangedAttackPower(unit)` | `ap, posBuff, negBuff` | Ranged AP |526| `UnitRangedDamage(unit)` | `speed, min, max, posBuff, negBuff, pct` | Ranged damage |527| `GetManaRegen()` | `base, casting` | Mana regen/sec |528| `GetPowerRegen()` | `base, casting` | Power regen/sec |529530### Player XP & Level531532| Function | Returns | Description |533|----------|---------|-------------|534| `UnitXP("player")` | `xp` | Current XP |535| `UnitXPMax("player")` | `maxXP` | XP to next level |536| `GetMaxPlayerLevel()` | `level` | Level cap |537| `GetRestState()` | `exhaustionID, name, factor` | Rested state |538| `IsXPUserDisabled()` | `bool` | XP frozen |539540### Money & Economy541542| Function | Returns | Description |543|----------|---------|-------------|544| `GetMoney()` | `copper` | Total money in copper |545546### Movement547548| Function | Returns | Description |549|----------|---------|-------------|550| `GetUnitSpeed(unit)` | `current, run, flight, swim` | Movement speeds |551| `GetPlayerFacing()` | `radians` | Direction facing `#noinstance` |552| `UnitPosition(unit)` | `x, y, z, mapID` | World position `#noinstance` |553| `UnitDistanceSquared(unit)` | `distSq, checked` | Squared distance `#noinstance` |554| `UnitOnTaxi(unit)` | `bool` | On flight path |555556### Death & Resurrection557558| Function | Returns | Description |559|----------|---------|-------------|560| `RepopMe()` | — | Release spirit |561| `RetrieveCorpse()` | — | Resurrect at corpse |562| `AcceptResurrect()` | — | Accept rez offer |563| `DeclineResurrect()` | — | Decline rez offer |564| `ResurrectGetOfferer()` | `name` | Who is offering rez |565| `ResurrectHasSickness()` | `bool` | Rez will give sickness |566| `ResurrectHasTimer()` | `bool` | Must wait before accepting |567| `GetCorpseRecoveryDelay()` | `seconds` | Delay before rez |568| `GetReleaseTimeRemaining()` | `seconds` | Time until forced release |569| `C_IncomingSummon.HasIncomingSummon(unit)` | `bool` | Has pending summon |570| `C_IncomingSummon.IncomingSummonStatus(unit)` | `status` | Summon status |571| `UnitHasIncomingResurrection(unit)` | `bool` | Being resurrected |572573---574575## Secret Values — 12.0.0 Impact on Unit APIs576577Many unit functions now return **secret values** under certain conditions. See the `wow-api-important` instructions for full details.578579### Functions Returning Secrets580581| Function | When Secret |582|----------|-------------|583| `UnitHealth(unit)` | When health is restricted |584| `UnitHealthMax(unit)` | When health is restricted |585| `UnitName(unit)` | When unit identity restricted in combat (non-player units in instances) |586| `UnitClass(unit)` | First return conditionally secret |587| `UnitPower(unit)` | When power is restricted |588589### Safe Pattern: Display Health590591```lua592-- CORRECT: Pass secret values directly to widgets593local hp = UnitHealth("target")594local maxHp = UnitHealthMax("target")595myStatusBar:SetMinMaxValues(0, maxHp) -- accepts secrets596myStatusBar:SetValue(hp) -- accepts secrets597598-- WRONG: Do NOT compare or do math599-- if hp < maxHp * 0.3 then -- ERROR: cannot compare secrets600```601602### Checking Restrictions603604```lua605-- Check if unit identity is restricted606local isSecret = C_Secrets.ShouldUnitIdentityBeSecret("target")607local isHealthSecret = C_Secrets.ShouldUnitHealthMaxBeSecret("target")608local isPowerSecret = C_Secrets.ShouldUnitPowerBeSecret("target")609```610611---612613## Common Patterns614615### Unit Frame Health Bar616617```lua618local frame = CreateFrame("Frame", nil, UIParent)619local healthBar = CreateFrame("StatusBar", nil, frame)620healthBar:SetStatusBarTexture("Interface\\TargetingFrame\\UI-StatusBar")621healthBar:SetMinMaxValues(0, 1)622623local function UpdateHealth(unit)624 local hp = UnitHealth(unit)625 local maxHp = UnitHealthMax(unit)626 healthBar:SetMinMaxValues(0, maxHp)627 healthBar:SetValue(hp)628end629630frame:RegisterUnitEvent("UNIT_HEALTH", "target")631frame:RegisterUnitEvent("UNIT_MAXHEALTH", "target")632frame:SetScript("OnEvent", function(self, event, unit)633 UpdateHealth(unit)634end)635```636637### Check if Unit is a Healable Friendly638639```lua640local function IsHealableUnit(unit)641 return UnitExists(unit)642 and UnitCanAssist("player", unit)643 and not UnitIsDeadOrGhost(unit)644 and UnitIsConnected(unit)645end646```647648### Get NPC ID from Target649650```lua651local function GetNPCID(unit)652 local guid = UnitGUID(unit)653 if not guid then return nil end654 local unitType, _, _, _, _, npcID = strsplit("-", guid)655 if unitType == "Creature" or unitType == "Vehicle" then656 return tonumber(npcID)657 end658end659```660661---662663## Related Events664665| Event | Payload | Description |666|-------|---------|-------------|667| `UNIT_HEALTH` | `unitTarget` | Health changed |668| `UNIT_MAXHEALTH` | `unitTarget` | Max health changed |669| `UNIT_POWER_UPDATE` | `unitTarget, powerType` | Power changed |670| `UNIT_POWER_FREQUENT` | `unitTarget, powerType` | Power changed (frequent) |671| `UNIT_MAXPOWER` | `unitTarget, powerType` | Max power changed |672| `UNIT_AURA` | `unitTarget, updateInfo` | Auras changed |673| `UNIT_TARGET` | `unitTarget` | Target changed |674| `UNIT_LEVEL` | `unitTarget` | Level changed |675| `UNIT_NAME_UPDATE` | `unitTarget` | Name updated |676| `UNIT_FACTION` | `unitTarget` | Faction changed |677| `UNIT_FLAGS` | `unitTarget` | Flags changed (PvP, AFK, etc.) |678| `UNIT_SPELLCAST_START` | `unitTarget, castGUID, spellID` | Cast started |679| `UNIT_SPELLCAST_STOP` | `unitTarget, castGUID, spellID` | Cast stopped |680| `UNIT_SPELLCAST_SUCCEEDED` | `unitTarget, castGUID, spellID` | Cast succeeded |681| `UNIT_SPELLCAST_CHANNEL_START` | `unitTarget, castGUID, spellID` | Channel started |682| `UNIT_SPELLCAST_CHANNEL_STOP` | `unitTarget, castGUID, spellID` | Channel stopped |683| `UNIT_SPELLCAST_EMPOWER_START` | `unitTarget, castGUID, spellID` | Empower started |684| `UNIT_SPELLCAST_EMPOWER_STOP` | `unitTarget, castGUID, spellID, complete` | Empower stopped |685| `UNIT_THREAT_SITUATION_UPDATE` | `unitTarget` | Threat changed |686| `UNIT_THREAT_LIST_UPDATE` | `unitTarget` | Threat list changed |687| `UNIT_CONNECTION` | `unitTarget, isConnected` | Online/offline |688| `UNIT_STATS` | `unitTarget` | Stats changed |689| `UNIT_ATTACK_POWER` | `unitTarget` | AP changed |690| `UNIT_SPELL_HASTE` | `unitTarget` | Spell haste changed |691| `UNIT_COMBAT` | `unitTarget, event, flagText, amount, schoolMask` | Combat text event |692| `UNIT_INVENTORY_CHANGED` | `unitTarget` | Equipped items changed |693| `PLAYER_TARGET_CHANGED` | — | Player target changed |694| `PLAYER_FOCUS_CHANGED` | — | Focus target changed |695| `PLAYER_ENTERING_WORLD` | `isInitialLogin, isReloadingUi` | Zone/instance load |696| `PLAYER_DEAD` | — | Player died |697| `PLAYER_ALIVE` | — | Player alive (accept rez) |698| `PLAYER_UNGHOST` | — | Player no longer ghost |699| `PLAYER_REGEN_ENABLED` | — | Left combat |700| `PLAYER_REGEN_DISABLED` | — | Entered combat |701| `INSPECT_READY` | `inspecteeGUID` | Inspection data available |702| `GROUP_ROSTER_UPDATE` | — | Group composition changed |703| `ROLE_CHANGED_INFORM` | `changedName, from, oldRole, newRole` | Role changed |704705---706707## Restrictions & Gotchas708709| Restriction | Details |710|-------------|---------|711| `#noinstance` | `UnitPosition`, `UnitDistanceSquared`, `GetPlayerFacing` blocked in instances |712| `#grouponly` | `UnitInRange` only works for group members |713| `#nocombat` | `CheckInteractDistance` blocked in combat |714| Secret values (12.0) | Health, name, power may be secret — cannot compare/branch, only pass to widgets |715| `NotifyInspect` throttle | Inspecting too fast will be throttled by the server |716| `UnitIsPlayer` | Charmed players may return false for some APIs |717718> **Sources:**719> - https://warcraft.wiki.gg/wiki/World_of_Warcraft_API#Unit720> - https://warcraft.wiki.gg/wiki/World_of_Warcraft_API#UnitAuras721> - https://warcraft.wiki.gg/wiki/World_of_Warcraft_API#UnitRole722> - https://warcraft.wiki.gg/wiki/World_of_Warcraft_API#PlayerScript723> - https://warcraft.wiki.gg/wiki/World_of_Warcraft_API#PaperDollInfo724> - https://warcraft.wiki.gg/wiki/World_of_Warcraft_API#PlayerLocationInfo725> - https://warcraft.wiki.gg/wiki/UnitId726> - https://warcraft.wiki.gg/wiki/GUID727```