That would be using the tag data that is supplied with the message
@badge-info=<badge-info>;badges=<badges>;color=<color>;display-name=<display-name>;emotes=<emotes>;id=<id-of-msg>;mod=<mod>;room-id=<room-id>;subscriber=<subscriber>;tmi-sent-ts=<timestamp>;turbo=<turbo>;user-id=<user-id>;user-type=<user-type> :<user>!<user>@<user>.tmi.twitch.tv PRIVMSG #<channel> :<message>
So you just need to enable the CAPabilities for Tags (and most people also grab commands) and parse out the tag data for color, displaynane and badges.
It’s there in chat itself no API calls needed
Cap requesting is covered here - Chat & Chatbots | Twitch Developers
Parsing the data, thats up to you to devise but heres a quick JS example - https://github.com/BarryCarlyon/twitch_misc/tree/main/chat