API code optimization