refactor api package