client.routes manages an athlete's saved routes and compares how similar two routes are to each other. All routes are athlete-scoped.
| Method | What it does |
|---|---|
| RouteService.list | List all routes for an athlete |
| RouteService.get | Get a specific route |
| RouteService.update | Update a route |
| RouteService.getSimilarity | How similar is this route to another? |
List the athlete's routes, then compare the first route to itself. Comparing a route to itself only proves the route is reachable through RouteService.getSimilarity; a real comparison needs a second route id.
const client = new IntervalsClient({ apiKey });
const routes = await client.routes.list();
console.log(`${routes.length} routes`);
for (const route of routes) {
console.log(`- ${route.name ?? route.route_id}: ${route.distance ?? 0} m`);
}
const first = routes[0];
if (!first || first.route_id === undefined) {
console.log('No routes found');
} else {
// Comparing a route to itself does not measure anything useful; it only proves the
// route is reachable through getSimilarity. A real comparison needs a second route id.
const similarity = await client.routes.getSimilarity(first.route_id, first.route_id);
console.log(`Route ${first.route_id} is reachable via getSimilarity (self-similarity=${similarity.similarity ?? 'n/a'})`);
}