server api refactor