← Back to docs

mde.js Reference

mde.js is the browser client used by publishers to define slots and render winning creatives. You must call mde.display(divId) after you finish defining your slots.

Edit this page →

Public API

mde.init(config)
Initialize the library. Call once on page load.
Params: config object params (seat, publisherId, etc.)
mde.defineSlot(slotConfig)
Declare one ad slot. Call before enableServices().
Params: slot config params (adUnitId, divId, sizes, targeting...)
mde.enableServices()
Enable auction + tracking services. Call after all slots are defined.
Params: No args.
mde.display(divId)
Trigger the auction for a slot and render the result into the provided div.
Params: divId string.
mde.getVersion()
Return the mde.js version string.
Params: No args.

Full example

html
<div id="mde-slot"></div>
<script type="module">
  import * as mde from 'https://exchange.adsgupta.com/mde.js';

  mde.init({
    seat: 'mde',
    publisherId: 'YOUR_PUBLISHER_ID'
  });

  mde.defineSlot({
    adUnitId: 'YOUR_AD_UNIT_ID',
    divId: 'mde-slot',
    sizes: ['300x250']
  });

  mde.enableServices();
  mde.display('mde-slot');
</script>