@poki/sdk
v0.0.2
Published
Typed, minimal wrapper around the Poki SDK. This package does **not** bundle the Poki SDK itself; it simply forwards calls and provides TypeScript types.
Maintainers
Keywords
Readme
@poki/sdk
Typed, minimal wrapper around the Poki SDK. This package does not bundle the Poki SDK itself; it simply forwards calls and provides TypeScript types.
You still need:
<script src="https://game-cdn.poki.com/scripts/v2/poki-sdk.js"></script>or something similar depending on your game engine.
Documentation: Poki SDK Documentation
Install
npm install @poki/sdkyarn add @poki/sdkUsage
Make sure the Poki SDK script is loaded in your page (see above). Then use this package to access the API:
import PokiSDK from '@poki/sdk';
async function boot() {
await PokiSDK.init();
PokiSDK.gameLoadingFinished();
}
boot();If the Poki SDK script is not loaded, this package will throw PokiSDK not loaded on use.
API
Initialization
init(options?: InitOptions): Promise<void>setDebug(toggle: boolean): voidsetLogging(toggle: boolean): void
Gameplay Lifecycle
gameLoadingFinished(): voidgameplayStart(): voidgameplayStop(): void
Commercial Breaks (see documentation for details)
commercialBreak(onStart?: () => void): Promise<void>
Rewarded Breaks (see documentation for details)
rewardedBreak(): Promise<boolean>
Sharing (see documentation for details)
shareableURL(params?: object): Promise<string>getURLParam(key: string): string
UI (see documentation for details)
movePill(topPercent: number, topPx: number): void
Analytics and Errors
measure(category: string, what: string, action: string): voidcaptureError(err: string | Error): void
External Links
openExternalLink(url: string): void
Playtest Helpers
playtestSetCanvas(canvas: HTMLCanvasElement | HTMLCanvasElement[] | null): voidplaytestCaptureHtmlOnce(): voidplaytestCaptureHtmlForce(): voidplaytestCaptureHtmlOn(): voidplaytestCaptureHtmlOff(): void
License
ISC
