api code optimization