Get started
Get started

Quickstart

Quickstart

Route a hike from Chamonix to Argentière with the Data API. You need a Mountaya account and two keys.

1

Get your keys

In the Mountaya app, open Organization → API keys and create two keys:

  • a publishable key (pk_…) with the data scope, and
  • a secret key (sk_…), which stays on your server.

Export them where your code runs:

export MOUNTAYA_PUBLISHABLE_KEY="pk_your_publishable_key"
export MOUNTAYA_SECRET_KEY="sk_your_secret_key"

No account yet? Create an account and keys takes two minutes.

2

Mint a session token

Every Data API request carries a session token. Your server mints it with the secret key.

export MOUNTAYA_SESSION_TOKEN=$(curl -s -X POST https://api.mountaya.com/v1/sessions \
  -H "X-API-Key: $MOUNTAYA_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"publishable_key\": \"$MOUNTAYA_PUBLISHABLE_KEY\"}" | jq -r .data.token)
Response
{
  "data": {
    "token": "sess_your_session_token",
    "expires_at": "2026-11-09T09:18:39.816061Z",
    "user_id": null
  }
}

The token lasts five minutes. Mint a fresh one when it expires.

3

Query directions

Send the publishable key and the token with a directions query. Coordinates are [longitude, latitude].

curl https://data.mountaya.com/graphql \
  -H "X-API-Key: $MOUNTAYA_PUBLISHABLE_KEY" \
  -H "X-Session-Token: $MOUNTAYA_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "query Directions($input: DirectionsInput!) { directions(input: $input) { routes { distance duration summary } } }",
    "variables": {
      "input": {
        "activity": "HIKING_AND_TRAIL",
        "waypoints": [[6.8712, 45.9231], [6.9271, 45.9822]]
      }
    }
  }'
Response
{
  "data": {
    "directions": {
      "routes": [
        {
          "distance": 9005.14542243658,
          "duration": 9631.009017156648,
          "summary": "9.0 km, ~2h40m, +277m / -56m elevation, 67% path, 12% track, 8% road."
        }
      ]
    }
  }
}

Distances are in meters and durations in seconds. A failed query still answers 200 OK, with an errors array: check it on every response.

Next steps

Last updated