API and SQL queries