1. This is my first post and I may miss something.

    I would like to get the unitids of the NPCs around the character in defined radius or in the current subzone. I don't have the NPC in the target. The NPCs are friendly to me. Is this possible? Or do I have to use something like SilverDragon does?

    I want to know which NPCs are there (differs due Phasing) and sometimes which Buff/Debuff it has. So with the unitid I can make the call to get the buffs and debuffs.

    Hope someone can help :)

    Thanks in advance

    The short answer: No, there's not. This is deliberate on Blizzard's part. You'd have to use a workaround like SilverDragon.

    The long answer: I think you may be a little confused on terminology. There's a fixed set of basic unit ids, and then a set that can be derived from those by appending "target" one or more times. So:

    player pet target focus party1 - 5 raid1 - 40 arena1 - 5 boss1 - ?

    You can also append "pet" to the party, raid, and arena unit ids, and can append "target" one or more times to the unit ids so formed.

    You can theoretically scan this list - just go through it. It's generally not useful to append more than one "target" to anything (any NPC's target is probably going to be a member of your party or raid or one of their pets), so you don't have to do the infinite recursion. However, scanning it obviously won't give you all the NPCs in an area.

    Now, there is something called a "global unit id" (guid) that shows up in the combat log - but guids are not unit ids, and you can't pass them to function that require a unit id. So, for example, while you can pass UnitHealth() any of the above and their derivatives, you can't pass a guid to UnitHealth() and get anything useful back.

    You can't scan for guids in an area either - you can watch for them in the combat log, but for your purpose, that's not going to be very helpful, and in general it's not helpful either, since you have to have a unit id of the first type to find out anything about them.

    Thank you for the detailed answer. I was really confused.

    For my project it would be sufficient to know which NPCs are there per name. I don't have to read the buffs/debuffs. But that doesn't change much imo.

    SilverDragon uses some methods: Cache: Not practicable to delete the cache every time.

    Target: If the user has already taken it in the target or mouseover, than it's not real benefit, because he can see it himself.

    Nameplates: Only works if nameplates are on, which is not practical. Or who activates the nameplates for friendly NPCs.

    Macro: Seems best option as of know. A macro which interacts with the addon. I still have to look into details here. Afaik you can't execute "/target NPCxy" from an addon. That's why he makes this workaround over a macro. Is my assumption correct?

    That's correct - addons can't target directly, only through macros. The workarounds are a major pain, but they're the only way you're going to be able to do what you want as things are.

    So my idea would be a macro like this. Is this possible?

     /targetexact <exact NPC-name>
     /click <addoncall, reading NPC data, remembering data to next click>
     /targetexact  <2nd NPC name>
     /click <addoncall, ...>
     and so on
     ...
     ...
    
     /click <finish, show results>
    

    I'm not sure if the unitID (and associated data) will update immediately following the /targetexact or whether you need to wait for PLAYER_TARGET_CHANGED. Best way would be simply trying it out.