Skip to content

Universe Information ​

No token needed Runs nightly against live ESI

Fetches solar system, station, and constellation details. Demonstrates navigating the universe data hierarchy.

Calls: universe.getSystemById · universe.getStationById · universe.getConstellationById · universe.getRegionById · universe.getStructures

Run it ​

bash
git clone https://github.com/lgriffin/ESI.ts.git && cd ESI.ts
npm ci
npm run example:universe

examples/universe-info.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 JITA_TRADE_HUB_STATION_ID = 60003760;

async function main() {
  const client = new EsiClient({ logger: esiLog });

  try {
    log.info('Universe Data Lookup\n');

    const [system, station] = await Promise.all([
      client.universe.getSystemById(JITA_SYSTEM_ID),
      client.universe.getStationById(JITA_TRADE_HUB_STATION_ID),
    ]);

    log.info('Solar System: Jita');
    log.info('-'.repeat(40));
    log.info(`  System ID:        ${system.system_id}`);
    log.info(`  Name:             ${system.name}`);
    log.info(`  Security Status:  ${system.security_status?.toFixed(4)}`);
    log.info(`  Constellation ID: ${system.constellation_id}`);
    log.info(`  Planets:          ${system.planets?.length ?? 0}`);
    log.info(`  Stargates:        ${system.stargates?.length ?? 0}`);
    log.info(`  Stations:         ${system.stations?.length ?? 0}`);

    // Look up the constellation
    const constellation = await client.universe.getConstellationById(
      system.constellation_id,
    );

    log.info(`\nConstellation: ${constellation.name}`);
    log.info('-'.repeat(40));
    log.info(`  Constellation ID: ${constellation.constellation_id}`);
    log.info(`  Region ID:        ${constellation.region_id}`);
    log.info(`  Systems:          ${constellation.systems?.length ?? 0}`);

    // Look up the region
    const region = await client.universe.getRegionById(constellation.region_id);

    log.info(`\nRegion: ${region.name}`);
    log.info('-'.repeat(40));
    log.info(`  Region ID:        ${region.region_id}`);
    log.info(`  Constellations:   ${region.constellations?.length ?? 0}`);

    log.info(`\nStation: ${station.name}`);
    log.info('-'.repeat(40));
    log.info(`  Station ID:       ${station.station_id}`);
    log.info(`  Owner (Corp ID):  ${station.owner}`);
    log.info(`  Type ID:          ${station.type_id}`);

    const structureIds = await client.universe.getStructures();
    log.info(`\nPublic Upwell structures: ${structureIds.length}`);
  } catch (err) {
    log.error('Request failed', { error: err });
    process.exit(1);
  } finally {
    await client.shutdown();
  }
}

main();

Released under the GPL-3.0-or-later license.