Refactored api routes to accept params