It would be very helpful if there was a way to get the group ID of the 365 group that is assigned to a sharepoint site.
Right now the only way to get a group ID is to call /sites and use the mailNickname to do a string comparison to a group name. This is unreliable as site names can be changed and even the email nickname and site name could be configured to match right from the start.