Implement #447 : added stats json api by type and state

Here's the implementation of the stats route.
Let me know if you need more stuff.