Swap

Swap tokens at the best pricing available.
post
https://api.totle.com
/swap
/swap
Swap Vs Swaps - Executing Multiple Swaps in One Call To execute multiple swaps, submit a request using the swaps array of objects, where each object within the array contains information about a single swap (i.e., to swap two token pairs, include two objects within the swaps array).
cURL
Node
Ruby
JavaScript
Python
curl -X POST \
https://api.totle.com/swap \
-H 'content-type: Application/JSON' \
-d '{
"swap":{
"sourceAsset":"ETH",
"destinationAsset":"DAI",
"sourceAmount":"1000000000000000000",
"maxMarketSlippagePercent":"10",
"maxExecutionSlippagePercent":"3"
}
}'
var request = require("request")
var body = {
"swap":{
"sourceAsset":"ETH",
"destinationAsset":"DAI",
"sourceAmount":"1000000000000000000",
"maxMarketSlippagePercent":"10",
"maxExecutionSlippagePercent":"3"
}
}
var options = {
method: 'POST',
url: 'https://api.totle.com/swap',
headers: {'content-type': 'application/json'},
body: JSON.stringify(body)
}
request(options, function (error, response, body) {
if (error) throw new Error(error)
console.log(body)
})
require 'uri'
require 'net/http'
url = URI("https://api.totle.com/swap")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["content-type"] = 'Application/JSON'
request.body = "{\"swap\":{\"sourceAsset\":\"ETH\",\"destinationAsset\":\"DAI\",\"sourceAmount\":\"1000000000000000000\",\"maxMarketSlippagePercent\":\"10\",\"maxExecutionSlippagePercent\":\"3\"}}"
response = http.request(request)
puts response.read_body
var data = "{\"swap\":{\"sourceAsset\":\"ETH\",\"destinationAsset\":\"DAI\",\"sourceAmount\":\"1000000000000000000\",\"maxMarketSlippagePercent\":\"10\",\"maxExecutionSlippagePercent\":\"3\"}}";
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://api.totle.com/swap");
xhr.send(data);
import requests
url = "https://api.totle.com/swap"
payload = "{\"swap\":{\"sourceAsset\":\"ETH\",\"destinationAsset\":\"DAI\",\"sourceAmount\":\"1000000000000000000\",\"maxMarketSlippagePercent\":\"10\",\"maxExecutionSlippagePercent\":\"3\"}}"
headers = {
'content-type': "Application/JSON"
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
Last modified 2yr ago