To add to what has already been said, with OSM you’ve also got the option of just downloading the data, loading it into a database and doing any sort of query you want on it. You’re not limited to “remote” APIs.