Changed api.js to a class