Add the SDK

The SDK is a small JavaScript file (ES5, no dependencies, about 10 KB). Its URL is shown in For business → My apps in the DiiL app. Load it in <head> before your own code: it reads the launch data synchronously.

<!-- SDK URL: shown in For business → My apps in the DiiL app -->
<script src="…/diil-miniapp.js"></script>
<script>
  Diil.ready()                        // hide DiiL's loading placeholder
  if (Diil.user) greet(Diil.user.firstName)
  fetch('/session', { method: 'POST', body: Diil.initData })   // verify on your server
</script>

Outside DiiL #

Outside the DiiL app the SDK runs in browser mode: Diil.isInDiil is false, there is no user, native calls do nothing, and requestAuthCode() rejects with not_in_diil.

Empty launch data #

If the user declined consent, the page opens without launch data (Diil.initData === ""). Call Diil.requestAuthCode() to ask again.

The full list of methods is in the JavaScript API reference.