refactor api url generation