Refactored code for a rest api interface.

For the rest api interface the url generation code was needed as is 
and not wrapped in a view.