Moved pagination to api and json rendering