You need two things:
- https://wow.gamepedia.com/API_UnitReaction in which case the unitID ("player") and the unitID of the comparison.
- The global table FACTION_BAR_COLORS in which to pass the reaction number above.
Lua Code:
local reaction = UnitReaction("target", "player")
local reactionColor = FACTION_BAR_COLORS[reaction]