Separate endpoints for view and api calls

* view calls are returning text/html
* api calls are returning application/json
Created a generic model to get spaces out of the API