Skip to main content
Version: v2

iframe / Widget

Embed the ready-made exchange UI in your site. The widget handles quoting, order creation, and the payment screen — you only wire attribution and (optionally) listen for events.

Embed URL

https://n.exchange/iframe
<iframe
src="https://n.exchange/iframe?ref=partner123&from=ETH&to=BTC"
width="420"
height="640"
style="border: 0;"
></iframe>

Query parameters

All parameters are optional; always include ref so orders are attributed to you.

ParameterExampleDescription
ref?ref=partner123Your referral code — see Affiliate & Referral
pair?pair=BTCETHPreselect an exact pair ({to}{from} naming)
from?from=ETHPreselect the deposit currency
to?to=BTCPreselect the withdraw currency
withdraw_address?withdraw_address=bc1q...Prefill the destination address. Must be valid for the chosen withdraw currency
hide-brand?hide-brand=trueHide the "Powered by n.exchange" footer (default false)

Example URL:

https://n.exchange/iframe?ref=partner123&from=ETH&to=BTC&withdraw_address=your_btc_address_here&hide-brand=true

Events

The widget posts messages to the parent window via postMessage.

orderCreated

Emitted when an order is created.

FieldDescription
event"orderCreated"
orderIdThe order's unique_reference — usable directly with GET /orders/{unique_reference}/
window.addEventListener('message', function (event) {
// Only accept messages from the widget origin
if (event.origin !== 'https://n.exchange') {
return;
}

const { event: eventName, orderId } = event.data || {};

if (eventName === 'orderCreated' && orderId) {
console.log('Order created:', orderId);
// e.g. start tracking it server-side via GET /orders/{orderId}/
}
});
Server-side tracking

The widget never exposes your API key. To track widget-created orders, forward the orderId from the event to your backend and poll or subscribe there — see Order Tracking and Webhooks.

Notes

  • Always validate event.origin against https://n.exchange before trusting a message.
  • If you prefill withdraw_address, make sure it matches the to currency you preselect — an address for the wrong chain will fail validation inside the widget.
  • The widget is the recommended path for purely client-side integrations; direct API calls from a browser would expose credentials (Authentication).

Next steps