Elevation lookup

Metres above mean sea level for one or many points.

GEThttps://api.mygeocode.com/v1/elevation

Parameters

ParameterTypeDescription
lat, lonrequired*numberA single point.
locationsrequired*string*Alternative to lat and lon: up to 100 points as lat,lon|lat,lon|... or as an encoded polyline enc:.... Each point counts as one request.
path, samplesoptionalstring, integer*Alternative to lat and lon: samples points (2 to 100) evenly spaced along the path lat,lon|lat,lon|..., first and last point included. Answered like locations.
bounds, rows, colsoptionalstring, integer*Alternative to lat and lon: a grid of rows by cols points (each at least 2, at most 100 points in all) over south,west,north,east, southern row first, west to east. Answered like locations.
keyoptionalstringAPI key, if not sent as a header.

The endpoint also accepts POST with a JSON body {"locations": [[lat, lon], ...]} for long lists that would not fit in a URL.

Example

$ curl -H "X-API-Key: YOUR_KEY" "https://api.mygeocode.com/v1/elevation?locations=36.2381,-116.8175|31.5590,35.4732"
const points = [[36.2381, -116.8175], [31.5590, 35.4732]];
const url = new URL("https://api.mygeocode.com/v1/elevation");
url.searchParams.set("locations", points.map((p) => p.join(",")).join("|"));

const { results } = await (await fetch(url, { headers: { "X-API-Key": "YOUR_KEY" } })).json();
results.forEach((r) => console.log(r.elevation_m));
import requests

points = [(36.2381, -116.8175), (31.5590, 35.4732)]
locations = "|".join(f"{lat},{lon}" for lat, lon in points)
r = requests.get("https://api.mygeocode.com/v1/elevation", params={"locations": locations}, headers={"X-API-Key": "YOUR_KEY"}, timeout=10)
for item in r.json()["results"]:
    print(item["elevation_m"])
Response
{
  "status": "ok",
  "results": [
    { "lat": 36.2381, "lon": -116.8175, "elevation_m": -82.0, "resolution_m": 463.8 },
    { "lat": 31.559, "lon": 35.4732, "elevation_m": -416.0, "resolution_m": 463.8 }
  ]
}

Response fields

FieldTypeDescription
resultsarrayOne entry per point, in input order.
results[].lat, results[].lonnumberThe point, as sent or as computed along a path or grid.
results[].elevation_mnumber or nullMetres above mean sea level, one decimal. Negative below sea level, including the sea floor over open ocean (the dataset carries bathymetry). null only where the dataset has no value.
results[].resolution_mnumberGrid spacing of the dataset in metres: 463.8 (15 arc-seconds).

Notes

The same lookup in other providers' formats

If you already have code written against one of these providers, keep it: the drop-in host accepts the same path and parameters and answers in that provider's response shape, with this endpoint behind it. See how the drop-ins work.

ProviderHostPath
Google Maps Platformgapi.mygeocode.com/maps/api/elevation/json?locations=lat,lng|lat,lng
/maps/api/elevation/json?locations=enc:POLYLINE
/maps/api/elevation/json?path=lat,lng|lat,lng&samples=N
Bing Maps REST Servicesbing.mygeocode.com/REST/v1/Elevation/List?points=lat,lon,lat,lon
/REST/v1/Elevation/Polyline?points=lat,lon,lat,lon&samples=N
/REST/v1/Elevation/Bounds?bounds=S,W,N,E&rows=R&cols=C (GET or POST)
MapQuestmapquest.mygeocode.com/elevation/v1/profile?latLngCollection=lat,lng,lat,lng&shapeFormat=raw&unit=m
Open-Elevationopenelevation.mygeocode.com/api/v1/lookup?locations=lat,lon|lat,lon
/api/v1/lookup (POST, JSON body)

Errors

400 invalid_request when neither a point nor locations is given, when a coordinate is out of range or malformed, when there are more than 100 points, or when samples, rows or cols would produce more than 100. 503 backend_unavailable when the elevation service does not answer; nothing is counted.