How to get trunk list and extensions list

I’m writing panel to show online calls.
What is a proper way of getting list of all trunks and extensions ?
I 'm trying with AMI sippeers or command sip show peers but I’m getting trunks and extensions together, how to distinguish trunks from extensions ?
Do I need to parse config files ?


Trunks and extesnsions are terms used in GUIs for Asterisk, not Asterisk itself. An extension in Asterisk is not a pysical object, but simply a number or other string that identifies a service. There is no explicit distinction in files like sp.conf.

Asterisk GUIs tend to categorise devices into trunks and extensions, but this is the wrong forum for details about he implementation of those GUIs.

If you are using raw Asterisk, and you want to enumerate GUI type extensions and extensions, you need to structure your channel driver configuration files and extension files in similar ways to those used by the GUIs.