Refactoring of API.js.