Quickstart
From no key to your first cited value in three steps.
1. Get an API key
Create a key on the Get an API key page with your email. It is shown once, so copy it, then keep it in an environment variable:
export INVARIANT_API_KEY="ief_..."
2. Pick a coordinate
Any point in the United States, as decimal latitude and longitude (WGS84). For example, Ashburn, Virginia:
lat 39.0438, lng -77.4874
3. Fetch a field
curl -s https://api.invariant-ai.com/v1/fetch \
-H "X-API-Key: $INVARIANT_API_KEY" \
-H "Content-Type: application/json" \
-d '{"lat": 39.0438, "lng": -77.4874, "fields": ["elevation"]}'
import os, requests
r = requests.post(
"https://api.invariant-ai.com/v1/fetch",
headers={"X-API-Key": os.environ["INVARIANT_API_KEY"]},
json={"lat": 39.0438, "lng": -77.4874, "fields": ["elevation"]},
timeout=30,
)
r.raise_for_status()
f = r.json()["fields"]["elevation"]
print(f["value"], f["unit"], f["source"], f["confidence"])
const r = await fetch("https://api.invariant-ai.com/v1/fetch", {
method: "POST",
headers: { "X-API-Key": process.env.INVARIANT_API_KEY, "Content-Type": "application/json" },
body: JSON.stringify({ lat: 39.0438, lng: -77.4874, fields: ["elevation"] }),
});
const { fields } = await r.json();
console.log(fields.elevation.value, fields.elevation.source);
You get back the value with its source:
{
"value": 89.63117218,
"unit": "meters",
"status": "ok",
"source": "USGS_3DEP_COG",
"confidence": "medium",
"cached": false
}
Ask for the same point again and cached is true: the answer comes from our 24 hour cache in a fraction of the time.