Hi Kentico Dev!
You can get JSON with your page widgets :
var docCultureInfo = DocumentCultureDataInfoProvider.GetDocumentCultureInfo(homePage.DocumentID);
var widgetsJson = docCultureInfo.DocumentPageBuilderWidgets
And then with JObject turn this string into a model and count all widgets