# Routing

> Canonical URL: https://docs.mountaya.com/en/apis/data/routing/
> Last updated: 2026-11-27
> Rules for agents: https://docs.mountaya.com/llms.txt#rules-for-agents

Route between waypoints, suggest routes to a target distance, map the ground in reach, and compare travel times.

Four queries route on the trail network: `directions` between waypoints, `suggestions` shaped to a distance, `isochrones` for the ground in reach, and `matrix` for travel times between places.

## 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.

**cURL**

```bash
export MOUNTAYA_PUBLISHABLE_KEY="pk_your_publishable_key"
export MOUNTAYA_DATA_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)
```

**TypeScript**

```typescript
import { Mountaya } from "@mountaya/client";
import { MountayaAdmin } from "@mountaya/client/admin";

const publishableKey = process.env.MOUNTAYA_PUBLISHABLE_KEY ?? "";
const secretKey = process.env.MOUNTAYA_SECRET_KEY ?? "";

const server = new Mountaya({ credential: { secretKey } });
const { data: session } = await new MountayaAdmin(server).sessions.postSession({
  body: { publishable_key: publishableKey },
});

const mountaya = new Mountaya({
  credential: { publishableKey, sessionToken: session.token },
});
```

**Python**

```python
import os
import requests

session = requests.post(
    "https://api.mountaya.com/v1/sessions",
    headers={"X-API-Key": os.environ["MOUNTAYA_SECRET_KEY"]},
    json={"publishable_key": os.environ["MOUNTAYA_PUBLISHABLE_KEY"]},
    timeout=10,
).json()["data"]
```

A session token lasts five minutes, so mint a new one when it expires. [Authentication](https://docs.mountaya.com/en/authentication.md) covers tokens in a browser.

## Directions

Route a hike from Chamonix to Argentière. Coordinates are `[longitude, latitude]`.

**cURL**

```bash
curl https://data.mountaya.com/graphql \
  -H "X-API-Key: $MOUNTAYA_PUBLISHABLE_KEY" \
  -H "X-Session-Token: $MOUNTAYA_DATA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "query Directions($input: DirectionsInput!) { directions(input: $input) { routes { distance duration summary avoidance } } }",
    "variables": {
      "input": {
        "activity": "HIKING_AND_TRAIL",
        "waypoints": [[6.8712, 45.9231], [6.9271, 45.9822]],
        "avoid": ["TOLLWAY", "RESTRICTED_ACCESS"]
      }
    }
  }'
```

**TypeScript**

```typescript
const { routes } = await mountaya.data.directions(
  {
    activity: "HIKING_AND_TRAIL",
    waypoints: [
      [6.8712, 45.9231],
      [6.9271, 45.9822],
    ],
    avoid: ["TOLLWAY", "RESTRICTED_ACCESS"],
  },
  { select: { routes: { distance: true, duration: true, summary: true, avoidance: true } } },
);

console.log(routes[0]?.summary, routes[0]?.avoidance);
```

**Python**

```python
query = """
query Directions($input: DirectionsInput!) {
  directions(input: $input) { routes { distance duration summary avoidance } }
}
"""

result = requests.post(
    "https://data.mountaya.com/graphql",
    headers={
        "X-API-Key": os.environ["MOUNTAYA_PUBLISHABLE_KEY"],
        "X-Session-Token": session["token"],
    },
    json={
        "query": query,
        "variables": {
            "input": {
                "activity": "HIKING_AND_TRAIL",
                "waypoints": [[6.8712, 45.9231], [6.9271, 45.9822]],
                "avoid": ["TOLLWAY", "RESTRICTED_ACCESS"],
            }
        },
    },
    timeout=30,
).json()

if "errors" in result:
    raise RuntimeError(result["errors"])
print(result["data"]["directions"]["routes"][0]["summary"])
```

**Response**

```json
{
  "data": {
    "directions": {
      "routes": [
        {
          "distance": 9005.14542243658,
          "duration": 9631.009017156648,
          "summary": "9.0 km, ~2h40m, +277m / -56m elevation, 67% path, 12% track, 8% road.",
          "avoidance": "NOT_NEEDED"
        }
      ]
    }
  }
}
```

`distance` is in meters and `duration` in seconds. The duration follows the terrain: a climb is slower than a descent. Select `geometry` for the route as a GeoJSON line, and `elevation` for its ascent and descent.

- `directions(input: DirectionsInput!)` takes `activity` (required), `waypoints` (required), `speed`, and `avoid`. It returns `routes`, a list of `DirectionsRoute`.
- `waypoints`: ordered `[longitude, latitude]` pairs, 2 to 45 of them, and the straight polyline through them, waypoint to waypoint, at most 100 km long. Either limit is `VALIDATION_FAILED` at `["input", "waypoints"]`. Split a longer trip into legs.
- Each waypoint is exactly two numbers, longitude in -180..180 and latitude in -90..90; otherwise `VALIDATION_FAILED` at `["input", "waypoints", i]`. The count, the length and `speed` are checked before any single waypoint, so an out-of-range waypoint that stretches the polyline past 100 km is first reported at `["input", "waypoints"]`.
- A waypoint no routable way reaches for the activity, or waypoints no route connects, is `VALIDATION_FAILED` at `["input", "waypoints"]`. A request within the 100 km bound that the routing engine still measures past it is `VALIDATION_FAILED` at `["input"]`, with the engine's own message in English whatever `Accept-Language` asks. Every other failure of the routing engine is `INTERNAL_ERROR`.
- `speed`: km/h on LEVEL ground, a finite number greater than 0; anything else (NaN and Infinity included) is `VALIDATION_FAILED` at `["input", "speed"]`. It replaces the activity's default flat pace. It is not the speed the route is traveled at: the model resolves a speed per stretch from this pace and the ground, caps each stretch at the activity's maximum speed, and integrates the duration. While no stretch reaches that cap, halving `speed` doubles `duration`; the route and its distance do not change.
- `distance`: meters, the planimetric great-circle length of the returned `geometry`, elevation ignored. Measuring the geometry reproduces it.
- `duration`: seconds, computed over the terrain the route crosses (grade, surface, trail difficulty), anchored on `speed` or the activity default. Integrating `analysis.speedInfo` over the geometry reproduces it exactly.
- `elevation`: `ElevationSummary` with `altitude { min max }`, `ascent`, `descent`, and `gradient { min max }` in degrees.
- `geometry`: a GeoJSON `LineString` of `[longitude, latitude, altitude]`.
- `analysis`: `GeometryAnalysis`, always present. Its surface, way-type and trail-difficulty lists are empty for activities without analysis; only hiking and trail running, professional trail, running and road cycling populate them. `slopeInfo` and `speedInfo` are populated for every activity. See [analysis](https://docs.mountaya.com/en/apis/data/analysis.md).
- `steps`: turn-by-turn steps (`fromIndex`, `toIndex`, `type`, `name`, `distance`, `duration`, `exitNumber`). A step's `distance` is the engine's length for the step rescaled onto the measured route.
- `summary`: one line such as `9.0 km, ~2h40m, +277m / -56m elevation, 67% path, 12% track, 8% road.` Read numbers from the typed fields, not from this string.
- `avoidance`: what the `avoid` list achieved. See hazards below.

### Hazards and avoidance

Some ways carry a toll or an access restriction, such as private or permit-only land. `directions` may cross one, so read `analysis.advisories` before you show the route. Pass `avoid` to route around them, then read `avoidance`.

| `avoidance` | Meaning |
| --- | --- |
| `NOT_REQUESTED` | You sent no `avoid` list. |
| `NOT_NEEDED` | The route crossed none of the hazards you named. |
| `APPLIED` | The route was rerouted around them. Check `advisories` for any other hazard. |
| `NO_ROUTE` | No route avoids them, so the original route comes back. |

- Every routed result reports what it crosses on `analysis.advisories`: the booleans `tollway` and `restrictedAccess`, plus the coordinate index ranges `tollwayInfo` and `roadAccessInfo`. Restricted access covers private, destination-only, customers, delivery, permit, and forbidden ways. A permissive way, where the owner tolerates passage, does not raise `restrictedAccess`.
- `avoid` takes `TOLLWAY`, `RESTRICTED_ACCESS`, or both. Omitted or empty routes normally. Naming a hazard costs a second routing pass only when the first route crosses it.
- `APPLIED` means the returned route is the rerouted one; it may still cross a different hazard, so read `advisories`.
- `NO_ROUTE` usually means a waypoint sits ON the hazardous way, which cannot be routed around. A reroute that fails on Mountaya's side also keeps the first route as `NO_ROUTE`, and the field then carries an `INTERNAL_ERROR` entry in `errors` beside its data; that request is recorded as a failure (5xx) and counts toward neither the monthly allowance nor an invoice.
- `SKI_TOURING`, `CROSS_COUNTRY_SKIING` and `SNOWSHOE_WALKING` routes carry no per-stretch hazard data: for them `avoidance` is always `NOT_NEEDED`, and the advisories alone report what the route crosses.
- `directions` is the only query that can return a route crossing a hazard. `suggestions` never does.

## Suggestions

Ask for routes shaped to a distance and an ascent. This one looks for a longer way to Argentière: about 12 km with 600 m of climbing.

**cURL**

```bash
curl https://data.mountaya.com/graphql \
  -H "X-API-Key: $MOUNTAYA_PUBLISHABLE_KEY" \
  -H "X-Session-Token: $MOUNTAYA_DATA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "query Suggestions($input: SuggestionsInput!) { suggestions(input: $input) { routes { seed distance duration summary } } }",
    "variables": {
      "input": {
        "activity": "HIKING_AND_TRAIL",
        "start": [6.8712, 45.9231],
        "end": [6.9271, 45.9822],
        "distance": 12000,
        "ascent": 600,
        "candidates": 3
      }
    }
  }'
```

**TypeScript**

```typescript
const suggested = await mountaya.data.suggestions(
  {
    activity: "HIKING_AND_TRAIL",
    start: [6.8712, 45.9231],
    end: [6.9271, 45.9822],
    distance: 12000,
    ascent: 600,
    candidates: 3,
  },
  { select: { routes: { seed: true, distance: true, duration: true, summary: true } } },
);

for (const route of suggested.routes) {
  console.log(route.seed, route.summary);
}
```

**Python**

```python
query = """
query Suggestions($input: SuggestionsInput!) {
  suggestions(input: $input) { routes { seed distance duration summary } }
}
"""

result = requests.post(
    "https://data.mountaya.com/graphql",
    headers={
        "X-API-Key": os.environ["MOUNTAYA_PUBLISHABLE_KEY"],
        "X-Session-Token": session["token"],
    },
    json={
        "query": query,
        "variables": {
            "input": {
                "activity": "HIKING_AND_TRAIL",
                "start": [6.8712, 45.9231],
                "end": [6.9271, 45.9822],
                "distance": 12000,
                "ascent": 600,
                "candidates": 3,
            }
        },
    },
    timeout=30,
).json()

if "errors" in result:
    raise RuntimeError(result["errors"])
for route in result["data"]["suggestions"]["routes"]:
    print(route["seed"], route["summary"])
```

**Response**

```json
{
  "data": {
    "suggestions": {
      "routes": [
        {
          "seed": 1647174438,
          "distance": 11462.699479476818,
          "duration": 13465.759617296519,
          "summary": "11.5 km, ~3h44m, +599m / -379m elevation, 79% path, 8% track, 5% road."
        },
        {
          "seed": 967324718,
          "distance": 13064.673161567045,
          "duration": 15522.708185158344,
          "summary": "13.1 km, ~4h18m, +653m / -433m elevation, 81% path, 7% track, 4% road."
        },
        {
          "seed": 416961995,
          "distance": 12933.929808013665,
          "duration": 15299.575502044987,
          "summary": "12.9 km, ~4h15m, +668m / -448m elevation, 82% path, 5% street, 5% track."
        }
      ]
    }
  }
}
```

Candidates come back closest to your targets first. Send a `seed` back in `seeds.include` to get the same route again.

Leave out `end` for a loop back to `start`. A suggestion never crosses a tollway or an access-restricted way.

- `suggestions(input: SuggestionsInput!)` takes `activity`, `start`, `distance` and `candidates` (all required), plus `end`, `ascent`, `points`, `seeds` and `speed`. It returns `routes`, a list of `SuggestionRoute`: every `DirectionsRoute` field plus `seed`. It has no `avoidance` field and no `avoid` input.
- `start` and `end`: `[longitude, latitude]`, exactly two numbers in range, else `VALIDATION_FAILED` at `["input", "start"]` or `["input", "end"]`. Without `end` the route loops back to `start`.
- `distance`: target meters, greater than 0 and at most 100 km (100000), the routing engine's ceiling for a route and a loop. For a point-to-point route it must also be at least the straight-line distance from `start` to `end`. Either refusal is `VALIDATION_FAILED` at `["input", "distance"]`.
- `distance` is a target, not a promise. The reported `distance` is measured from each finished geometry and can differ from the target, loops especially. Rank on the returned value.
- `candidates`: 1 to 10. Each candidate uses a different seed and so a different shape. Fewer routes than `candidates` can come back with no error.
- `ascent`: target meters of gain, a finite number 0 or more (negative, NaN or Infinity is `VALIDATION_FAILED` at `["input", "ascent"]`). A positive target ranks fresh candidates by their distance and ascent gaps combined, and drops every fresh candidate whose ascent is more than 50% above or below it. A pinned seed is kept whatever its ascent.
- `points`: shaping points for a loop, 2 to 10, default 5. Higher values make rounder loops. Ignored for point-to-point routes.
- `seeds.include`: seeds to pin, returned first in the order given while each still routes without crossing a hazard. At most `candidates` of them, no repeats; otherwise `VALIDATION_FAILED` at `["input", "seeds", "include"]`. Remaining slots are filled with fresh candidates.
- `seeds.exclude`: at most 100 seeds to skip when generating fresh candidates (more is `VALIDATION_FAILED` at `["input", "seeds", "exclude"]`). A seed in both lists is `VALIDATION_FAILED` at `["input", "seeds"]`.
- Reproducing a seed also requires the same `start`, `end`, `distance` and `points`. The server does not check them: different inputs give a different route for the same seed.
- `speed`: as on `directions`, a finite km/h figure greater than 0 that rescales `duration` only.
- Order of `routes`: pinned seeds first, in the order given, then fresh candidates nearest the target distance (or nearest the distance and ascent targets combined when `ascent` is positive).
- Hazards: a candidate crossing a tollway or an access-restricted way is dropped, with no opt-out, so every candidate's `analysis.advisories` reports no hazard. For `SKI_TOURING`, `CROSS_COUNTRY_SKIING` and `SNOWSHOE_WALKING` the check reads the engine's route-level warning, which any access tag raises, so a candidate crossing a `PERMISSIVE`, `AGRICULTURAL` or `FORESTRY` way is dropped as well.
- When no hazard-free candidate can be generated, or no candidate can be routed at all, the request is `VALIDATION_FAILED` at `["input", "start"]`. A candidate that fails on Mountaya's side is asked for once more; when no candidate survives and one failed again, the request is `INTERNAL_ERROR`.
- When fewer candidates survive because one failed on Mountaya's side twice (or a pinned seed failed twice), the field keeps the survivors and carries an `INTERNAL_ERROR` entry in `errors`; the request is recorded as a failure (5xx) and counts toward neither the monthly allowance nor an invoice.

## Isochrones

Map the ground you can reach from a point within a time or a distance. This asks for 30 and 60 minutes on foot from Chamonix.

**cURL**

```bash
curl https://data.mountaya.com/graphql \
  -H "X-API-Key: $MOUNTAYA_PUBLISHABLE_KEY" \
  -H "X-Session-Token: $MOUNTAYA_DATA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "query Isochrones($input: IsochronesInput!) { isochrones(input: $input) { isochrones { value area reachFactor } } }",
    "variables": {
      "input": {
        "activity": "HIKING_AND_TRAIL",
        "locations": [[6.8712, 45.9231]],
        "range": [1800, 3600],
        "rangeType": "TIME"
      }
    }
  }'
```

**TypeScript**

```typescript
const { isochrones } = await mountaya.data.isochrones(
  {
    activity: "HIKING_AND_TRAIL",
    locations: [[6.8712, 45.9231]],
    range: [1800, 3600],
    rangeType: "TIME",
  },
  { select: { isochrones: { value: true, area: true, reachFactor: true } } },
);

for (const isochrone of isochrones) {
  console.log(isochrone.value, isochrone.area);
}
```

**Python**

```python
query = """
query Isochrones($input: IsochronesInput!) {
  isochrones(input: $input) { isochrones { value area reachFactor } }
}
"""

result = requests.post(
    "https://data.mountaya.com/graphql",
    headers={
        "X-API-Key": os.environ["MOUNTAYA_PUBLISHABLE_KEY"],
        "X-Session-Token": session["token"],
    },
    json={
        "query": query,
        "variables": {
            "input": {
                "activity": "HIKING_AND_TRAIL",
                "locations": [[6.8712, 45.9231]],
                "range": [1800, 3600],
                "rangeType": "TIME",
            }
        },
    },
    timeout=30,
).json()

if "errors" in result:
    raise RuntimeError(result["errors"])
for isochrone in result["data"]["isochrones"]["isochrones"]:
    print(isochrone["value"], isochrone["area"])
```

**Response**

```json
{
  "data": {
    "isochrones": {
      "isochrones": [
        {
          "value": 1800,
          "area": 3.63273032e+06,
          "reachFactor": 0.2891
        },
        {
          "value": 3600,
          "area": 9.12239342e+06,
          "reachFactor": 0.1815
        }
      ]
    }
  }
}
```

Each range value returns one polygon: select `geometry` to draw it. `area` is in square meters. A low `reachFactor` means the trails are hemmed in, as in a valley.

- `isochrones(input: IsochronesInput!)` takes `activity`, `locations`, `range` and `rangeType` (all required), plus `speed`.
- `locations`: one or two `[longitude, latitude]` pairs; none or more than two is `VALIDATION_FAILED` at `["input", "locations"]`. Each is placed on the activity's network as a `directions` waypoint is (within 400 m for most activities, on the ways the activity routes on); a location no such way lies near is `VALIDATION_FAILED` at `["input", "locations", i]`.
- `range`: one to six values (otherwise `VALIDATION_FAILED` at `["input", "range"]`), each greater than 0 and at most 7,200 seconds for `TIME` or 25,000 meters for `DISTANCE` (otherwise `VALIDATION_FAILED` at `["input", "range", i]`). Several values give concentric polygons.
- A `TIME` budget is measured with the routing engine's own travel-time model, not the terrain-aware model behind `duration` on `directions`, `suggestions` and `analyzeGeometry`. An isochrone's edge and a route's duration are not interchangeable.
- `speed`: km/h, a finite number greater than 0, meaningful only with `TIME`; pairing it with `DISTANCE` is `VALIDATION_FAILED` at `["input", "speed"]`. The time budget is stretched by the ratio of `speed` to the engine's own pace for the activity: 5 km/h on foot and on skis, 20 km/h for `ROAD_CYCLING`. The stretched budget is held to 7,200 seconds, so a speed that takes any range value past it is `VALIDATION_FAILED` at `["input", "speed"]`. At 10 km/h on foot, every range value must be at most 3,600 seconds.
- Once the input's bounds pass and each location is placed, any failure of the routing engine is `INTERNAL_ERROR`.
- `isochrones`: one `Isochrone` per location and range value, in the order the engine returns them. Read each one's `value` rather than relying on its position.
- `Isochrone.value` echoes the range value (seconds or meters). `area` is square meters, null when the provider does not report it. `reachFactor` is the share of the theoretical circle (the same budget with no network or terrain in the way) that the polygon covers, 0 to 1, null when not reported. `center` is `[longitude, latitude]` forwarded verbatim from the provider, null when it reports none, never reconstructed from the input. `geometry` is the GeoJSON polygon.

## Matrix

Compare travel times and distances between many places at once. This grid links Chamonix, Argentière, and Les Houches.

**cURL**

```bash
curl https://data.mountaya.com/graphql \
  -H "X-API-Key: $MOUNTAYA_PUBLISHABLE_KEY" \
  -H "X-Session-Token: $MOUNTAYA_DATA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "query Matrix($input: MatrixInput!) { matrix(input: $input) { durations distances } }",
    "variables": {
      "input": {
        "activity": "HIKING_AND_TRAIL",
        "locations": [[6.8712, 45.9231], [6.9271, 45.9822], [6.7991, 45.8915]],
        "metrics": ["DURATION", "DISTANCE"]
      }
    }
  }'
```

**TypeScript**

```typescript
const grid = await mountaya.data.matrix(
  {
    activity: "HIKING_AND_TRAIL",
    locations: [
      [6.8712, 45.9231],
      [6.9271, 45.9822],
      [6.7991, 45.8915],
    ],
    metrics: ["DURATION", "DISTANCE"],
  },
  { select: { durations: true, distances: true } },
);

console.log(grid.durations?.[0]?.[1], grid.distances?.[0]?.[1]);
```

**Python**

```python
query = """
query Matrix($input: MatrixInput!) {
  matrix(input: $input) { durations distances }
}
"""

result = requests.post(
    "https://data.mountaya.com/graphql",
    headers={
        "X-API-Key": os.environ["MOUNTAYA_PUBLISHABLE_KEY"],
        "X-Session-Token": session["token"],
    },
    json={
        "query": query,
        "variables": {
            "input": {
                "activity": "HIKING_AND_TRAIL",
                "locations": [[6.8712, 45.9231], [6.9271, 45.9822], [6.7991, 45.8915]],
                "metrics": ["DURATION", "DISTANCE"],
            }
        },
    },
    timeout=30,
).json()

if "errors" in result:
    raise RuntimeError(result["errors"])
matrix = result["data"]["matrix"]
print(matrix["durations"][0][1], matrix["distances"][0][1])
```

**Response**

```json
{
  "data": {
    "matrix": {
      "durations": [
        [0, 6481.25, 5564.66],
        [6481.25, 0, 11977.68],
        [5564.66, 11977.68, 0]
      ],
      "distances": [
        [0, 9001.81, 7728.75],
        [9001.81, 0, 16635.78],
        [7728.75, 16635.78, 0]
      ]
    }
  }
}
```

Row `i`, column `j` is the trip from location `i` to location `j`. A `null` cell has no route.

> **Matrix durations are not hiking times**
>
> Chamonix to Argentière takes 6,481 seconds here (1h48) but 9,631 seconds with `directions` (2h40). The matrix uses the routing engine's own travel times, while `directions` and `suggestions` follow the terrain. Show hikers the `directions` duration.

- `matrix(input: MatrixInput!)` takes `activity`, `locations` and `metrics` (required), plus `sources` and `destinations`.
- `locations`: 2 to 50 `[longitude, latitude]` pairs (otherwise `VALIDATION_FAILED` at `["input", "locations"]`); each exactly two numbers in range (otherwise `["input", "locations", i]`). No two locations may lie more than 20 km apart in a straight line; a matrix with such a pair is `VALIDATION_FAILED` at `["input", "locations"]`.
- `sources` and `destinations`: index lists into `locations`, each at most 50 entries (otherwise `VALIDATION_FAILED` at `["input", "sources"]` or `["input", "destinations"]`). An index that names no location is `VALIDATION_FAILED` at `["input", "sources", i]` or `["input", "destinations", i]`. A repeated index is accepted. Both default to every location.
- `metrics`: `DURATION`, `DISTANCE`, or both; an empty list is `VALIDATION_FAILED` at `["input", "metrics"]`. A grid you did not request is absent (null).
- `durations` (seconds) and `distances` (meters) are one row per source and one column per destination. They are the only sparse lists in the schema: an inner `null` marks an unreachable pair. Check every cell.
- Matrix durations are the routing engine's own estimates. They take no `speed` and do not use the terrain-aware model behind `duration` on `directions`, `suggestions` and `analyzeGeometry`, so they are not comparable with those durations. Measured: Chamonix to Argentière on foot is 6481.25 s in the matrix and 9631.0 s from `directions`.
- Matrix costs are the engine's over its whole network: unlike `directions`, they do not leave out ways the activity avoids, so a cost may cross a ferry, a ford or steps. Use `directions` for a route exact to the activity.
- `distances` are the engine's own figures, with no geometry to measure them against, so they differ slightly from a `directions` distance (9001.81 m against 9005.15 m for the same pair).
- A location the engine cannot place on the network answers its pairs null rather than failing, as does a location on ways no other location connects to (an enclosed site); pairs between two locations on the same enclosed site are answered.
- A matrix too large for the engine to search at once is computed one source at a time and answered exactly as the whole matrix, recorded as one request, in a few seconds more. Any engine failure within these bounds is `INTERNAL_ERROR`.

## Activities

Every query takes an `activity`, which picks the ways it routes on and its default pace.

| Activity | API value | Wire form | Directions |
| --- | --- | --- | --- |
| Hiking and trail running | `HIKING_AND_TRAIL` | `hiking-and-trail` | Yes |
| Professional trail | `PROFESSIONAL_TRAIL` | `professional-trail` | Yes, off-network |
| Running | `RUNNING` | `running` | Yes |
| Road cycling | `ROAD_CYCLING` | `road-cycling` | Yes |
| Gravel biking | `GRAVEL_BIKE` | `gravel-bike` | Unavailable |
| Mountain biking | `MOUNTAIN_BIKE` | `mountain-bike` | Unavailable |
| Backcountry skiing | `BACKCOUNTRY_SKIING` | `backcountry-skiing` | Freehand line only |
| Ski touring | `SKI_TOURING` | `ski-touring` | Yes, off-network |
| Cross-country skiing | `CROSS_COUNTRY_SKIING` | `cross-country-skiing` | Yes |
| Snowshoe walking | `SNOWSHOE_WALKING` | `snowshoe-walking` | Yes |

Each routed activity uses a profile tuned to its terrain and movement style. Most activities support turn-by-turn routing, road cycling among them. Backcountry skiing is freehand-line only: no query routes it. Gravel biking and mountain biking are unavailable: the activity catalog does not list them, and every query refuses them, `analyzeGeometry` included. The GraphQL `ActivitySlug` enum uses the uppercase value; the Map Studio and Tile APIs use the kebab-case wire form, the same value lowercased with each underscore turned into a hyphen.

How activities route:

- **Preference.** Most activities favor pleasant, terrain-appropriate ways. Running and road cycling favor the fastest way. Professional trail takes the most-direct line.
- **Waypoint snapping.** A waypoint must lie within a snapping distance of a routable way, or the query is rejected. Most activities use 400 m. Snowshoe walking relaxes it to a few kilometers for off-trail points. Ski touring and professional trail remove the limit, so routes can start or end far off-network.
- **Default speed.** Around 4.5 km/h hiking, 8 km/h professional trail, 25 km/h road cycling, each on LEVEL ground. Override it per request with `speed`.
- **Duration is computed over the terrain, not over the distance.** From that flat pace, the model charges each stretch for its grade, its surface and its trail difficulty. A climb is slower, a descent is faster, and chunky gravel costs a road cyclist far more than a hiker. Read the per-stretch result on `analysis.speedInfo`: integrating it over the geometry reproduces `duration` exactly.
- `BACKCOUNTRY_SKIING` has no routing profile (freehand only), and `GRAVEL_BIKE` and `MOUNTAIN_BIKE` are unavailable. All three are `VALIDATION_FAILED` at `["input", "activity"]` on `directions`, `suggestions`, `isochrones` and `matrix`.
- Road cycling routes on the paved network, with analysis.
- Units: coordinates are `[longitude, latitude]` in WGS 84, distances in meters, durations in seconds, elevations in meters above sea level, gradients in degrees. `speed` alone is in km/h, so `distance / speed` is off by a factor of 3.6: read `duration` instead.

## Next steps

- [Places](https://docs.mountaya.com/en/apis/data/places.md): Geocode places, list points of interest, and search your own content.
- [Analysis](https://docs.mountaya.com/en/apis/data/analysis.md): Classify and time a line you already have.
