Skip to content

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

apiKeyYour publishable key (pk_…). The SDK refuses secret keys.
gameGame slug from the catalog.
containerCSS selector or element to place the game in.
launchUrlInstead of apiKey+game: a signed URL from the launch API (verified players).
width, heightCSS size. height: "auto" resizes the frame to fit the game.
aspectRatioe.g. "16:9" — responsive, fills the container width.
playerOptional player id (unverified).
onEventCallback for every event.
lazyfalse to load immediately (default lazy).

Events

EventWhene.data
readyLaunch screen loaded{ game }
game.startedA session started (after Play){ test }
score.submittedA score was saved{ score, best, isPersonalBest }
game.completedA round finishedsame as above
errorGame couldn't start{ code } e.g. insufficient_credits
resizeGame 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 listeners

How 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.