@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:
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
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:
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)
readonlyadmin:AdminResource
Defined in: packages/ts-sdk/src/client.ts:119
Simulator administration APIs.
cards
Example:
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
])
readonlycards:CardsResource
Defined in: packages/ts-sdk/src/client.ts:123
Card metadata APIs.
limitedEvents
Example:
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,
})
readonlylimitedEvents:LimitedEventsResource
Defined in: packages/ts-sdk/src/client.ts:127
Limited Event APIs.
lobbies
Example:
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)
readonlylobbies:LobbiesResource
Defined in: packages/ts-sdk/src/client.ts:131
Pre-match multiplayer lobby APIs.
matches
Example:
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,
})
readonlymatches:MatchesResource
Defined in: packages/ts-sdk/src/client.ts:139
Match lifecycle APIs.
matchHistory
Example:
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)
readonlymatchHistory:MatchHistoryResource
Defined in: packages/ts-sdk/src/client.ts:135
Server-owned simulator history APIs.
session
Example:
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',
})
readonlysession:SessionResource
Defined in: packages/ts-sdk/src/client.ts:143
High-level live match session APIs.
system
Example:
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()
readonlysystem:SystemResource
Defined in: packages/ts-sdk/src/client.ts:147
System APIs.
tournamentRooms
Example:
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)
readonlytournamentRooms:TournamentRoomsResource
Defined in: packages/ts-sdk/src/client.ts:151
Tournament room APIs for sealed/draft events and duel tables.
