Could you please try following, written and tested with your shown samples. Please make sure you clear your browser cache before testing your URLs.
Options +FollowSymLinks -MultiViews
RewriteEngine ON
RewriteBase /
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.*)/?$ api/$1.php [L]
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…