replace api() with sql()