JavaScript SDK
The SDK creates the embed for you and lets your page react to what happens in the game — for example, awarding points in your LMS when a student finishes a round.
Quick start
<div id="acbiz-game"></div>
<script src="https://play.acbizglobal.net/public/js/sdk/acbiz-play.js"></script>
<script>
var game = ACBIZPlay.init({
apiKey: "pk_live_YOUR_KEY", // publishable key only!
game: "mental-math-sprint",
container: "#acbiz-game",
aspectRatio: "16:10", // or width / height, or height: "auto"
player: "student-1042" // optional, your own opaque user id
});
game.on("score.submitted", function (e) {
console.log("Scored", e.data.score, "best", e.data.best);
});
</script>Options
apiKey | Your publishable key (pk_…). The SDK refuses secret keys. |
game | Game slug from the catalog. |
container | CSS selector or element to place the game in. |
launchUrl | Instead of apiKey+game: a signed URL from the launch API (verified players). |
width, height | CSS size. height: "auto" resizes the frame to fit the game. |
aspectRatio | e.g. "16:9" — responsive, fills the container width. |
player | Optional player id (unverified). |
onEvent | Callback for every event. |
lazy | false to load immediately (default lazy). |
Events
| Event | When | e.data |
|---|---|---|
ready | Launch screen loaded | { game } |
game.started | A session started (after Play) | { test } |
score.submitted | A score was saved | { score, best, isPersonalBest } |
game.completed | A round finished | same as above |
error | Game couldn't start | { code } e.g. insufficient_credits |
resize | Game content height changed | { height } |
Events are for your UI. Anything that grants value (money, grades, prizes) should be confirmed on your server via webhooks or the API — browser events can be faked by the person using the browser.
Controlling the game
game.pause(); game.resume();
game.mute(); game.unmute();
game.off("score.submitted");
game.destroy(); // removes the iframe and listenersHow it works (security)
- The SDK talks to the game with
window.postMessage. It only accepts messages whose origin is ACBIZ Play and whose source is its own iframe. - The game only sends events to — and only obeys commands from — the page origin we verified against your allowed domains.
- Game logic and scoring run in the ACBIZ frame and on our servers; nothing in your page can change credits or scores.
Roadmap
The message protocol is versioned (version: 1) so it can grow without breaking you. Planned: XP and achievements, tournament entry, and multiplayer lobbies.