Getting Started
GetJar is a gaming platform API for user management, virtual currency, and leaderboards.
Quick Start
1. Load the SDK
IIFE (browser script tag) — pin a version in production:
html
<!-- Production: pin to a specific version -->
<script src="https://cdn.getjar.com/v3.0.0/getjar-iap-sdk.min.js"></script>
<!-- Development only: latest (5-minute CDN TTL) -->
<script src="https://cdn.getjar.com/latest/getjar-iap-sdk.min.js"></script>ESM (bundler or modern browser):
javascript
import { Configuration, Leaderboard, UserGame } from 'https://cdn.getjar.com/v3.0.0/getjar-iap-sdk.esm.js';2. Get Your API Key
- Sign in at https://dev.getjar.com
- Copy your API key from the dashboard
3. Read the Player's userId
When GetJar embeds your game, the player's userId is passed as a URL query parameter. Read it at startup and pass it to Configuration.userId so the SDK includes it as the x-user-id header on every request. See the PostMessage Integration section for how to use it in coin operations.
javascript
const userId = new URLSearchParams(window.location.search).get('userId');4. Initialize the SDK
Create a Configuration instance, then pass it to each SDK class. IIFE global is GetjarIAP:
javascript
// After script loads, GetjarIAP is available globally
const cfg = new GetjarIAP.Configuration({
basePath: 'https://sdk-new.getjar.com',
apiKey: 'your-api-key',
userId // from step 3
});
const leaderboardClient = new GetjarIAP.Leaderboard(cfg);
const userGameClient = new GetjarIAP.UserGame(cfg);ESM / bundler:
javascript
import { Configuration, Leaderboard, UserGame } from 'https://cdn.getjar.com/v3.0.0/getjar-iap-sdk.esm.js';
const cfg = new Configuration({
basePath: 'https://sdk-new.getjar.com',
apiKey: 'your-api-key',
userId // from step 3
});
const leaderboardClient = new Leaderboard(cfg);
const userGameClient = new UserGame(cfg);Features
- Leaderboard SDK — Per-game competitive rankings
- User Game SDK — Track and update player progress
- PostMessage Integration — Coin operations (give, spend, balance) via iframe messaging