Updated API to support JSON return. Added docs