Update api.php

Make it class extension friendly, especially for method addApi