Refactor API to new data model