archipelago-client
v1.0.1
Published
TypeScript client library for the Archipelago multi-game randomizer platform
Maintainers
Readme
archipelago
TypeScript client library for the Archipelago multi-game randomizer platform. Provides a dual client — WebSocket for real-time events and WebHost for REST API access — with zero production dependencies.
Installation
npm install archipelago-clientRequires Node.js 24+ (uses built-in WebSocket and fetch).
Quick Start
import { ArchipelagoClient, Game } from 'archipelago-client';
const client = new ArchipelagoClient({ host: 'archipelago.gg', port: 38281 });
client.on('ItemSend', (item) => {
console.log(`${item.player.name} received ${item.item.name}`);
});
await client.connect();
await client.authenticate('MyBot', new Game('Hollow Knight'), 'slot');Examples
| Example | Description |
|---------|-------------|
| WebSocket events | Connect, authenticate, listen to ItemSend and other events |
| DeathLink | Send and receive DeathLink events via bounce packets |
| WebHost REST | Query room_status, tracker, and datapackage endpoints |
Run any example with npx tsx examples/<name>.ts (server configuration at the top of each file).
Cache: The WebSocket example demonstrates optional client-side caching (
useCache: true) to persist game datapackages between sessions.
Testing
The project uses archipelago.gg for E2E testing. Test infrastructure lives in the sibling test-archi/ directory.
Setting Up a Test Room
cd ../test-archi
npm run generate # Generate a seed on archipelago.gg
npm run host # Host the game serverThis generates a test seed on archipelago.gg and saves room information to test-archi/.room-info.json.
Running Tests
npm test # Run the full test suite (Vitest)
npm run test:e2e # Run E2E tests (requires a hosted room on archipelago.gg)Note: E2E tests require a room to be hosted on archipelago.gg. Set one up with
cd ../test-archi && npm run generate && npm run host.
For detailed setup, see the Test Infrastructure Documentation.
API Overview
| Class | Description | Events |
|-------|-------------|--------|
| ArchipelagoClient | WebSocket client for real-time multiworld communication | connect, disconnect, error, ItemSend, HintUpdate, Bounce, RoomUpdate, … |
| WebHostClient | REST client for the Archipelago WebHost API | — |
| EventManager | Generic typed event emitter | Extensible |
| PrintJSONManager | High-level PrintJSON event router | 16 PrintJSONType events |
| Game | Game identifier (extends Tagged) | — |
| Player | Network player representation | — |
| Item | Network item representation | — |
| Hint | Hint data structure | — |
Error Classes
| Class | Description |
|-------|-------------|
| ArchipelagoError | Base error class |
| ArchipelagoConnectionError | WebSocket connection failures |
| ArchipelagoAuthError | Authentication errors |
| ArchipelagoPacketError | Packet parsing errors |
| ArchipelagoWebHostError | Base WebHost error |
| ArchipelagoWebHostNotFoundError | 404 responses |
| ArchipelagoWebHostRateLimitError | 429 rate limit responses |
| ArchipelagoWebHostServerError | 5xx server errors |
For the complete API reference, see the TypeDoc documentation.
Contribuer
| Command | Description |
|---------|-------------|
| npm run build | Compile TypeScript to dist/ |
| npm test | Run the test suite (Vitest) |
| npm run lint | Lint with Biome |
| npm run docs | Generate TypeDoc HTML in docs/ |
Conventions
- Commits : Conventional Commits (enforced by commitlint + husky).
- Suffixes de fichiers :
.class.ts,.enum.ts,.interface.ts,.type.tspour une lisibilité immédiate. - Zéro dépendance production : la library ne dépend que des APIs natives Node.js 23+ (
WebSocket,fetch,node:fs,node:crypto).
