{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-products/hosted-checkout/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"JavaScript SDK","description":"Official Banxa API documentation – on-ramp and off-ramp transfers with identity verification and compliance.","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"javascript-sdk","__idx":0},"children":["JavaScript SDK"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The Banxa JavaScript SDK provides a lightweight alternative to manually constructing referral URLs. Include a single script tag and use the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Banxa"]}," class to trigger redirect or iFrame checkout from any button or event in your page."]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"include-the-sdk","__idx":1},"children":["Include the SDK"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Add the following loader script to your page. It asynchronously loads the SDK and calls your ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["yourOnLoadFunction"]}," callback when ready."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"!function(callback){\n  var b = document.createElement('script');\n  b.type = \"text/javascript\";\n  b.async = true;\n  b.src = \"https://sdk.banxa.com/js/banxa-sdk-latest.js\";\n  var x = document.getElementsByTagName('script')[0];\n  x.parentNode.insertBefore(b, x);\n  if (callback) { b.addEventListener(\"load\", function() { callback() }) }\n}(yourOnLoadFunction);\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"initialise-the-banxa-class","__idx":2},"children":["Initialise the Banxa class"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Create an instance of ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Banxa"]}," with your partner name. Use the second argument to select sandbox or production."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"// Production\nconst banxa = new Banxa('your-partner-name');\n\n// Sandbox\nconst banxa = new Banxa('your-partner-name', 'sandbox');\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Replace ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["your-partner-name"]}," with the partner subdomain provided by Banxa (e.g., ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["binance"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["metamask"]},")."]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"redirect-to-a-new-tab","__idx":3},"children":["Redirect to a new tab"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Open the Banxa checkout in a new browser tab when a button is clicked."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"banxa.redirect('#redirect', {\n  fiatType: 'AUD',\n  coinType: 'BTC',\n  fiatAmount: 500,\n  walletAddress: '3Hiy7HuFcqwkgERyfRSwEHqrwSwTirm8zb',\n  theme: 'dark'\n});\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"html","header":{"controls":{"copy":{}}},"source":"<button id=\"redirect\">Buy crypto</button>\n","lang":"html"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The first argument (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["#redirect"]},") is a CSS selector for the element that triggers the checkout on click."]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"embed-as-an-iframe","__idx":4},"children":["Embed as an iFrame"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Inject an iFrame into a container element in your page."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"banxa.iframe(\n  '#iframeButton',   // trigger element selector\n  '#iframeTarget',   // container element selector\n  {\n    fiatType: 'AUD',\n    coinType: 'BTC',\n    fiatAmount: 200,\n    walletAddress: '3Hiy7HuFcqwkgERyfRSwEHqrwSwTirm8zb'\n  },\n  '800px',           // optional width (pass false to omit)\n  '400px'            // optional height (pass false to omit)\n);\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"html","header":{"controls":{"copy":{}}},"source":"<button id=\"iframeButton\">Open checkout</button>\n\n<div id=\"iframeTarget\">\n  <!-- iFrame is injected here -->\n</div>\n","lang":"html"},"children":[]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"supported-parameters","__idx":5},"children":["Supported parameters"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["All ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/products/hosted-checkout/docs/referral-integration/supported-parameters"},"children":["referral URL parameters"]}," are supported as keys in the options object passed to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["redirect()"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["iframe()"]},"."]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"notes","__idx":6},"children":["Notes"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["The SDK generates a referral URL from the options you provide and opens it via redirect or iFrame — it does not make server-to-server API calls."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["For server-to-server order creation (with webhooks, order IDs, and KYC sharing), use the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/products/hosted-checkout/docs/api-integration/api-integration-overview"},"children":["API integration"]}," instead."]}]}]},"headings":[{"value":"JavaScript SDK","id":"javascript-sdk","depth":1},{"value":"Include the SDK","id":"include-the-sdk","depth":2},{"value":"Initialise the Banxa class","id":"initialise-the-banxa-class","depth":2},{"value":"Redirect to a new tab","id":"redirect-to-a-new-tab","depth":2},{"value":"Embed as an iFrame","id":"embed-as-an-iframe","depth":2},{"value":"Supported parameters","id":"supported-parameters","depth":2},{"value":"Notes","id":"notes","depth":2}],"frontmatter":{"title":"Banxa JavaScript SDK for Referral Integration | Banxa Docs","description":"Embed or redirect to Banxa checkout using the JavaScript SDK. One-line script tag setup with redirect() and iframe() methods for referral integrations.","seo":{"title":"JavaScript SDK"}},"lastModified":"2026-05-19T23:30:38.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/products/hosted-checkout/docs/referral-integration/javascript-sdk","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}