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.
| Parameter | Example | Description |
|---|---|---|
ref | ?ref=partner123 | Your referral code — see Affiliate & Referral |
pair | ?pair=BTCETH | Preselect an exact pair ({to}{from} naming) |
from | ?from=ETH | Preselect the deposit currency |
to | ?to=BTC | Preselect the withdraw currency |
withdraw_address | ?withdraw_address=bc1q... | Prefill the destination address. Must be valid for the chosen withdraw currency |
hide-brand | ?hide-brand=true | Hide 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.
| Field | Description |
|---|---|
event | "orderCreated" |
orderId | The 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.originagainsthttps://n.exchangebefore trusting a message. - If you prefill
withdraw_address, make sure it matches thetocurrency 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
- Affiliate & Referral — attribution & economics
- Payment UI patterns — if you build your own UI instead