I haven’t seen the total counts being exposed in an API, but the individual policy violations including the threat level are available through the Policy Violations by Report REST API. If you count all the threatLevel results per group and application, you should end up with the same number the GUI calculates.
If you only have one policy per threat group, you could also use the Success Metrics Data REST API and just multiply the number of openCountAtTimePeriodEndxxx with the threat level of your corresponding policy.