How do I search for Team Sites and Communication Sites using SharePoint Search REST API?
You need to use the below endpoint:
/_api/search/query?querytext='contentclass:sts_site webtemplate=SITEPAGEPUBLISHING webtemplate=GROUP'&rowlimit=500
The base template value of Communication site is
SITEPAGEPUBLISHING and that of modern team site backed by O365 group is
Reference - List all communication sites in SPO
Note - at the moment, private groups are not visible via search even if you are a member of the group.