Lv.1 Arcade Rookie 👑 VIP PASS
CGA Studio WebGames Platform · API v1 & SDK v3.0

One Economy & Ads API for Every CGA Web Game

Drop one script tag (or our Unity WebGL plugin) into any browser game to share CGA Coins, VIP Ad-Free Passes, Cross-Game Boosters, Stripe Checkout, and Google H5 Rewarded & Interstitial Ads (ca-pub-7657243293501758).

📄 OpenAPI 3.1 JSON ⚡ cga-portal.js (v3.0) 🎮 Unity CGAPortal.jslib 💻 Unity CGAPortalBridge.cs

1. HTML5 / TypeScript / Vite Quickstart (1 Script Tag)

<script src="https://play.cgastudio.games/sdk/cga-portal.js"></script>
<script>
  // 1. Read shared CGA Coin balance & VIP Ad-Free status
  const wallet = await CGAPortal.getWallet();

  // 2. Award shared CGA Coins on level/quiz win (+50 bonus on 2nd game played today!)
  await CGAPortal.earnCoins("my-game-slug", 25, "Cleared Level 4", "lvl4:" + Date.now(), 40);

  // 3. Spend shared CGA Coins (auto-opens Stripe Shop if balance is low)
  await CGAPortal.spendCoins(50, "Extra 5 Moves", null, "my-game-slug");

  // 4. Play Google H5 Rewarded Video Ad (+40 CGA Coins credited server-side!)
  const ad = await CGAPortal.showRewardedAd({ gameSlug: "my-game-slug", placement: "free_life" });
  if (ad.ok) grantExtraLife();

  // 5. Play between-level Interstitial (auto-skipped for VIP Pass & 150s cooldown!)
  await CGAPortal.showInterstitial("level_complete");
</script>

2. Standardized REST Endpoints (https://play.cgastudio.games/api/v1)

Authenticated automatically via first-party .cgastudio.games cookie (credentials: "include") or header X-Wallet-Token: CGW-....

GET /api/v1/wallet — Fetch player ID, shared CGA Coin balance, VIP tier, Rank/XP, ads_config, & entitlements
GET /api/v1/catalog?game_slug=... — List Stripe coin/VIP packs and per-game armory items
POST /api/v1/earn — Body: { game_slug, amount, xp, reason, ref_id } (250/day cap + +50 Cross-Game Hopper bonus)
POST /api/v1/spend — Body: { game_slug, amount, reason, ref_id } (Atomic SQL guard; 402 INSUFFICIENT_COINS if low)
POST /api/v1/items/buy & /api/v1/items/consume — Queue & atomically claim cross-game boosters/lives
POST /api/v1/ads/reward — Body: { game_slug, placement, ad_network } (+40 CGA Coins, 45s cooldown, 8/day cap)
POST /api/v1/daily · /api/v1/checkout · /api/v1/restore — 7-day streak, Live Stripe Checkout, & cross-device sync

3. Unity WebGL C# Integration

// Drop CGAPortal.jslib into Assets/Plugins/WebGL/ and CGAPortalBridge.cs into Assets/Scripts/
CGAPortalBridge.Instance.EarnCoins("take-that", 25, "Stage Cleared");
CGAPortalBridge.Instance.SpendCoins("take-that", 50, "Extra 5 Moves");
CGAPortalBridge.Instance.ShowRewardedAd("take-that", "free_life");
CGAPortalBridge.Instance.ShowInterstitial("stage_complete"); // Auto-skipped if IsVipAdFree!