API Documentation

Our API is designed to be a simple, drop-in replacement for the Google Elevation API, providing a familiar and easy-to-use interface.

Authentication

An API key is required for all requests. You can get a free API key by selecting a plan on our homepage. The key must be included in all requests, either as a query parameter or as an HTTP header.

Option 1: Query Parameter (Recommended)

Include your API key as the `key` parameter in the request URL.

curl "https://api.terraintap.com/elevation/json?locations=40.714224,-73.961452&key=YOUR_API_KEY"

Option 2: HTTP Header

For added security, you can also provide your key in the `X-API-Key` HTTP header.

curl -H "X-API-Key: YOUR_API_KEY" "https://api.terraintap.com/elevation/json?locations=40.714224,-73.961452"

Advanced Use Cases

Multiple Locations

You can request elevation data for multiple locations in a single request by separating the latitude/longitude pairs with a pipe (|) character, up to a maximum of 512 coordinates per request.

# Request for two separate points
curl "https://api.terraintap.com/elevation/json?locations=39.7391536,-104.9847034|36.1699412,-115.1398296&key=YOUR_API_KEY"

# Response
{
  "results": [
    {
      "elevation": 1609.0,
      "location": { "lat": 39.7391536, "lng": -104.9847034 },
      "resolution_meters": 30.0
    },
    {
      "elevation": 618.0,
      "location": { "lat": 36.1699412, "lng": -115.1398296 },
      "resolution_meters": 30.0
    }
  ],
  "status": "OK"
}

Path Sampling

To get elevation data for a series of evenly spaced points along a path, use the path and samples parameters. The path is a pipe-separated list of two or more coordinates defining the path, and samples is the number of points you want to retrieve along that path, up to a maximum of 512 coordinates per request.

# Request for 3 samples along a path from Denver to Colorado Springs
curl "https://api.terraintap.com/elevation/json?path=39.7391536,-104.9847034|38.8338816,-104.8213634&samples=3&key=YOUR_API_KEY"

# Response
{
  "results": [
    {
      "elevation": 1609.0,
      "location": { "lat": 39.7391536, "lng": -104.9847034 },
      "resolution_meters": 30.0
    },
    {
      "elevation": 1874.0,
      "location": { "lat": 39.2864676, "lng": -104.9030189 },
      "resolution_meters": 30.0
    },
    {
      "elevation": 1839.0,
      "location": { "lat": 38.8338816, "lng": -104.8213634 },
      "resolution_meters": 30.0
    }
  ],
  "status": "OK"
}

XML Output

By default, the API returns JSON. However, you can request XML output by simply replacing /json with /xml in the request URL.

# Example Request for XML output
curl "https://api.terraintap.com/elevation/xml?locations=40.714224,-73.961452&key=YOUR_API_KEY"

# Example Response (XML)
<ElevationResponse>
  <status>OK</status>
  <result>
    <elevation>10.0</elevation>
    <location>
      <lat>40.714224</lat>
      <lng>-73.961452</lng>
    </location>
    <resolution>30.0</resolution>
  </result>
</ElevationResponse>