Quickstart

Create a game, register currencies, and grant your first gold — all in under 5 minutes.

1. Install the SDK

bash
npm install @gameplaygen/sdk

2. Initialize & Create a Game

Every economy lives inside a game. Creating one gives you an API key.

typescript
import { GameplayGen } from '@gameplaygen/sdk';

// Initialize the client
const gg = new GameplayGen({
  apiKey: 'gp_your_api_key',
  baseUrl: 'https://gameplaygen.com',
});

// Create a game (one-time setup)
await gg.economy.createGame('my-awesome-game');

Save the API key — you can't retrieve it later.

3. Define Currencies & Items

typescript
// Define currencies and items
await gg.economy.defineCurrency('gold', 'Gold', '💰');
await gg.economy.defineItem('iron-sword', 'Iron Sword', {
  prices: [{ currencyId: 'gold', amount: 50 }],
});

4. Player Operations

Players are identified by your own IDs. The SDK auto-creates wallets.

typescript
// Player operations
await gg.economy.createPlayer('player_42');
await gg.economy.grant('player_42', 'gold', 100, 'welcome_bonus');
await gg.economy.purchase('player_42', 'iron-sword');

const balance = await gg.economy.getBalance('player_42');
// → [{ currencyId: 'gold', balance: 50 }]

const inventory = await gg.economy.getInventory('player_42');
// → [{ itemId: 'iron-sword', quantity: 1 }]

5. Check the Dashboard

Every transaction is tracked in real time. Visit your game's economy dashboard to see live metrics, wealth distribution, and the AI Advisor.

typescript
const stats = await gg.economy.getStats();

Next Steps

SDK Reference → — every method with types and examples

HTTP API Reference → — all endpoints with curl examples

Integration Patterns → — loot drops, trading, taxation, and more

Watch it live → — see the engine powering 1,000 AI agents