Route Planner
No token needed Runs nightly against live ESICalculates the shortest route between two solar systems and looks up the name of each system along the way.
The route endpoint uses POST with an optional body for preferences, avoid lists, and custom connections (e.g. jump bridges).
Calls: route.getRoute · universe.getSystemById
Run it
bash
git clone https://github.com/lgriffin/ESI.ts.git && cd ESI.ts
npm ci
npm run example:routeexamples/route-planner.ts on GitHub. The imports below are written as a consumer of the package writes them; the file in the repository imports from ../src.
Source
ts
import { EsiClient } from '@lgriffin/esi.ts';
import { createConsoleLogger } from '@lgriffin/esi.ts';
// The program's own output. The client logs through the same console sink
// at ESI_LOG_LEVEL (default warn), so its diagnostics stay out of the way.
const log = createConsoleLogger('info');
const esiLog = createConsoleLogger();
const JITA_SYSTEM_ID = 30000142;
const AMARR_SYSTEM_ID = 30002187;
async function main() {
const client = new EsiClient({ logger: esiLog });
try {
log.info(`Route: Jita -> Amarr\n`);
// Basic route (shortest path, default options)
const route = await client.route.getRoute(JITA_SYSTEM_ID, AMARR_SYSTEM_ID);
log.info(`Total jumps: ${route.length - 1}\n`);
// Resolve system names by looking up each system
const systems = await Promise.all(
route.map((id: number) => client.universe.getSystemById(id)),
);
log.info('Route (Shortest)');
log.info('-'.repeat(40));
for (let i = 0; i < route.length; i++) {
const sys = systems[i]!;
const name = sys.name ?? `System ${route[i]}`;
const sec = sys.security_status?.toFixed(2) ?? '?';
const prefix =
i === 0
? 'START'
: i === route.length - 1
? 'END '
: ` ${String(i).padStart(3)}`;
log.info(` ${prefix} ${name} (${sec})`);
}
// Safer route
log.info('\nRoute (Safer)');
log.info('-'.repeat(40));
const saferRoute = await client.route.getRoute(
JITA_SYSTEM_ID,
AMARR_SYSTEM_ID,
{
preference: 'Safer',
},
);
log.info(` ${saferRoute.length - 1} jumps`);
} catch (err) {
log.error('Request failed', { error: err });
process.exit(1);
} finally {
await client.shutdown();
}
}
main();