Get started
Data API

Itineraries

Itineraries

Two queries read the itineraries you already have: itinerary returns one in full, and exportItinerary prepares it as a route file. To create or edit an itinerary, use the Map Studio API.

Set up

Every sample on this page reuses this setup. It mints a session token with your secret key, so run it on your server.

export MOUNTAYA_PUBLISHABLE_KEY="pk_your_publishable_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)

This token names no member, so it reads your itineraries as last published. To read drafts, mint it with a member's user_id, as authentication shows.

itinerary

Read one itinerary with its segments and waypoints. Replace the id with one of yours: search finds it by name.

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 Itinerary($input: ItineraryInput!) { itinerary(input: $input) { name activitySlug distance ascent segments { name distance duration } waypoints { name point } } }",
    "variables": {
      "input": { "id": "0b6d1a4e-6d3f-4f7a-9c2e-1f0a5b8c3d21" }
    }
  }'
Response
{
  "data": {
    "itinerary": {
      "name": "Docs Tour du Mont-Blanc",
      "activitySlug": "HIKING_AND_TRAIL",
      "distance": 16152.93,
      "ascent": 941,
      "segments": [
        {
          "name": "Day 1: Col de Voza",
          "distance": 4477.94,
          "duration": 7650.52
        },
        {
          "name": "Day 2: Les Contamines",
          "distance": 11674.99,
          "duration": 11698.57
        }
      ],
      "waypoints": [
        {
          "name": "Col de Voza",
          "point": [6.7621, 45.8842]
        }
      ]
    }
  }
}

Segments come in order, with distances in meters and durations in seconds. Select a segment's geometry to draw it, and groups for named legs such as "Day 1".

exportItinerary

Prepare an itinerary as a route file. The query answers a short-lived download link, not the file itself.

query ExportItinerary {
  exportItinerary(input: { id: "0b6d1a4e-6d3f-4f7a-9c2e-1f0a5b8c3d21", format: GPX }) {
    url
    filename
    format
    expiresAt
  }
}

Fetch url before expiresAt to download the file. format takes GPX, KML, KMZ, GEOJSON, CSV, FIT, or TCX.

Next steps

Last updated