Clean up api.php, add agpl header