When using nvim_buf_add_highlight there is no way to query the list of existing highlights.
I've mentioned this in https://github.com/neovim/neovim/issues/6270#issuecomment-286225069, and while I would need it mainly for Neomake's tests (where a workaround would be to store it yourself), I think it's useful to have in general for introspection, debugging etc.
It should be possible to query a specific highlight (by id), or get a list of all existing ones (per buffer, and globally).
The plan is to eventually integrate add_highlight with extmarks #5031 ideally highlights will be extmarks with extra data attached and will be manipulated with the same API functions.
Most helpful comment
The plan is to eventually integrate
add_highlightwith extmarks #5031 ideally highlights will be extmarks with extra data attached and will be manipulated with the same API functions.