Simon Black created a nice script based on the Model SDK, which counts the entities, microflows and pages and outputs that in a word document.
Yes, take a look at de Mendix SDK: https://docs.mendix.com/apidocs-mxsdk/mxsdk/
There are already some scripts outthere to retrieve some metrics.
Regards,
Ronald