Skip to main content

Classes

Adrop

The main SDK class. Works as a singleton.

Static Methods

MethodReturn TypeDescription
observe(config)AdropInitialize SDK and start automatic DOM detection
instance()AdropReturn existing instance

Instance Methods

MethodReturn TypeDescription
renderAd(container, options?)Promise<void>Render ad
requestAd(options)Promise<AdropAdResponse>Request ad data only
clear(container)voidRemove ad
setConfig(config)voidUpdate configuration
on(event, callback, filter?)voidRegister event listener
off(event, callback)voidUnregister event listener

Instance Properties

PropertyTypeDescription
uidstringUser identifier (getter/setter)
appKeystringAPI authentication key (getter/setter)
metricsAdropMetricsUser property management

Interfaces

AdropConfig

SDK initialization options.
interface AdropConfig {
  appId: string;      // App ID (required)
  uid?: string;       // User identifier
  appKey?: string;    // API authentication key
  debug?: boolean;    // Debug logging (default: false)
}

AdropAdRequest

Ad request parameters.
interface AdropAdRequest {
  unit: string;           // Unit ID (required)
  uid?: string;           // User identifier
  contextId?: string;     // Contextual targeting ID
  trackMode?: 0 | 1;      // 0: auto, 1: manual (native)
  isEntireClick?: boolean; // Entire area click (native)
  theme?: AdTheme;        // Theme
}

AdropAdResponse

Ad response object.
interface AdropAdResponse {
  code: AdropErrorCode;  // Response code
  msg: string;           // Response message
  result?: AdData;       // Ad data (on success)
}

AdData

Ad data object.
interface AdData {
  // Common
  format: AdFormat;       // Ad format
  unit: string;           // Unit ID

  // Native ad fields
  headline?: string;      // Ad title
  body?: string;          // Ad description
  callToAction?: string;  // CTA button text
  asset?: string;         // Main image URL
  destinationURL?: string; // Click destination URL

  // Advertiser profile
  profile?: {
    displayLogo?: string;  // Advertiser logo URL
    displayName?: string;  // Advertiser name
    link?: string;         // Advertiser profile link
  };

  // Extra text items
  extra?: Record<string, string>;
}

AdropEventFilter

Event filter options.
interface AdropEventFilter {
  unit?: string;  // Filter specific unit only
}

Constants

Adrop.Events

Event constants. Access via Adrop.Events.
ConstantValueDescription
AD_RECEIVED'adReceived'Ad received successfully
AD_NO_FILL'adNoFill'No direct ads
AD_IMPRESSION'adImpression'Ad impression
AD_CLICKED'adClicked'Ad click
AD_FAILED'adFailed'Ad request failed
AD_BACKFILL_NO_FILL'adBackfillNoFill'No backfill ads

Adrop.ErrorCode

Error codes. Access via Adrop.ErrorCode.
ConstantValueDescription
OK0Success
ERROR_CODE_INVALID_UNIT4000Invalid unit ID
ERROR_CODE_AD_INACTIVE4001No active campaigns
ERROR_CODE_AD_NO_FILL4002No matching ads
ERROR_CODE_INVALID_PARAMS4003Invalid parameters

Types

AdFormat

Ad format type.
type AdFormat = 'banner' | 'nativeAd' | 'backfill';

AdTheme

Theme type.
type AdTheme = 'light' | 'dark';

Event Callbacks

Callback signatures for each event.
// Ad received, impression, click
type AdReceivedCallback = (unit: string, adData: AdData) => void;
type AdImpressionCallback = (unit: string, adData: AdData) => void;
type AdClickedCallback = (unit: string, adData: AdData) => void;

// No ad, failed
type AdNoFillCallback = (unit: string) => void;
type AdFailedCallback = (unit: string) => void;
type AdBackfillNoFillCallback = (unit: string) => void;