factorize api request