Skip to documentation
AdQuestDocs

Quickstart: iframe or WebView

Show your first quest in the hosted embed, from any website, with one backend route and a few lines of JavaScript.

On this page

Prerequisites

  • The publisher’s accepted and active platform, with its Embed URL and public API key.
  • Your site’s address on the platform’s Where AdQuest may appear list, if the publisher keeps one.
  • A backend route that creates participant sessions. Use the one from the Quickstart.

Step 1: Load the embed and send the session

The page waits for adquest:ready from the embed, asks your backend for a session, then sends adquest:init.

index.html
<iframe id="adquest" title="AdQuest rewards" style="width:100%;height:720px;border:0"></iframe>
<script type="module">
  const frame = document.getElementById("adquest");
  const origin = "https://sdk.adquest.batriders.ir";
  window.addEventListener("message", async (event) => {
    if (event.origin !== origin || event.source !== frame.contentWindow) return;
    const message = typeof event.data === "string" ? JSON.parse(event.data) : event.data;
    if (message?.version !== 1 || message.type !== "adquest:ready") return;
    const session = await fetch("/api/adquest/session", { method: "POST" }).then((response) => response.json());
    frame.contentWindow.postMessage({ version: 1, type: "adquest:init", payload: { apiKey: "YOUR_PUBLIC_API_KEY", ...session } }, origin);
  });
  frame.src = origin + "/YOUR_PLATFORM_PUBLIC_ID";
</script>

Step 2: What you should see

  • The embed loads with the publisher’s branding and shows the quests and the token balance.
  • Opening and completing a quest adds tokens to the balance.

Next steps

Something unclear, missing or wrong here? Tell us