I do not think you can get this information directly from the DNG REST API. You can create a (internal) variable in RPE, initialize it to 0 and increment it using assignment or using JavaScript Code and then print the variable.
Daniel Moul selected this answer as the correct answer
I want following count to be displayed inside a widget on the DNG Dashboard
1) artifact count in modules
2) Artifact count in all modules in project area
3) Artifact count in project area
4) Artifact count in all module view in a project area
Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means.
Learn more here.