This is the best option for free terrain tiles. There are four formats, though "Terrarium" is the most used. It maps RGB pixels in a PNG to raw elevation values using this formula [0].
If you're using Mapbox GL, you can just point your map to [1] to fetch the tiles, and then use it as a hillshade. I do that in my topographic map style [2].
Additionally, the `elevatr` package (https://github.com/jhollist/elevatr) serves tiles directly from AWS Open Data Terrain Tiles. I don't believe it requires a key.
Related: in my masterclass (free and open source, materials here: https://github.com/tylermorganwall/MusaMasterclass) I also walk through how you can convert LIDAR data into hi-res DEMs to generate 2D and 3D maps
Mapbox has an API you can query from--I believe they have a free tier. The `ceramic` package makes this easy to pull from, but you need to get a Mapbox key first: