Publishers · Reference
SDK API reference
Every init option, method, result object and event of the Adsun SDK.
Adsun.init(params)
Creates (or returns the existing) controller for a block. Calling it twice with the same blockId returns the same controller.
| Param | Type | Default | Description |
|---|---|---|---|
blockId | string | — | Your block ID (required) |
debug | boolean | false | Test ad, no billing, no Reward URL |
debugConsole | boolean | false | Show SDK logs in console in debug |
debugBannerType | string | — | "RewardedVideo" or "FullscreenMedia" (debug only) |
forceCampaignId | string | — | Show one specific campaign (testing) |
apiUrl | string | script host | Only if the API host differs from the script host |
Controller methods
| Method | Returns | Description |
|---|---|---|
show() | Promise<ShowPromiseResult> | Shows the ad. Resolves when finished, rejects when skipped / no ad / error |
destroy() | void | Closes the ad from your code |
addEventListener(e, fn) | void | Subscribe to an event |
removeEventListener(e, fn) | void | Unsubscribe |
showNextBanner() | boolean | Skip to the next banner in a multi-banner ad — true when it switched |
ShowPromiseResult
interface ShowPromiseResult {
done: boolean; // true = watched till the end / closed normally
description: string; // human readable reason
state: "load" | "render" | "playing" | "destroy";
error: boolean; // true if something failed
}Events
| Event | When it fires |
|---|---|
onStart | First frame shown (impression counted) |
onSkip | User closed the ad |
onReward | Reward ad watched till the end (server-verified) |
onComplete | Interstitial finished or closed |
onProgress | Playback progress |
onShowNextBanner | Next banner of a multi-banner ad starts |
onError | Load or playback error |
onBannerNotFound | No ad available right now |
onNonStopShow | Ads requested too often in a row |
onTooLongSession | Session older than 4 hours |
onNotSuitable | Anti-fraud rejected the view — no reward |
INFO
If you don't listen to
onBannerNotFound, onNonStopShow or onTooLongSession, the SDK shows a friendly message in the user's language (English, Turkish, Russian) using Telegram's native popup.Timings & rules
| Rule | Value |
|---|---|
| Time between ads | 5 s (configurable per block) |
| Reward timer | 15 s or video length |
| Interstitial close button | after 5 s |
| Video CTA appears | after 3 s |
| Task: time away before claim | 15 s |
| Task: next task loads | 30 s after reward |
| Task: gap between two task loads | 120 s per user and block |
| Max session (initData age) | 4 hours |
Every controller is created once per blockId; window.Adsun.version tells you which SDK build your users are actually running.
Telegram helpers
await Adsun.telegram.requestSafeAreas(300); // ms timeout
Adsun.telegram.getSafeAreas(); // { top, bottom, left, right, ... }
Adsun.telegram.isFullscreen(); // booleanStill stuck? Write to support@adsun.io or our Telegram support — we answer fast.