final API code