I saw in the sonar time machine that it was possible to see for each analysis the number of blocker and critical issues, but I didn't find where these metrics are stocked and how to retrieve them one by one externally with a Java program.
You should use the web service api/timemachine/index. It is documented within the application, for example at https://sonarqube.com/web_api/api/timemachine/index
The metrics for having numbers of issues are violations
(total number, whatever the severity), blocker_violations
, critical_violations
, major_violations
, minor_violations
and info_violations
.