Refactor views/APIs

This commit moves API requests (those urls under /api/) to their own
file and makes it slightly easier to define new APIs.