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.

ParamTypeDefaultDescription
blockIdstring—Your block ID (required)
debugbooleanfalseTest ad, no billing, no Reward URL
debugConsolebooleanfalseShow SDK logs in console in debug
debugBannerTypestring—"RewardedVideo" or "FullscreenMedia" (debug only)
forceCampaignIdstring—Show one specific campaign (testing)
apiUrlstringscript hostOnly if the API host differs from the script host

Controller methods

MethodReturnsDescription
show()Promise<ShowPromiseResult>Shows the ad. Resolves when finished, rejects when skipped / no ad / error
destroy()voidCloses the ad from your code
addEventListener(e, fn)voidSubscribe to an event
removeEventListener(e, fn)voidUnsubscribe
showNextBanner()booleanSkip 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

EventWhen it fires
onStartFirst frame shown (impression counted)
onSkipUser closed the ad
onRewardReward ad watched till the end (server-verified)
onCompleteInterstitial finished or closed
onProgressPlayback progress
onShowNextBannerNext banner of a multi-banner ad starts
onErrorLoad or playback error
onBannerNotFoundNo ad available right now
onNonStopShowAds requested too often in a row
onTooLongSessionSession older than 4 hours
onNotSuitableAnti-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

RuleValue
Time between ads5 s (configurable per block)
Reward timer15 s or video length
Interstitial close buttonafter 5 s
Video CTA appearsafter 3 s
Task: time away before claim15 s
Task: next task loads30 s after reward
Task: gap between two task loads120 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();   // boolean

Still stuck? Write to support@adsun.io or our Telegram support — we answer fast.