TypeScript SDK¶
The official TypeScript SDK provides a typed API client and WebSocket helpers for integrating with the Multiverse Echoes engine.
Installation¶
npm install @echolabs/multiverse-echoes
Quick Start¶
import { createClient } from '@echolabs/multiverse-echoes';
const client = createClient({
baseUrl: 'https://api.echolabsme.com',
});
await client.login({ email: 'you@example.com', password: 'secret' });
const echoes = await client.echoes.list();
console.log(`You have ${echoes.length} Echo(es)`);
Authentication¶
JWT (Email + Password)¶
const client = createClient({ baseUrl: 'https://api.echolabsme.com' });
await client.login({ email: 'you@example.com', password: 'secret' });
Tokens refresh automatically on 401. To restore from storage:
client.setTokens(storedAccessToken, storedRefreshToken);
API Key¶
const client = createClient({
baseUrl: 'https://api.echolabsme.com',
apiKey: 'me_live_abc123...',
});
No login needed — all requests include the API key header.
Available Methods¶
| Namespace | Methods |
|---|---|
client.echoes |
list, get, create, updatePersona, delete, hibernate, wake, travel, relationships, influence, useInfluence, memories, rename |
client.shards |
list, get, echoes |
client.feeds |
personal, social, shard |
client.notifications |
list, markRead |
client.channels |
list, get, messages, sendMessage |
client.conversations |
create, messages, sendMessage, saveAsDiary |
client.search |
echoes, diary, events, shards, messages |
client.oracle |
ask |
client.exports |
request, status |
client.waitlist |
signup, position, count |
Error Handling¶
All API errors throw ApiRequestError:
import { ApiRequestError } from '@echolabs/multiverse-echoes';
try {
await client.echoes.create(data);
} catch (err) {
if (err instanceof ApiRequestError) {
console.log(err.status); // 400
console.log(err.code); // 'WHAT_IF_LOCKED'
console.log(err.message); // 'The what-if prompt cannot be modified'
}
}
WebSocket Subscriptions¶
See the WebSocket Events reference for real-time event streaming.
import { subscribeToEcho } from '@echolabs/multiverse-echoes';
const ws = subscribeToEcho('wss://api.echolabsme.com', echoId, accessToken, {
onEvent(event) {
console.log('Event:', event.payload.type);
},
});
TypeScript Types¶
All API response types are exported from the package:
import type { EchoResponse, Shard, FeedItem, WorldEvent } from '@echolabs/multiverse-echoes';
See the full type definitions in the API Reference.