Can you please give me a short example how we can retrieve attributes of any particular template?
Are you wanting the AFAttributeTemplates of a particular AFElementTemplate, the AFAttributes for all AFElements from a particular AFElementTemplate, the AFAttributes for a particular AFAttributeTemplate, or something else?
Take a look at the examples for the AFAttributeSearch.FindAttributes method to find AFAttributes and you would use a 'Template' filter in the 'Element' sub-filter of the search query if you are wanting all attributes from a particular AFElementTemplate.
Can we find attribute by filtering its category?
Yes as of 2017 R2 you can. See the documentation here: AFSearchFilter Enumeration
The Search Overview topic in the SDK help also provides more information about searching.
Retrieving data ...