WEB SDK v1.0.0 JavaScript

Web SDK Integration

Add the AdswedMedia offerwall to any website with a single script tag. Modal or embed mode, automatic reward polling, and event-driven architecture.

Size ~18 KB Deps None IE11+ Compatible

Quick Start 5 minutes to integrate

Setup in 4 Steps

1

Add Script

Include the SDK script tag in your HTML

2

Initialize

Call ADSW.init() with your app key

3

Show

Add a button that calls ADSW.show()

4

Earn

Listen for reward events to credit users

Step 1: Add the SDK Script
HTML
<script src="https://www.pro.adswedmedia.com/sdk/v1/adsw.js"></script>
Step 2: Initialize
JavaScript
ADSW.init({
  appKey: 'YOUR_APP_KEY',      // From Publisher Dashboard
  userId: 'USER_123',          // Your user's unique ID
  appName: 'My App',           // Displayed in offerwall header
  enablePolling: true,         // Auto-check for rewards
  debug: false                 // Set true during development
});
Step 3: Add a Button
HTML
<button onclick="ADSW.show()">Earn Rewards</button>
Step 4: Listen for Rewards
JavaScript
ADSW.on('reward', function(data) {
  console.log('Earned ' + data.reward + ' ' + data.currency);
  // data.transactionId — use for deduplication
});

Complete HTML Example

HTML
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>My Rewards Page</title>
</head>
<body>

  <h1>Earn Free Coins!</h1>
  <p>Your balance: <span id="balance">0</span> coins</p>
  <button id="openOfferwall" disabled>Loading...</button>

  <script src="https://www.pro.adswedmedia.com/sdk/v1/adsw.js"></script>
  <script>
    var userBalance = 0;

    ADSW.init({
      appKey: 'YOUR_APP_KEY',
      userId: 'user_123',
      appName: 'My Rewards App',
      enablePolling: true
    }, function(error) {
      if (error) { console.error('Init failed:', error); return; }
      var btn = document.getElementById('openOfferwall');
      btn.textContent = 'Earn Coins';
      btn.disabled = false;
      btn.onclick = function() { ADSW.show(); };
    });

    ADSW.on('reward', function(data) {
      userBalance += data.reward;
      document.getElementById('balance').textContent = userBalance;
    });
  </script>
</body>
</html>

Configuration

Init Options

OptionTypeRequiredDefaultDescription
appKeystringYes-Your API key from the Publisher Dashboard
userIdstringYes-Unique user ID in your system (must be stable per user)
appNamestringNo"Offerwall"Name displayed in the offerwall header
baseUrlstringNoAutoOverride the API base URL
localestringNo-Language code (en, es, fr)
debugbooleanNofalseEnable console logging
enablePollingbooleanNofalseAuto-poll for rewards every 15 seconds
pollIntervalnumberNo15000Polling interval in milliseconds
showRewardToastbooleanNotrueShow toast notification on reward

Display Modes

Modal Mode (Default)

Offerwall opens as a centered popup overlay. Close via X button, click outside, or ESC key. Full-screen on mobile.

JavaScript
ADSW.show();                    // default modal
ADSW.show({ mode: 'modal' });   // explicit
Embed Mode

Renders the offerwall inline inside a container element on your page.

HTML + JS
<div id="offerwall-container" style="width:100%;max-width:480px"></div>

<script>
  ADSW.show({
    mode: 'embed',
    container: '#offerwall-container',
    height: '700px'   // optional, default: 600px
  });
</script>

Events & Methods

Events

EventDataDescription
init{ sessionId, site }SDK initialized successfully
ready{}Offerwall iframe loaded and ready
open-Offerwall displayed
close-Offerwall closed
reward{ transactionId, offerId, offerName, reward, currency, timestamp }User earned a reward
offer_click{ offerId, offerName, payout }User clicked an offer
error{ message }An error occurred
Reward Event Example
JavaScript
ADSW.on('reward', function(data) {
  data.transactionId  // Unique ID for deduplication
  data.offerId        // Offer identifier
  data.offerName      // Offer name
  data.reward         // Amount earned (in your currency)
  data.currency       // Currency name (e.g. "coins")
  data.timestamp      // ISO timestamp
});

API Methods

MethodDescription
ADSW.init(config, cb)Initialize the SDK (required first)
ADSW.show(options)Display the offerwall (modal or embed)
ADSW.hide()Close the offerwall modal
ADSW.on(event, fn)Register event listener
ADSW.off(event, fn)Remove event listener
ADSW.isReady()Returns true if SDK is initialized
ADSW.isVisible()Returns true if offerwall is showing
ADSW.getSessionId()Returns current session token
ADSW.destroy()Remove all SDK elements and listeners