Quote a convert before proposing it
curl --request POST \
--url https://api.tuyo.com/public/action_quotes \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Tuyo-API-Version: <tuyo-api-version>' \
--data '
{
"intent": {
"kind": "<unknown>",
"from": "<unknown>",
"to": "<unknown>",
"amountIn": "<unknown>"
}
}
'import requests
url = "https://api.tuyo.com/public/action_quotes"
payload = { "intent": {
"kind": "<unknown>",
"from": "<unknown>",
"to": "<unknown>",
"amountIn": "<unknown>"
} }
headers = {
"Tuyo-API-Version": "<tuyo-api-version>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Tuyo-API-Version': '<tuyo-api-version>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
intent: {kind: '<unknown>', from: '<unknown>', to: '<unknown>', amountIn: '<unknown>'}
})
};
fetch('https://api.tuyo.com/public/action_quotes', 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.tuyo.com/public/action_quotes",
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([
'intent' => [
'kind' => '<unknown>',
'from' => '<unknown>',
'to' => '<unknown>',
'amountIn' => '<unknown>'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"Tuyo-API-Version: <tuyo-api-version>"
],
]);
$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.tuyo.com/public/action_quotes"
payload := strings.NewReader("{\n \"intent\": {\n \"kind\": \"<unknown>\",\n \"from\": \"<unknown>\",\n \"to\": \"<unknown>\",\n \"amountIn\": \"<unknown>\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Tuyo-API-Version", "<tuyo-api-version>")
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.tuyo.com/public/action_quotes")
.header("Tuyo-API-Version", "<tuyo-api-version>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"intent\": {\n \"kind\": \"<unknown>\",\n \"from\": \"<unknown>\",\n \"to\": \"<unknown>\",\n \"amountIn\": \"<unknown>\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tuyo.com/public/action_quotes")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Tuyo-API-Version"] = '<tuyo-api-version>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"intent\": {\n \"kind\": \"<unknown>\",\n \"from\": \"<unknown>\",\n \"to\": \"<unknown>\",\n \"amountIn\": \"<unknown>\"\n }\n}"
response = http.request(request)
puts response.read_body{
"kind": "convert",
"from": {
"assetId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"networkId": "<unknown>",
"symbol": "<string>",
"amount": "<unknown>",
"usdValue": "<unknown>"
},
"to": {
"assetId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"networkId": "<unknown>",
"symbol": "<string>",
"estimatedAmount": "<unknown>",
"usdValue": "<unknown>"
},
"fee": {
"amount": "<unknown>",
"symbol": "<string>",
"usdValue": "<unknown>"
},
"valueLossPercent": "<unknown>",
"quotedAt": "2023-11-07T05:31:56Z"
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true
},
"meta": {
"requestId": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true
},
"meta": {
"requestId": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true
},
"meta": {
"requestId": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true
},
"meta": {
"requestId": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true
},
"meta": {
"requestId": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true
},
"meta": {
"requestId": "<string>"
}
}API Reference
Quote a convert before proposing it
Dry-runs the convert intent POST /action_proposals takes, the way approval in Tuyo would build it: the same route, fee and on-chain simulation, with nothing saved and no funds reserved. from.amount is everything that leaves the balance, fee included; to.estimatedAmount is what the route is expected to deliver; slippage can leave less. valueLossPercent compares the USD value of the two, so a high one flags a poor route or an amount too small for its fee. The quote is not held: approval quotes again. 422 codes: no_route, insufficient_balance, simulation_failed (the operation would revert) and action_unavailable (unknown token, or conversions not enabled).
POST
/
action_quotes
Quote a convert before proposing it
curl --request POST \
--url https://api.tuyo.com/public/action_quotes \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Tuyo-API-Version: <tuyo-api-version>' \
--data '
{
"intent": {
"kind": "<unknown>",
"from": "<unknown>",
"to": "<unknown>",
"amountIn": "<unknown>"
}
}
'import requests
url = "https://api.tuyo.com/public/action_quotes"
payload = { "intent": {
"kind": "<unknown>",
"from": "<unknown>",
"to": "<unknown>",
"amountIn": "<unknown>"
} }
headers = {
"Tuyo-API-Version": "<tuyo-api-version>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Tuyo-API-Version': '<tuyo-api-version>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
intent: {kind: '<unknown>', from: '<unknown>', to: '<unknown>', amountIn: '<unknown>'}
})
};
fetch('https://api.tuyo.com/public/action_quotes', 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.tuyo.com/public/action_quotes",
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([
'intent' => [
'kind' => '<unknown>',
'from' => '<unknown>',
'to' => '<unknown>',
'amountIn' => '<unknown>'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"Tuyo-API-Version: <tuyo-api-version>"
],
]);
$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.tuyo.com/public/action_quotes"
payload := strings.NewReader("{\n \"intent\": {\n \"kind\": \"<unknown>\",\n \"from\": \"<unknown>\",\n \"to\": \"<unknown>\",\n \"amountIn\": \"<unknown>\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Tuyo-API-Version", "<tuyo-api-version>")
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.tuyo.com/public/action_quotes")
.header("Tuyo-API-Version", "<tuyo-api-version>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"intent\": {\n \"kind\": \"<unknown>\",\n \"from\": \"<unknown>\",\n \"to\": \"<unknown>\",\n \"amountIn\": \"<unknown>\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tuyo.com/public/action_quotes")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Tuyo-API-Version"] = '<tuyo-api-version>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"intent\": {\n \"kind\": \"<unknown>\",\n \"from\": \"<unknown>\",\n \"to\": \"<unknown>\",\n \"amountIn\": \"<unknown>\"\n }\n}"
response = http.request(request)
puts response.read_body{
"kind": "convert",
"from": {
"assetId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"networkId": "<unknown>",
"symbol": "<string>",
"amount": "<unknown>",
"usdValue": "<unknown>"
},
"to": {
"assetId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"networkId": "<unknown>",
"symbol": "<string>",
"estimatedAmount": "<unknown>",
"usdValue": "<unknown>"
},
"fee": {
"amount": "<unknown>",
"symbol": "<string>",
"usdValue": "<unknown>"
},
"valueLossPercent": "<unknown>",
"quotedAt": "2023-11-07T05:31:56Z"
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true
},
"meta": {
"requestId": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true
},
"meta": {
"requestId": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true
},
"meta": {
"requestId": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true
},
"meta": {
"requestId": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true
},
"meta": {
"requestId": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true
},
"meta": {
"requestId": "<string>"
}
}Headers
Response
The quote.