API: Include ApiMain construction in api.php try-catch block