Firstly, the data is freely available. It's NASA's SRTM [1], downloadable from a zillion mirror sites.
Then just take some code to calculate a lat/long offset and find the right position in the right tile. Bob Osola has some easily portable PHP for this if you need it [2].
Free hint: Putting both your tiles and your (Lua) lookup code in Redis, then calling the latter with EVALSHA, is a really neat and fast way to do this.
If you really need ocean depths, higher resolutions than SRTM offers, or stuff above 60 degrees latitude, then it gets a little more complex. But for 90% of cases doing it yourself is eminently practicable.
[1] http://www2.jpl.nasa.gov/srtm/ [2] http://www.osola.org.uk/elevations/