Skip to content

TypeScript SDK

The official TypeScript SDK provides typed methods for all API endpoints.

View source on GitHub

Terminal window
npm install @weplaytestgames/sdk
import { WPGClient } from '@weplaytestgames/sdk';
const client = new WPGClient({
apiKey: process.env.WPG_API_KEY!,
});
// List your games
const games = await client.games.list();
// Create a playtest
const playtest = await client.playtests.create('game_abc123', {
visibility: 'private',
quantity: 3,
instructions: 'Focus on the tutorial',
});
// Check credit balance
const balance = await client.billing.getBalance();
console.log(`Balance: $${balance.balanceCents / 100}`);

Pass your API key when creating the client:

const client = new WPGClient({
apiKey: 'wpg_sk_...',
// Optional: custom base URL for testing
baseUrl: 'https://app.weplaytestgames.com/api/v1',
});

The SDK throws typed errors:

import { WPGClient, WPGError } from '@weplaytestgames/sdk';
try {
await client.playtests.create('game_abc', { visibility: 'private', quantity: 1 });
} catch (error) {
if (error instanceof WPGError) {
console.log(error.code); // 'PAYMENT_REQUIRED'
console.log(error.message); // 'Insufficient credit'
console.log(error.status); // 402
}
}

List methods return async iterables:

// Iterate all games
for await (const game of client.games.list()) {
console.log(game.name);
}
// Or get a single page
const page = await client.games.list({ limit: 10 });
console.log(page.data);
console.log(page.meta.hasMore);
NamespaceMethods
client.authme(), updateProfile(), categories(), devices(), platforms()
client.gameslist(), create(), get(), update()
client.playtestscreate(), list(), get(), update(), slots()
client.slotsget(), accept(), reject(), downloadUrl(), transcript()
client.submissionslist()
client.playtesterprofile(), updateProfile(), stats(), openPlaytests(), myPlaytests()
client.playtester.slotsget(), reserve(), release(), submit(), dispute()
client.billinggetBalance(), payments(), purchaseCredit()
client.payoutslist(), quote(), request(), cancel()
client.chatcontacts(), conversation(), sendMessage(), unreadCount()
client.notificationslist(), markAllRead()
client.webhookslist(), create(), update(), delete(), deliveries(), test(), enable(), rotateSecret()