[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"wp-translations":3,"fetchDocsBySlug-apiv2-en":10},{"post":4,"docs":7},[5,6],"EN","RU",[5,8,6,9],"ES","UA",{"id":11,"title":12,"slug":13,"date":14,"status":15,"content":16,"language":17,"translations":18,"seo":24,"apiDocFields":33,"featuredImage":29,"postsnotation":34},"cG9zdDoxMjQx","APIv2","apiv2","2024-09-11T10:21:35","publish","\u003Cp id=\"tw-target-text\" class=\"tw-data-text tw-text-large tw-ta\" dir=\"ltr\" data-placeholder=\"Перевод\" aria-label=\"Переведенный текст\" data-ved=\"2ahUKEwj68-3liKuIAxXnlP0HHXvCJS8Q3ewLegQICBAU\">\u003Cstrong>\u003Cspan class=\"Y2IQFc\" lang=\"en\">The following methods are used to enhance the capabilities of your service using Swapgate.io’s exchange features.\u003C\u002Fspan>\u003C\u002Fstrong>\u003C\u002Fp>\n\u003Ch2>Algorithm\u003C\u002Fh2>\n\u003Cp>\u003Cspan class=\"Y2IQFc\" lang=\"en\">Swapgate\u003C\u002Fspan> uses a dynamic rate system to generate exchange rate predictions, using liquidity provider market depth analysis. While the default flow will analyse the market depth and return a realistically-calculated result, the \u003Cstrong>markup\u003C\u002Fstrong> parameter can influence the rate returned by the rate prediction algorithm.\u003C\u002Fp>\n\u003Cp>The \u003Cstrong>markup\u003C\u002Fstrong> parameter will influence the rate pre-calculation returned by our system on the following way:\u003C\u002Fp>\n\u003Cblockquote>\u003Cp>A \u003Csub>final\u003C\u002Fsub>​=A \u003Csub>calculated\u003C\u002Fsub>​​ ∗ (1 − K \u003Csub>markup \u003C\u002Fsub>\u002F 100​)\u003C\u002Fp>\u003C\u002Fblockquote>\n\u003Ctable>\n\u003Ctbody>\n\u003Ctr>\n\u003Ctd>A \u003Csub>final\u003C\u002Fsub>​\u003C\u002Ftd>\n\u003Ctd>Final amount to receive, predicted for the exchange\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>A \u003Csub>calculated\u003C\u002Fsub>\u003C\u002Ftd>\n\u003Ctd>Initial amount to receive predicted for the exchange\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>K \u003Csub>markup \u003C\u002Fsub>​\u003C\u002Ftd>\n\u003Ctd>\u003Cstrong>markup\u003C\u002Fstrong> parameter value\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003C\u002Ftbody>\n\u003C\u002Ftable>\n\u003Cp>Based on the provided formula, a \u003Cb>markup\u003C\u002Fb> value of 0.3, provided for a 1 BTC → USDT exchange will yield the following results, making the final prediction price increased by 0.3%:\u003C\u002Fp>\n\u003Cblockquote>\u003Cp>49549.728053855135 * (1 – 0.3 \u002F 100) = 49401.07886969357\u003C\u002Fp>\u003C\u002Fblockquote>\n\u003Ch2>API\u003C\u002Fh2>\n\u003Cp>The rates data can be obtained through an API \u003Cstrong>v1\u003C\u002Fstrong> call to the \u003Cstrong>\u002Fapi\u002Fv1\u002Frates\u002Fpublic\u002Fone endpoint\u003C\u002Fstrong>.\u003C\u002Fp>\n\u003Cp>The API \u003Cstrong>v1\u003C\u002Fstrong> does not require API key authorization or IP whitelisting.\u003C\u002Fp>\n\u003Ctable>\n\u003Cthead>\n\u003Ctr>\n\u003Cth>Parameter\u003C\u002Fth>\n\u003Cth>Description\u003C\u002Fth>\n\u003Cth>Example\u003C\u002Fth>\n\u003C\u002Ftr>\n\u003C\u002Fthead>\n\u003Ctbody>\n\u003Ctr>\n\u003Ctd>\u003Cstrong>instrumentFromCurrencyTitle\u003C\u002Fstrong>\u003C\u002Ftd>\n\u003Ctd>The name of the currency to be exchanged\u003C\u002Ftd>\n\u003Ctd>BTC\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>\u003Cstrong>instrumentFromNetworkTitle\u003C\u002Fstrong>\u003C\u002Ftd>\n\u003Ctd>The blockchain network of the currency to be exchanged\u003C\u002Ftd>\n\u003Ctd>BTC\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>\u003Cstrong>instrumentToCurrencyTitle\u003C\u002Fstrong>\u003C\u002Ftd>\n\u003Ctd>The name of the currency to be obtained\u003C\u002Ftd>\n\u003Ctd>USDT\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>\u003Cstrong>instrumentToNetworkTitle\u003C\u002Fstrong>\u003C\u002Ftd>\n\u003Ctd>The blockchain network of the currency to be obtained\u003C\u002Ftd>\n\u003Ctd>TRC20\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>\u003Cstrong>rateMode\u003C\u002Fstrong>\u003C\u002Ftd>\n\u003Ctd>The rate mode of the exchange, FLOATING or FIXED.\u003C\u002Ftd>\n\u003Ctd>FLOATING\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>\u003Cstrong>claimedDepositAmount\u003C\u002Fstrong>\u003C\u002Ftd>\n\u003Ctd>The deposit amount claimed to be paid by the client\u003C\u002Ftd>\n\u003Ctd>1\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>\u003Cstrong>markup\u003C\u002Fstrong>\u003C\u002Ftd>\n\u003Ctd>The markup parameter\u003C\u002Ftd>\n\u003Ctd>0.3\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003C\u002Ftbody>\n\u003C\u002Ftable>\n\u003Cpre>\u003Ccode>\r\nGET \u002Fapi\u002Fv1\u002Frates\u002Fpublic\u002Fone?instrumentFromCurrencyTitle=BTC&amp;instrumentFromNetworkTitle=\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cpre>\u003Ccode>BTC&amp;instrumentToCurrencyTitle=\u003C\u002Fcode>\u003Ccode>USDT&amp;instrumentToNetworkTitle=TRC20&amp;rateMode=FLOATING&amp;claimedDepositAmount=\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cpre>\u003Ccode>1&amp;markup=0.3\r\n\r\n{\r\n\t\"instrumentFrom\": {\r\n\t\t\"currencyTitle\": \"BTC\",\r\n\t\t\"networkTitle\": \"BTC\",\r\n\t\t\"precisionDecimals\": 11\r\n\t},\r\n\t\"instrumentTo\": {\r\n\t\t\"currencyTitle\": \"USDT\",\r\n\t\t\"networkTitle\": \"TRC20\",\r\n\t\t\"precisionDecimals\": 1\r\n\t},\r\n\t\"depositRules\": {\r\n\t\t\"minAmount\": \"0.0010202831699481001984\",\r\n\t\t\"maxAmount\": \"0\"\r\n\t},\r\n\t\"withdrawalRules\": {\r\n\t\t\"minAmount\": \"51.324600057525118367\",\r\n\t\t\"maxAmount\": \"0\",\r\n\t\t\"withdrawalFeeRules\": {\r\n\t\t\t\"maxAmount\": \"1\",\r\n\t\t\t\"minAmount\": \"1\"\r\n\t\t}\r\n\t},\r\n\t\"minConfirmationsToWithdraw\": 2,\r\n\t\"minConfirmationsToTrade\": 2,\r\n\t\"updatedAt\": \"2024-08-05T13:31:44.315Z\",\r\n\t\"liquidityProviderPublicCode\": \"radio\",\r\n\t\"amountToGet\": \"50201.90689595\",\r\n\t\"amountToGive\": \"1\",\r\n\t\"marketMinAmount\": \"0.1\",\r\n\t\"enableFixedRate\": true,\r\n\t\"amountToGiveCurrencyTitle\": \"BTC\",\r\n\t\"rateMode\": \"FLOATING\",\r\n\t\"finalNetworkFeeAmount\": \"0\",\r\n\t\"platformFee_Absolute\": null,\r\n\t\"liquidityProviderQuotes\": {\r\n\t\t\"sellQuote\": {\r\n\t\t\t\"baseValue\": \"1\",\r\n\t\t\t\"quoteValue\": \"50304.27\"\r\n\t\t},\r\n\t\t\"buyQuote\": {\r\n\t\t\t\"baseValue\": \"50294.99\",\r\n\t\t\t\"quoteValue\": \"1\"\r\n\t\t}\r\n\t},\r\n\t\"price\": \"50201.90689595\",\r\n\t\"marketLeftPrice\": \"50304.27\",\r\n\t\"marketRightPrice\": \"0.000019882696069727819809\",\r\n\t\"marketAmountToGet\": \"50243.798064469251204\",\r\n\t\"marketAmountToGetUSDT\": \"50243.798064469251204\",\r\n\t\"quotesWithoutNetworkFee\": {\r\n\t\t\"sellQuote\": {\r\n\t\t\t\"baseValue\": \"1\",\r\n\t\t\t\"quoteValue\": \"50202.90689595\"\r\n\t\t},\r\n\t\t\"buyQuote\": {\r\n\t\t\t\"baseValue\": \"50294.99\",\r\n\t\t\t\"quoteValue\": \"0.997985\"\r\n\t\t}\r\n\t},\r\n\t\"quotes\": {\r\n\t\t\"sellQuote\": {\r\n\t\t\t\"baseValue\": \"1\",\r\n\t\t\t\"quoteValue\": \"50201.90689595\"\r\n\t\t},\r\n\t\t\"buyQuote\": {\r\n\t\t\t\"baseValue\": \"50294.99\",\r\n\t\t\t\"quoteValue\": \"0.99796512097183797717\"\r\n\t\t}\r\n\t},\r\n\t\"markup\": \"0.3\"\r\n}\r\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Ch2>Markup parameter in order flow\u003C\u002Fh2>\n\u003Ch3>Algorithm\u003C\u002Fh3>\n\u003Cp>The markup parameter must also be passed during the order creation to ensure valid order commission. With the markup parameter passed, \u003Cspan class=\"Y2IQFc\" lang=\"en\">Swapgate\u003C\u002Fspan> will apply the following formula to the order commission algorithm:\u003C\u002Fp>\n\u003Cblockquote>\u003Cp>A \u003Csub>withdrawal\u003C\u002Fsub> = A \u003Csub>exchange\u003C\u002Fsub> * (1 – (C \u003Csub>platform(%)\u003C\u002Fsub> + K \u003Csub>markup\u003C\u002Fsub>) \u002F 100)\u003C\u002Fp>\u003C\u002Fblockquote>\n\u003Ctable>\n\u003Ctbody>\n\u003Ctr>\n\u003Ctd>A \u003Csub>withdrawal\u003C\u002Fsub>​\u003C\u002Ftd>\n\u003Ctd>Amount of currency sent to the client as the exchange result\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>A \u003Csub>exchange\u003C\u002Fsub>\u003C\u002Ftd>\n\u003Ctd>Amount of currency that \u003Cspan class=\"Y2IQFc\" lang=\"en\">Swapgate\u003C\u002Fspan> had available after performing our trading strategy\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>C \u003Csub>platform(%)\u003C\u002Fsub>​\u003C\u002Ftd>\n\u003Ctd>Commission percent defined by \u003Cspan class=\"Y2IQFc\" lang=\"en\">Swapgate\u003C\u002Fspan>\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>K \u003Csub>markup \u003C\u002Fsub>​\u003C\u002Ftd>\n\u003Ctd>\u003Cstrong>markup\u003C\u002Fstrong> parameter value\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003C\u002Ftbody>\n\u003C\u002Ftable>\n\u003Cp>Based on the provided formula, a \u003Cstrong>markup\u003C\u002Fstrong> value of 0.3 provided during order creation, will increase \u003Cspan class=\"Y2IQFc\" lang=\"en\">Swapgate\u003C\u002Fspan> commission percent by 0.3.\u003Cbr \u002F>\nIn the following example \u003Cspan class=\"Y2IQFc\" lang=\"en\">Swapgate\u003C\u002Fspan> commission is set to 1 percent:\u003C\u002Fp>\n\u003Cblockquote>\u003Cp>A \u003Csub>withdrawal\u003C\u002Fsub> = A \u003Csub>exchange\u003C\u002Fsub> * (1 – (1 + 0.3) \u002F 100)\u003C\u002Fp>\u003C\u002Fblockquote>\n\u003Cp>Using the previous example, an exchange of 1 BTC to USDT based on the market price of \u003Cstrong>50243.798064469251204\u003C\u002Fstrong> BTC:USDT will yield the following client withdrawal amount:\u003C\u002Fp>\n\u003Cblockquote>\u003Cp>50243.798064469251204 * (1 – (1 + 0.3) \u002F 100) = 49590.62868963115\u003C\u002Fp>\u003C\u002Fblockquote>\n\u003Cp>Based on the provided formula, a \u003Cstrong>markup \u003C\u002Fstrong>value of 0.3 provided during order creation, will increase \u003Cspan class=\"Y2IQFc\" lang=\"en\">Swapgate \u003C\u002Fspan>commission percent by 0.3.\u003Cbr \u002F>\nAfter an exchange with a markup parameter enters the \u003Cstrong>COMPLETED\u003C\u002Fstrong> state, the markup parameter will be used in the partner margin calculation formula:\u003C\u002Fp>\n\u003Cblockquote>\u003Cp>C \u003Csub>affiliate\u003C\u002Fsub> = C \u003Csub>platform\u003C\u002Fsub> * (C \u003Csub>affiliate(%)\u003C\u002Fsub> \u002F 100) + C \u003Csub>platform\u003C\u002Fsub> * (K \u003Csub>markup\u003C\u002Fsub> \u002F 100)\u003C\u002Fp>\u003C\u002Fblockquote>\n\u003Ctable>\n\u003Ctbody>\n\u003Ctr>\n\u003Ctd>C \u003Csub>affiliate\u003C\u002Fsub>​\u003C\u002Ftd>\n\u003Ctd>Amount of currency sent to the affiliate’s wallet per exchange (affiliate margin)\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>C \u003Csub>platform\u003C\u002Fsub>\u003C\u002Ftd>\n\u003Ctd>Amount of currency that \u003Cspan class=\"Y2IQFc\" lang=\"en\">Swapgate \u003C\u002Fspan>gained from the exchange (platform margin)\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>C \u003Csub>affiliate(%)\u003C\u002Fsub>​\u003C\u002Ftd>\n\u003Ctd>Commission percent defined for the affiliate\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>K \u003Csub>markup \u003C\u002Fsub>​\u003C\u002Ftd>\n\u003Ctd>\u003Cstrong>markup\u003C\u002Fstrong> parameter value\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003C\u002Ftbody>\n\u003C\u002Ftable>\n\u003Ch2>Passing the \u003Cstrong>markup\u003C\u002Fstrong> parameter\u003C\u002Fh2>\n\u003Cp>During order creation, \u003Cspan class=\"Y2IQFc\" lang=\"en\">Swapgate\u003C\u002Fspan> API accepts the \u003Cstrong>markup\u003C\u002Fstrong> parameter alongside other order creation parameters:\u003C\u002Fp>\n\u003Cpre>\u003Ccode>\r\n{\r\n\t\"rateMode\": \"FLOATING\",\r\n\t\"instrumentFrom\": {\r\n\t\t\"currencyTitle\": \"USDT\",\r\n\t\t\"networkTitle\": \"TRC20\"\r\n\t},\r\n\t\"instrumentTo\": {\r\n\t\t\"currencyTitle\": \"BTC\",\r\n\t\t\"networkTitle\": \"BTC\"\r\n\t},\r\n\t\"destinationAddress\": \"bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh\",\r\n\t\"destinationAddressMemo\": null,\r\n\t\"refundAddress\": null,\r\n\t\"refundAddressMemo\": null,\r\n\t\"claimedNetworkFee\": null,\r\n\t\"legacyOrderId\": null,\r\n\t\"referrerId\": \"aff_616\",\r\n\t\"claimedDepositAmount\": \"125000\",\r\n\t\"utmData\": [],\r\n\t\"browserFingerprint\": \"6b3add86bec11616427d069556a33548\"\r\n\t\"markup\": \"0.2\" \u002F\u002F &lt;-- here\r\n}\r\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>The \u003Cstrong>markup\u003C\u002Fstrong> multiplier value is passed alongside other parameters.\u003C\u002Fp>\n\u003Ch2>Using API v2\u003C\u002Fh2>\n\u003Cp>Using the \u003Cstrong>v2\u003C\u002Fstrong> API endpoints requires additional authorization setup. Without the necessary authorization parameters, \u003Cstrong>v2\u003C\u002Fstrong> endpoints will throw \u003Cstrong>403 Forbidden\u003C\u002Fstrong> errors.\u003Cbr \u002F>\nThe integration is composed of two steps – creating an API key and integrating its usage in the API requests. By creating an API key, our b2b customers will receive a key pair to sign their requests alongside a list of whitelisted IP addresses that can access the API endpoints.\u003C\u002Fp>\n\u003Cblockquote>\u003Cp>\u003Cb>Note:\u003C\u002Fb> you must have an active authorization cookie to perform \u003Cstrong>\u002Fapi\u002Fv1\u002Fusers\u002F*\u003C\u002Fstrong> requests.\u003C\u002Fp>\u003C\u002Fblockquote>\n\u003Ch3>Creating an API key\u003C\u002Fh3>\n\u003Cp>While creating the API key, an array of whitelisted IPs must be passed:\u003C\u002Fp>\n\u003Cpre>\u003Ccode>\r\nPOST \u002Fapi\u002Fv1\u002Fusers\u002Fgenerate-api-key\r\n\r\nRequest:\r\n{\r\n\t\"name\": \"test\",\r\n\t\"whiteListIp\": [\"127.0.0.1\"],\r\n\t\"isActive\": true\r\n}\r\n\r\nResponse:\r\n{\r\n\t\"apiId\": 40,\r\n\t\"name\": \"test\",\r\n\t\"isActive\": true,\r\n\t\"publicKey\": \"ZgzycV6Sf78BZKuyIAiz+0Bor002+0\u002Frx1gLKsmYCsY=\",\r\n\t\"secretKey\": \"a482a8e3a3ff9aeadefb11d3d8c11253e7e8412e05ef2b8599016cc87a64b7d6\",\r\n\t\"whiteListIp\": [\r\n\t\t\"127.0.0.1\"\r\n\t],\r\n\t\"createdAt\": \"2024-08-05T13:54:18.427Z\"\r\n}\r\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>The response will contain the key pair that is required to use during API \u003Cstrong>v2\u003C\u002Fstrong> authorization.\u003C\u002Fp>\n\u003Cblockquote>\u003Cp>\u003Cb>Note:\u003C\u002Fb> The \u003Cstrong>secretKey\u003C\u002Fstrong> field will be displayed only once, during API key creation. We advise to save it immediately after creating the API key.\u003C\u002Fp>\u003C\u002Fblockquote>\n\u003Ch3>Listing your API keys\u003C\u002Fh3>\n\u003Cp>If your integration requires more than one API key to be used, you can easily list them through the \u003Cstrong>list\u003C\u002Fstrong> endpoint:\u003C\u002Fp>\n\u003Cpre>\u003Ccode>\r\nGET \u002Fapi\u002Fv1\u002Fusers\u002Flist-api-key\r\n\r\n[\r\n\t{\r\n\t\t\"apiId\": 40,\r\n\t\t\"name\": \"test\",\r\n\t\t\"isActive\": true,\r\n\t\t\"settings\": {},\r\n\t\t\"publicKey\": \"ZgzycV6Sf78BZKuyIAiz+0Bor002+0\u002Frx1gLKsmYCsY=\",\r\n\t\t\"whiteListIp\": [\r\n\t\t\t\"127.0.0.1\"\r\n\t\t],\r\n\t\t\"createdAt\": \"2024-08-05T13:54:18.427Z\"\r\n\t}\r\n]\r\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Ch3>Managing your API keys\u003C\u002Fh3>\n\u003Cp>Managing existing API keys can be done through our b2b customer support line. This includes:\u003C\u002Fp>\n\u003Cul>\n\u003Cli>Deleting API keys\u003C\u002Fli>\n\u003Cli>Adding new whitelisted IPs to an existing API key\u003C\u002Fli>\n\u003Cli>Updating and adding settings for an API key (ex.: min\u002Fmax values for markup value)\u003C\u002Fli>\n\u003Cli>Deactivating API keys\u003C\u002Fli>\n\u003C\u002Ful>\n\u003Ch3>Using the API key\u003C\u002Fh3>\n\u003Cp>API \u003Cstrong>v2\u003C\u002Fstrong> requires 3 headers to be set on every request:\u003C\u002Fp>\n\u003Ctable>\n\u003Cthead>\n\u003Ctr>\n\u003Cth>Header\u003C\u002Fth>\n\u003Cth>Value\u003C\u002Fth>\n\u003C\u002Ftr>\n\u003C\u002Fthead>\n\u003Ctbody>\n\u003Ctr>\n\u003Ctd>\u003Cstrong>x-api-public-key\u003C\u002Fstrong>\u003C\u002Ftd>\n\u003Ctd>Your public key obtained during API key creation\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>\u003Cstrong>x-api-timestamp\u003C\u002Fstrong>\u003C\u002Ftd>\n\u003Ctd>UNIX timestamp\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>\u003Cstrong>x-api-signature\u003C\u002Fstrong>\u003C\u002Ftd>\n\u003Ctd>A signature of the request\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003C\u002Ftbody>\n\u003C\u002Ftable>\n\u003Cp>The signature value is generated using \u003Cstrong>hmac sha256\u003C\u002Fstrong>. The data passed is string concatenation of the timestamp, the string representation of the request body and the public key, while the private key is used as the key to the \u003Cstrong>hmac\u003C\u002Fstrong> function:\u003C\u002Fp>\n\u003Cpre>\u003Ccode>\r\nfunction signRequest(requestBody) {\r\n  const timestamp = new Date().getTime();\r\n  const publicKey = \"ZgzycV6Sf78BZKuyIAiz+0Bor002+0\u002Frx1gLKsmYCsY=\";\r\n\tconst privateKey = \"a482a8e3a3ff9aeadefb11d3d8c11253e7e8412e05ef2b8599016cc87a64b7d6\";\r\n\t\r\n\tconst encoder = new TextEncoder();\r\n\tconst data = encoder.encode(\r\n\t\ttimestamp + JSON.stringify(requestBody) + publicKey,\r\n\t);\r\n\t\r\n\tconst hmac = createHmac('sha256', privateKey);\r\n\tconst dataSign = hmac.update(data);\r\n\tconst signature = dataSign.digest('base64');\r\n\t\r\n\treturn signature;\r\n}\r\n\r\nsignRequest({ myKey: \"myValue\" })\r\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Ch2>Sample integration code\u003C\u002Fh2>\n\u003Cpre>\u003Ccode>\r\nconst { createHmac } = require('crypto');\r\n\r\nconst API_PREFIX = 'https:\u002F\u002Fs\u003Cspan class=\"Y2IQFc\" lang=\"en\">wapgate\u003C\u002Fspan>.io\u002Fapi\u002F';\r\nconst PUBKEY = 'public_key'; \u002F\u002F changeme\r\nconst PRIVKEY = 'private_key'; \u002F\u002F changeme\r\n\r\nfunction signRequest(requestBody, timestamp) {\r\n  const encoder = new TextEncoder();\r\n  const data = encoder.encode(timestamp + JSON.stringify(requestBody) + PUBKEY);\r\n\r\n  const hmac = createHmac('sha256', PRIVKEY);\r\n  const dataSign = hmac.update(data);\r\n  const signature = dataSign.digest('base64');\r\n\r\n  return signature;\r\n}\r\n\r\nasync function createOrder() {\r\n  const clientBrowserFingerprint = '6b3add86bec11616427d069556a33548';\r\n  const orderRateMode = 'FLOATING';\r\n  const depositAmount = '1';\r\n  const clientDestinationAddress = 'TUhw6S1HyXDhycKvTec3x7HNGQfNn3Vhpc';\r\n  const clientDestinationAddressMemo = null;\r\n  const markup = '0.3';\r\n  const instrumentFromCurrencyTitle = 'BTC';\r\n  const instrumentFromNetworkTitle = 'BTC';\r\n\r\n  const instrumentToCurrencyTitle = 'USDT';\r\n  const instrumentToNetworkTitle = 'TRC20';\r\n\r\n  \u002F\u002F Step 1. Prepate createOrder request body using obtained rate data\r\n\r\n  const createOrderRequestBody = {\r\n    rateMode: orderRateMode,\r\n    instrumentFrom: {\r\n      currencyTitle: instrumentFromCurrencyTitle,\r\n      networkTitle: instrumentFromNetworkTitle,\r\n    },\r\n    instrumentTo: {\r\n      currencyTitle: instrumentToCurrencyTitle,\r\n      networkTitle: instrumentToNetworkTitle,\r\n    },\r\n    destinationAddress: clientDestinationAddress,\r\n    destinationAddressMemo: clientDestinationAddressMemo,\r\n    refundAddress: null,\r\n    refundAddressMemo: null,\r\n    markup: markup,\r\n    claimedNetworkFee: null,\r\n    legacyOrderId: null,\r\n    referrerId: null,\r\n    claimedDepositAmount: depositAmount,\r\n    utmData: [],\r\n    browserFingerprint: clientBrowserFingerprint,\r\n  };\r\n\r\n  \u002F\u002F Step 2. Prepare signature based on key pair and createOrder request data\r\n\r\n  const timestamp = new Date().getTime();\r\n  const signature = signRequest(createOrderRequestBody, timestamp);\r\n\r\n  \u002F\u002F Step 3. Call API v2 create-order endpoint\r\n\r\n  const order = JSON.parse(\r\n    await (\r\n      await fetch(`${API_PREFIX}v2\u002Forders\u002Fpublic\u002Fcreate`, {\r\n        method: 'POST',\r\n        headers: {\r\n          'x-api-public-key': PUBKEY,\r\n          'x-api-timestamp': timestamp,\r\n          'x-api-signature': signature,\r\n          'content-type': 'application\u002Fjson; charset=utf-8',\r\n        },\r\n        body: JSON.stringify(createOrderRequestBody),\r\n      })\r\n    ).text(),\r\n  );\r\n\r\n  console.log('order', order);\r\n}\r\n\r\nvoid createOrder();\r\n\u003C\u002Fcode>\u003C\u002Fpre>\n",{"code":5},[19],{"language":20,"slug":13,"status":15},{"code":6,"locale":21,"name":22,"slug":23},"ru_RU","Русский","ru",{"canonical":25,"metaDesc":26,"readingTime":27,"opengraphTitle":28,"opengraphUrl":25,"opengraphImage":29,"twitterImage":29,"opengraphDescription":26,"twitterDescription":30,"title":28,"twitterTitle":30,"opengraphType":31,"opengraphPublishedTime":30,"opengraphModifiedTime":32},"https:\u002F\u002Fswapgate.io\u002Fdocs\u002Fapiv2\u002F","Modern API with enhanced features. Full reference with usage examples, integration tips, and request formats.",4,"API v2: Guide and Examples",null,"","article","2025-04-14T09:31:16+00:00",{"afterDescription":29,"apiEndpoints":29},{"notation":29}]