I'm not sure what's the best way to get format-name ⇒ formatID.

But this is one possible way:

(Note: this only gets formats that are available in the current clipboard. So use this to check whether a format is available.)