Rename lib.api to lib.endpoint
Add standard JSON stuff to api
Merge pull request #43 from mdmoss/master

Standardise JSON responses and fix imports