Compute a route with Thinwrap (TypeScript)

Compute a multi-waypoint route via the Thinwrap unified Routing facade in TypeScript — same call shape for Mapbox, Google, HERE, ESRI, TomTom, and OSRM.

1. Install

npm install @thinwrap/location

2. Send the call

import { Routing } from '@thinwrap/location';

const routing = new Routing('mapbox', {
  accessToken: process.env.MAPBOX_TOKEN!,
});

const result = await routing.route({
  waypoints: [
    { lat: 37.7749, lng: -122.4194 }, // San Francisco
    { lat: 37.3382, lng: -121.8863 }, // San Jose
  ],
  travelMode: 'driving',
});

// Distances normalized to meters, durations to seconds.
console.log(result.totalDistanceMeters, result.totalDurationSeconds);
console.log('polyline:', result.polyline); // Google-precision-5 encoded

Same code works for all supported providers — just change the provider ID.