Skip to content

one-to-many v2 endpoint #1299

@e-kotov

Description

@e-kotov

Proposal: V2 one-to-many endpoint

This issue proposes a V2 endpoint (/api/v2/one-to-many) to improve consistency with other MOTIS endpoints and improve developer ergonomics.

Proposed Improvements

1. Align time units with one-to-all

Currently, one-to-many uses max in seconds, while one-to-all uses maxTravelTime in minutes (and all other endpoints also mostly use minutes). Also it just does not seem to make much sense to measure time in seconds for travel, and if precision is that important, using decimal minutes should work too.

Proposal: Adopt maxTravelTime (minutes) in V2. This standardizes the API surface and reduces unit-mismatch with other endpoints. Make it easier to understand what max refers to even without reading the API description.

2. Structured response object

The current response is a JSON array: [{"duration": 120}, ...].

Proposal: Wrap the response in a structured object to allow for metadata and future extensibility:

{
  "durations": [ ... ],
  "debugOutput": { ... }
}

This proposal together with the next one are the main reason for 'v2', as the format of the response would change significantly.

3. Add optional debug statistics

For performance profiling (distinguishing network vs. routing latency), client-side measurement is insufficient.

Proposal: Add an optional debug=true parameter.

  • Initial implementation: Return server-side timing statistics (e.g., routing: 45ms, parsing: 2ms) in the debugOutput field.
  • Future potential: The debugOutput structure provides a place to expose internal routing failure reasons (e.g. "unreachable" vs "disconnected graph") if the underlying osr library exposes them in the future. Because the debug data may contain more data than the useful response with durations and distances (e.g. if debug would contain info for each calculated/non-calculated route), it should be optional.

4. Improve default values

Proposal: Make the following parameters optional with sensible defaults:

  • arriveBy: false: The primary use case for one-to-many is computing isochrones/accessibility from a single origin to many destinations (forward search). Defaulting to false creates the "path of least resistance" for the most common task. The reverse operation is probably used less often anyway.
  • maxMatchingDistance: 25: one-to-all already has this default, so for consistency I would use it here too. (Even though the web ui uses a much larger 250).

5. Inline mode enum

Currently, mode references the global Mode schema, which includes unsupported modes (like PT).

Proposal: Inline enum: [WALK, BIKE, CAR] for V2. This creates a strict, self-documenting contract. Expanding this list later to include more modes is a non-breaking change. Substituting it later with 'Mode' schema if the endpoint some day supports the whole schema should not be an issue.

Also, I'n not sure if this endpoint should have

Summary of V2 Changes

Feature V1 (Current) V2 (Proposed)
Travel Time max (seconds) maxTravelTime (minutes)
Response format Array<Duration> Object { durations: ... }
Defaults arriveBy required Default false
Defaults maxMatchingDistance required Default 25
Debug Info Not available debug param & output
Modes Global Mode Inlined WALK, BIKE, CAR

P.S. Maybe I fundamentally misunderstand something about internals of MOTIS and its components, so maybe some of these suggestions may seem absurd or even counterproductive.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions