Skip to content

Guide

Migrate a Valhalla client to geolith routing (in development)

A Valhalla client pointed at geolith Routing.

Status · In development

In development, not deployed: there is no routing endpoint to call yet, on geolith.app or api.geolith.app, and no routing plan, price or key.

  • 6 min
  • Intermediate
  • Updated

By

You will build

A Valhalla client pointed at geolith Routing.

You need

A Valhalla client

Valhalla clientNew URL, kebab pathsgeolith routerValhalla JSON
Only the base URL and the paths change; request and response bodies stay Valhalla’s.

Status: routing is in development and not deployed. There is no hosted routing endpoint and no routing plan, price or key. This guide lists what changes so a client is ready when a router is.

The geolith router speaks Valhalla's API. A client written for Valhalla changes two things: the base URL and the paths, which are kebab-case.

Path mapping

Valhallageolith
/route/route
/isochrone/isochrone
/sources_to_targets/sources-to-targets
/trace_route/trace-route
/trace_attributes/trace-attributes

Only the kebab-case paths are served: /sources_to_targets does not answer.

Before and after

js
// Before: Valhalla.
const VALHALLA = 'https://valhalla.example.com';
const res = await fetch(`${VALHALLA}/sources_to_targets`, {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ sources, targets, costing: 'auto' }),
});
js
// After: a geolith router you run (ROUTER_HOST); the body is unchanged.
const ROUTER = 'https://ROUTER_HOST';
const res = await fetch(`${ROUTER}/sources-to-targets`, {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ sources, targets, costing: 'auto' }),
});

What stays the same

  • Request bodies: locations, sources, targets, shape, costing, contours, shape_match, date_time, units.
  • Response bodies: the trip object, sources_to_targets, the isochrone GeoJSON, and the trace results.
  • Error bodies: error_code, error, status_code and status, with the HTTP status of the same number.
  • Traffic: historical speeds in Valhalla's CSV format, used for requests with a date_time. See traffic and live data.

What to check

  • Costing: auto, pedestrian and bicycle only.
  • Spoken (verbal_*) instructions are in progress.
  • Accuracy per endpoint is on routing accuracy.

Keep going

Previous and next

Related

More guides like this

Questions

Quick answers