Skip to content

@my-swu/simulator-client


@my-swu/simulator-client / SimulatorClient

Interface: SimulatorClient ​

Defined in: packages/ts-sdk/src/client.ts:115

Public typed client used to call simulator HTTP and WebSocket APIs.

The client groups endpoints by workflow: system checks, card metadata, match lifecycle calls, Limited Events, and high-level match sessions.

Example:

ts
import { createSimulatorClient } from '@my-swu/simulator-client'

// Point this at the simulator HTTP origin for /health and /api routes.
const simulatorClient = createSimulatorClient({
  baseUrl: 'http://127.0.0.1:4000',
})

// System health verifies the client can reach the simulator.
const health = await simulatorClient.system.health()

console.log(health.status)

Example ​

ts
import { createSimulatorClient } from '@my-swu/simulator-client'

const simulatorClient = createSimulatorClient({
  baseUrl: 'http://127.0.0.1:4000',
})

const health = await simulatorClient.system.health()
const requestedCardMetadata = await simulatorClient.cards.get([46102])
console.log(health.status, requestedCardMetadata[0]?.title)

See ​

https://simulator-sdk.my-swu.com/guide/client-api

Properties ​

admin ​

Example:

ts
import { createSimulatorClient } from '@my-swu/simulator-client'

// Point this at the simulator HTTP origin for /health and /api routes.
const simulatorClient = createSimulatorClient({
  baseUrl: 'http://127.0.0.1:4000',
})

const { admin } = simulatorClient

console.log(admin)

readonly admin: AdminResource

Defined in: packages/ts-sdk/src/client.ts:119

Simulator administration APIs.


cards ​

Example:

ts
import { createSimulatorClient } from '@my-swu/simulator-client'

// Point this at the simulator HTTP origin for /health and /api routes.
const simulatorClient = createSimulatorClient({
  baseUrl: 'http://127.0.0.1:4000',
})

// Card resources read canonical card metadata.
const cardMetadata = await simulatorClient.cards.get([
  46102, // Leia Organa - Someone Who Loves You
  308, // Echo Base
])

readonly cards: CardsResource

Defined in: packages/ts-sdk/src/client.ts:123

Card metadata APIs.


limitedEvents ​

Example:

ts
import { createSimulatorClient } from '@my-swu/simulator-client'

// Point this at the simulator HTTP origin for /health and /api routes.
const simulatorClient = createSimulatorClient({
  baseUrl: 'http://127.0.0.1:4000',
})

// Limited Events generate draft or sealed pools before match creation.
const draftEventAccess = await simulatorClient.limitedEvents.create({
  kind: 'draft',
  draftRounds: [], // Chaos draft only; a plain draft repeats `setCode`.
  pickTimerEnabled: false,
  setCode: 'SOR',
  playerCount: 4,
})

readonly limitedEvents: LimitedEventsResource

Defined in: packages/ts-sdk/src/client.ts:127

Limited Event APIs.


lobbies ​

Example:

ts
import { createSimulatorClient } from '@my-swu/simulator-client'

// Point this at the simulator HTTP origin for /health and /api routes.
const simulatorClient = createSimulatorClient({
  baseUrl: 'http://127.0.0.1:4000',
})

const { lobbies } = simulatorClient

console.log(lobbies)

readonly lobbies: LobbiesResource

Defined in: packages/ts-sdk/src/client.ts:131

Pre-match multiplayer lobby APIs.


matches ​

Example:

ts
import { createSimulatorClient } from '@my-swu/simulator-client'

// Point this at the simulator HTTP origin for /health and /api routes.
const simulatorClient = createSimulatorClient({
  baseUrl: 'http://127.0.0.1:4000',
})

// Use card ids; the server validates deck legality.
const premierHostDeck = {
  leader: 46102, // Leia Organa - Someone Who Loves You
  leaders: [], // Twin Suns only; Premier uses the single `leader` above.
  base: 308, // Echo Base
  cards: Array.from({ length: 50 }, () => 45), // Alliance X-Wing
  sideboard: [],
}

// Match creation returns the host seat access object.

const hostAccess = await simulatorClient.matches.create({
  format: 'premier',
  // Twin Suns supports 2-4 players; every other format is exactly 2.
  playerCount: 2,
  hostName: 'Host',
  hostAuthenticated: false,
  historyIdentities: [],
  // One entry per AI-controlled seat; empty means a human opponent joins.
  aiOpponents: [],
  hostDeck: premierHostDeck,
})

readonly matches: MatchesResource

Defined in: packages/ts-sdk/src/client.ts:139

Match lifecycle APIs.


matchHistory ​

Example:

ts
import { createSimulatorClient } from '@my-swu/simulator-client'

// Point this at the simulator HTTP origin for /health and /api routes.
const simulatorClient = createSimulatorClient({
  baseUrl: 'http://127.0.0.1:4000',
})

const { matchHistory } = simulatorClient

console.log(matchHistory)

readonly matchHistory: MatchHistoryResource

Defined in: packages/ts-sdk/src/client.ts:135

Server-owned simulator history APIs.


session ​

Example:

ts
import { createSimulatorClient } from '@my-swu/simulator-client'

// Point this at the simulator HTTP origin for /health and /api routes.
const simulatorClient = createSimulatorClient({
  baseUrl: 'http://127.0.0.1:4000',
})

// Sessions own live socket state for one private seat.
const matchSession = simulatorClient.session.create({
  matchId: 'match_123',
  seatToken: 'seat_token_123',
})

readonly session: SessionResource

Defined in: packages/ts-sdk/src/client.ts:143

High-level live match session APIs.


system ​

Example:

ts
import { createSimulatorClient } from '@my-swu/simulator-client'

// Point this at the simulator HTTP origin for /health and /api routes.
const simulatorClient = createSimulatorClient({
  baseUrl: 'http://127.0.0.1:4000',
})

// System health verifies the server is reachable.
const health = await simulatorClient.system.health()

readonly system: SystemResource

Defined in: packages/ts-sdk/src/client.ts:147

System APIs.


tournamentRooms ​

Example:

ts
import { createSimulatorClient } from '@my-swu/simulator-client'

// Point this at the simulator HTTP origin for /health and /api routes.
const simulatorClient = createSimulatorClient({
  baseUrl: 'http://127.0.0.1:4000',
})

const { tournamentRooms } = simulatorClient

console.log(tournamentRooms)

readonly tournamentRooms: TournamentRoomsResource

Defined in: packages/ts-sdk/src/client.ts:151

Tournament room APIs for sealed/draft events and duel tables.

Released under the MIT License.