Create a new instant swap order
curl --request POST \
--url https://api.openxswitch.com/v1/instant-swap \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"walletId": "wallet_abc123",
"fromCoin": "USDT",
"fromAmount": 100,
"toCoin": "ETH",
"extId": "<string>",
"instantSync": false
}
'import requests
url = "https://api.openxswitch.com/v1/instant-swap"
payload = {
"walletId": "wallet_abc123",
"fromCoin": "USDT",
"fromAmount": 100,
"toCoin": "ETH",
"extId": "<string>",
"instantSync": False
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
walletId: 'wallet_abc123',
fromCoin: 'USDT',
fromAmount: 100,
toCoin: 'ETH',
extId: '<string>',
instantSync: false
})
};
fetch('https://api.openxswitch.com/v1/instant-swap', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.openxswitch.com/v1/instant-swap",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'walletId' => 'wallet_abc123',
'fromCoin' => 'USDT',
'fromAmount' => 100,
'toCoin' => 'ETH',
'extId' => '<string>',
'instantSync' => false
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.openxswitch.com/v1/instant-swap"
payload := strings.NewReader("{\n \"walletId\": \"wallet_abc123\",\n \"fromCoin\": \"USDT\",\n \"fromAmount\": 100,\n \"toCoin\": \"ETH\",\n \"extId\": \"<string>\",\n \"instantSync\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.openxswitch.com/v1/instant-swap")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"walletId\": \"wallet_abc123\",\n \"fromCoin\": \"USDT\",\n \"fromAmount\": 100,\n \"toCoin\": \"ETH\",\n \"extId\": \"<string>\",\n \"instantSync\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.openxswitch.com/v1/instant-swap")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"walletId\": \"wallet_abc123\",\n \"fromCoin\": \"USDT\",\n \"fromAmount\": 100,\n \"toCoin\": \"ETH\",\n \"extId\": \"<string>\",\n \"instantSync\": false\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"id": "swap_abc123",
"extId": "ext_abc123",
"fee": "0.0",
"fromCoin": "USDT",
"fromAmount": "100",
"toCoin": "ETH",
"toAmount": "0.0234",
"swapPrice": "0.000234",
"ts": "2025-04-04T12:00:00Z",
"quoteId": "quote123",
"walletId": "wallet_001"
}
}{
"statusCode": 400,
"path": "/v1/...",
"timestamp": "2025-03-13T12:34:56.789Z",
"message": "......"
}{
"statusCode": 404,
"path": "/v1/...",
"timestamp": "2025-03-13T12:34:56.789Z",
"message": "Cannot GET /v1/..."
}{
"statusCode": 422,
"path": "/v1/...",
"timestamp": "2025-03-13T12:34:56.789Z",
"message": [
"param is required"
]
}{
"statusCode": 500,
"path": "/v1/...",
"timestamp": "2025-03-13T12:34:56.789Z",
"message": "......"
}Instant-swap Endpoints
Create a new instant swap order
Executes an instant swap based on a previously fetched quote or directly using coin and amount inputs. Returns swap confirmation with details.
POST
/
v1
/
instant-swap
Create a new instant swap order
curl --request POST \
--url https://api.openxswitch.com/v1/instant-swap \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"walletId": "wallet_abc123",
"fromCoin": "USDT",
"fromAmount": 100,
"toCoin": "ETH",
"extId": "<string>",
"instantSync": false
}
'import requests
url = "https://api.openxswitch.com/v1/instant-swap"
payload = {
"walletId": "wallet_abc123",
"fromCoin": "USDT",
"fromAmount": 100,
"toCoin": "ETH",
"extId": "<string>",
"instantSync": False
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
walletId: 'wallet_abc123',
fromCoin: 'USDT',
fromAmount: 100,
toCoin: 'ETH',
extId: '<string>',
instantSync: false
})
};
fetch('https://api.openxswitch.com/v1/instant-swap', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.openxswitch.com/v1/instant-swap",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'walletId' => 'wallet_abc123',
'fromCoin' => 'USDT',
'fromAmount' => 100,
'toCoin' => 'ETH',
'extId' => '<string>',
'instantSync' => false
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.openxswitch.com/v1/instant-swap"
payload := strings.NewReader("{\n \"walletId\": \"wallet_abc123\",\n \"fromCoin\": \"USDT\",\n \"fromAmount\": 100,\n \"toCoin\": \"ETH\",\n \"extId\": \"<string>\",\n \"instantSync\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.openxswitch.com/v1/instant-swap")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"walletId\": \"wallet_abc123\",\n \"fromCoin\": \"USDT\",\n \"fromAmount\": 100,\n \"toCoin\": \"ETH\",\n \"extId\": \"<string>\",\n \"instantSync\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.openxswitch.com/v1/instant-swap")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"walletId\": \"wallet_abc123\",\n \"fromCoin\": \"USDT\",\n \"fromAmount\": 100,\n \"toCoin\": \"ETH\",\n \"extId\": \"<string>\",\n \"instantSync\": false\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"id": "swap_abc123",
"extId": "ext_abc123",
"fee": "0.0",
"fromCoin": "USDT",
"fromAmount": "100",
"toCoin": "ETH",
"toAmount": "0.0234",
"swapPrice": "0.000234",
"ts": "2025-04-04T12:00:00Z",
"quoteId": "quote123",
"walletId": "wallet_001"
}
}{
"statusCode": 400,
"path": "/v1/...",
"timestamp": "2025-03-13T12:34:56.789Z",
"message": "......"
}{
"statusCode": 404,
"path": "/v1/...",
"timestamp": "2025-03-13T12:34:56.789Z",
"message": "Cannot GET /v1/..."
}{
"statusCode": 422,
"path": "/v1/...",
"timestamp": "2025-03-13T12:34:56.789Z",
"message": [
"param is required"
]
}{
"statusCode": 500,
"path": "/v1/...",
"timestamp": "2025-03-13T12:34:56.789Z",
"message": "......"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
Wallet/Sub-wallet ID
Example:
"wallet_abc123"
Source coin symbol
Example:
"USDT"
Amount to swap from
Example:
100
Target coin symbol
Example:
"ETH"
External reference ID from client's system.
Immediately sync wallet asset instead of queuing the sync job (default is queued)
Example:
false
⌘I
.png?fit=max&auto=format&n=ML35RDblT1Ol-zJb&q=85&s=062e79ad9c4540929eec204aff020178)
.png?fit=max&auto=format&n=ML35RDblT1Ol-zJb&q=85&s=f6328956931c9664a2a070c2edb6e9b3)