Modularised RESTful API

api.php now just acts as a router for the request. Logic handled by
appropriate files.