move client getting code to api