{"openapi":"3.1.0","info":{"title":"CGA Studio WebGames Economy & Ads API","version":"1.0.0","description":"Unified shared-currency wallet, cross-game booster entitlements, Google H5 Rewarded Ad rewards, and Stripe Billing API for all CGA Studio web games."},"servers":[{"url":"https://play.cgastudio.games/api/v1","description":"Production Edge API (Cloudflare D1 + Stripe)"}],"components":{"securitySchemes":{"WalletCookie":{"type":"apiKey","in":"cookie","name":"cga_wallet_tok"},"WalletHeader":{"type":"apiKey","in":"header","name":"X-Wallet-Token","description":"Portable CGW-... wallet token"}}},"security":[{"WalletCookie":[]},{"WalletHeader":[]}],"paths":{"/wallet":{"get":{"summary":"Get or create player wallet, VIP state, rank, and pending entitlements","responses":{"200":{"description":"Wallet snapshot"}}}},"/catalog":{"get":{"summary":"List Stripe real-money coin/VIP packs and per-game armory items","parameters":[{"name":"game_slug","in":"query","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Catalog object"}}}},"/earn":{"post":{"summary":"Award gameplay CGA Coins & XP (250/day cap + automatic +50 Cross-Game Hopper Quest)","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["game_slug","amount"],"properties":{"game_slug":{"type":"string","example":"big-pub-quiz"},"amount":{"type":"integer","minimum":1,"maximum":60,"example":25},"xp":{"type":"integer","example":40},"reason":{"type":"string","example":"Cleared Level 5"},"ref_id":{"type":"string","description":"Idempotency key"}}}}}},"responses":{"200":{"description":"Updated wallet + earned amount"}}}},"/spend":{"post":{"summary":"Atomically spend shared CGA Coins inside any game","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["amount","reason"],"properties":{"game_slug":{"type":"string","example":"pawprint-rescue"},"amount":{"type":"integer","example":50},"reason":{"type":"string","example":"Extra Moves (+5)"},"ref_id":{"type":"string"}}}}}},"responses":{"200":{"description":"Updated wallet + tx_id"},"402":{"description":"INSUFFICIENT_COINS — prompt shop or rewarded ad"}}}},"/items/buy":{"post":{"summary":"Purchase a per-game armory item using CGA Coins and queue entitlement","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["item_id"],"properties":{"item_id":{"type":"string","example":"pr_booster_trio"},"ref_id":{"type":"string"}}}}}},"responses":{"200":{"description":"Updated wallet + purchased_item"},"402":{"description":"INSUFFICIENT_COINS"}}}},"/items/consume":{"post":{"summary":"Atomically claim all queued entitlements for a specific game_slug","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["game_slug"],"properties":{"game_slug":{"type":"string"}}}}}},"responses":{"200":{"description":"Updated wallet + claimed_items array"}}}},"/ads/reward":{"post":{"summary":"Credit +40 CGA Coins after a completed Google H5 / House Rewarded Video Ad (45s cooldown, 8/day cap)","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"game_slug":{"type":"string","example":"big-pub-quiz"},"placement":{"type":"string","example":"reward_coins"},"ad_network":{"type":"string","example":"google_h5"},"ref_id":{"type":"string"}}}}}},"responses":{"200":{"description":"Updated wallet + ad_reward_coins"},"429":{"description":"Cooldown or daily cap"}}}},"/daily":{"post":{"summary":"Claim progressive 7-day login streak (2x for VIP)","responses":{"200":{"description":"Claimed"}}}},"/checkout":{"post":{"summary":"Create Live Stripe Checkout Session","responses":{"200":{"description":"{ checkout_url }"}}}},"/restore":{"post":{"summary":"Restore wallet across devices via CGW-... sync_code","responses":{"200":{"description":"Restored"}}}}}}