Install it
Your game needs a listing on Alldle first, but it does not have to be live yet. A game’s own SDK page, under its entry in My games, gives you this code already filled in, and shows results as they arrive.
<script src="https://www.alldle.net/sdk.js" data-game="your-game-slug"></script>The tag creates a ready instance named alldle. You only call it when a round ends:
alldle.completeMode('classic', { won: true, attempts: 3, maxAttempts: 6 });This address always serves the current version, so you can leave it as it is.
npm i @alldle/sdkimport { Alldle } from '@alldle/sdk';
const alldle = new Alldle({ gameSlug: 'your-game-slug' });
alldle.completeMode('classic', { won: true, attempts: 3, maxAttempts: 6 });The package comes with types. Call alldle.connect() when the page loads, so that a player sent by Alldle is recognized and their token leaves the address bar. The script tag does this by itself.
Your game’s slug
Section titled “Your game’s slug”data-game is the end of your Alldle address: alldle.net/game/your-game-slug.
Where it goes
Section titled “Where it goes”Anywhere on the page where the game runs. In a single-page app with the script tag, add it to your HTML template, and call alldle from the code that ends a round.
In TypeScript with the script tag, declare the global yourself, or use the npm package for types:
declare const alldle: { completeMode(mode: string, data: { won: boolean; attempts?: number; maxAttempts?: number }): Promise<unknown>;};See what it does
Section titled “See what it does”Add data-debug to the script tag, or debug: true with npm. Every call is then logged in the browser console. A wrong slug or domain is always reported there, even without it.
<script src="https://www.alldle.net/sdk.js" data-game="your-game-slug" data-debug></script>From an older version
Section titled “From an older version”Coming from 0.1? If you load /sdk.js, you are already on 0.2, and AllDle and AllDleSDK.AllDle still work. If you bundled 0.1, upgrade the package: until you do, your own site reports nothing. Your game’s SDK page tells you if the game is still on the old version.
Report rounds, then check that it works.