The quest IDs are discovered by comparing a list of completed IDs to a new list after killing the rare. There is no method to directly search quest IDs.
You can download
BfA treasures for HandyNotes and open the Rares.lua file which has all the rare quest IDs.