Skip to content
Developers

Embed the BayChange widget

Add our exchange form to your site with one line of HTML. Exchanges started in it are credited to your partner code.

Public REST API: not available yet. For now you can integrate BayChange with the widget below and with partner links. Get your partner code in your account — it also has a code builder with a live preview.

Quick start

Paste this where the form should appear. Replace your-code with your partner code. The default height (720 px) fits the form; for an exact fit, add the resize script below.

HTML
<iframe
  src="https://baychange.com/embed?ref=your-code&amp;from=usdt.tron&amp;to=btc.btc"
  title="Crypto exchange by BayChange"
  width="100%" height="720"
  style="display:block;width:100%;max-width:480px;border:0;color-scheme:light"
  allow="clipboard-read; clipboard-write" loading="lazy"></iframe>

Parameters

All parameters go in the iframe address: https://baychange.com/embed?ref=…&from=…. All are optional.

refk7m2qxaYour partner code (from your account). Exchanges started in the widget count as yours. Without it the widget works, but nothing is credited.
fromusdt.tronCoin you send, as SYMBOL.NETWORK. Case doesn't matter. Default: USDT on Tron.
tobtc.btcCoin you get. Default: BTC.
amount250Amount to send, in units of the “from” coin. Your visitor can change it.
themelightBackground around the form: light (white, default) or transparent.
localeruInterface language: en, es, pt-br, tr, ru, uk, kk, uz, az, de, fr, it, pl, ja, zh, id, vi. Default: en. The widget then opens at /<language>/embed (you can also use that address directly, e.g. https://baychange.com/ru/embed?ref=your-code).

Events

The widget sends messages to your page with postMessage. Always check thatevent.origin is https://baychange.com.

baychange:ready—The widget has loaded.
baychange:resize{ height }Height of the widget content in pixels. Use it to resize the iframe.
baychange:order_created{ order: { id, from, to, amountIn } }Your visitor created an order. The order page opens on baychange.com in a new tab.

Resize the iframe automatically

HTML
<iframe
  src="https://baychange.com/embed?ref=your-code"
  title="Crypto exchange by BayChange"
  width="100%" height="720"
  style="display:block;width:100%;max-width:480px;border:0;color-scheme:light"
  allow="clipboard-read; clipboard-write" loading="lazy"></iframe>
<script>
window.addEventListener("message", function (e) {
  if (e.origin !== "https://baychange.com" || !e.data || e.data.type !== "baychange:resize") return;
  document.querySelectorAll('iframe[src^="https://baychange.com/embed"]').forEach(function (f) {
    if (f.contentWindow === e.source) f.style.height = e.data.height + "px";
  });
});
</script>

Listen for new orders

JavaScript
window.addEventListener("message", function (e) {
  if (e.origin !== "https://baychange.com" || !e.data) return;
  if (e.data.type === "baychange:order_created") {
    // e.data.order = { id, from, to, amountIn }
    console.log("BayChange order created", e.data.order.id);
  }
});

What your visitor sees

  1. Gets a quotePicks the coins and amount, sees the fee and what they get before anything is sent.
  2. Enters their addressesThe payout address and a refund address are checked in the form, as on our site.
  3. Opens the order page“Start exchange” creates the order and opens its page on baychange.com in a new tab, with the deposit address and live status.

Limits and rules

  • There is no public REST API yet. The widget and partner links are the only integration for now.
  • Don't put the iframe in a sandbox. If you must, allow scripts, same-origin, forms, popups and popups-to-escape-sandbox, or the form and the order page won't work.
  • Keep the iframe at least 320 px wide. The form is designed for 360–480 px.
  • Don't cover, crop or restyle the form, and don't ask visitors for their wallet addresses outside it.
  • The order page with the deposit address always opens on baychange.com, not inside your site.
  • The usual limits apply: minimum amounts per coin, request limits per visitor, and regions where the service is not available.
  • The order number in the order_created event opens the order page. Treat it as private: don't publish or log it where others can see it.

Earnings, payouts and partner rules: partner program and Partner Terms.

Get your partner code