refactor api files