Produce swap instruction (calldata) for client execution
curl --request POST \
--url https://api.fiet.finance/v1/swap \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"chainId": 1,
"tokenIn": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"tokenOut": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
"tradeType": "EXACT_IN",
"amount": "1000000",
"slippageBps": 50
}
'import requests
url = "https://api.fiet.finance/v1/swap"
payload = {
"chainId": 1,
"tokenIn": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"tokenOut": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
"tradeType": "EXACT_IN",
"amount": "1000000",
"slippageBps": 50
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({
chainId: 1,
tokenIn: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
tokenOut: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
tradeType: 'EXACT_IN',
amount: '1000000',
slippageBps: 50
})
};
fetch('https://api.fiet.finance/v1/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.fiet.finance/v1/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([
'chainId' => 1,
'tokenIn' => '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
'tokenOut' => '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
'tradeType' => 'EXACT_IN',
'amount' => '1000000',
'slippageBps' => 50
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"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.fiet.finance/v1/swap"
payload := strings.NewReader("{\n \"chainId\": 1,\n \"tokenIn\": \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n \"tokenOut\": \"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\",\n \"tradeType\": \"EXACT_IN\",\n \"amount\": \"1000000\",\n \"slippageBps\": 50\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
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.fiet.finance/v1/swap")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"chainId\": 1,\n \"tokenIn\": \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n \"tokenOut\": \"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\",\n \"tradeType\": \"EXACT_IN\",\n \"amount\": \"1000000\",\n \"slippageBps\": 50\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.fiet.finance/v1/swap")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"chainId\": 1,\n \"tokenIn\": \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n \"tokenOut\": \"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\",\n \"tradeType\": \"EXACT_IN\",\n \"amount\": \"1000000\",\n \"slippageBps\": 50\n}"
response = http.request(request)
puts response.read_body{
"quote": {
"asOf": {
"timestamp": "2023-11-07T05:31:56Z",
"blockNumber": 123
},
"expiresAt": "2023-11-07T05:31:56Z",
"chainId": 123,
"tokenIn": "<string>",
"tokenOut": "<string>",
"amountIn": "<string>",
"amountOut": "<string>",
"fees": {},
"route": {}
},
"instructions": [
{
"kind": "EVM_CALL",
"chainId": 123,
"to": "<string>",
"data": "<string>",
"value": "<string>",
"constraints": {
"notAfter": "2023-11-07T05:31:56Z",
"maxSlippageBps": 2500
}
}
]
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"detail": "<string>"
}API Reference
Swap
POST
/
v1
/
swap
Produce swap instruction (calldata) for client execution
curl --request POST \
--url https://api.fiet.finance/v1/swap \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"chainId": 1,
"tokenIn": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"tokenOut": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
"tradeType": "EXACT_IN",
"amount": "1000000",
"slippageBps": 50
}
'import requests
url = "https://api.fiet.finance/v1/swap"
payload = {
"chainId": 1,
"tokenIn": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"tokenOut": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
"tradeType": "EXACT_IN",
"amount": "1000000",
"slippageBps": 50
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({
chainId: 1,
tokenIn: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
tokenOut: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
tradeType: 'EXACT_IN',
amount: '1000000',
slippageBps: 50
})
};
fetch('https://api.fiet.finance/v1/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.fiet.finance/v1/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([
'chainId' => 1,
'tokenIn' => '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
'tokenOut' => '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
'tradeType' => 'EXACT_IN',
'amount' => '1000000',
'slippageBps' => 50
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"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.fiet.finance/v1/swap"
payload := strings.NewReader("{\n \"chainId\": 1,\n \"tokenIn\": \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n \"tokenOut\": \"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\",\n \"tradeType\": \"EXACT_IN\",\n \"amount\": \"1000000\",\n \"slippageBps\": 50\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
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.fiet.finance/v1/swap")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"chainId\": 1,\n \"tokenIn\": \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n \"tokenOut\": \"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\",\n \"tradeType\": \"EXACT_IN\",\n \"amount\": \"1000000\",\n \"slippageBps\": 50\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.fiet.finance/v1/swap")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"chainId\": 1,\n \"tokenIn\": \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n \"tokenOut\": \"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\",\n \"tradeType\": \"EXACT_IN\",\n \"amount\": \"1000000\",\n \"slippageBps\": 50\n}"
response = http.request(request)
puts response.read_body{
"quote": {
"asOf": {
"timestamp": "2023-11-07T05:31:56Z",
"blockNumber": 123
},
"expiresAt": "2023-11-07T05:31:56Z",
"chainId": 123,
"tokenIn": "<string>",
"tokenOut": "<string>",
"amountIn": "<string>",
"amountOut": "<string>",
"fees": {},
"route": {}
},
"instructions": [
{
"kind": "EVM_CALL",
"chainId": 123,
"to": "<string>",
"data": "<string>",
"value": "<string>",
"constraints": {
"notAfter": "2023-11-07T05:31:56Z",
"maxSlippageBps": 2500
}
}
]
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"detail": "<string>"
}This endpoint returns swap instructions (calldata + constraints) for you to execute.
For execution options, see Swap.
Authorizations
Basic Auth (assumed at gateway for MVP)
Body
application/json
Example:
1
Pattern:
^0x[a-fA-F0-9]{40}$Example:
"0x742d35Cc6634C0532925a3b844Bc9e7595f5fE4b"
Pattern:
^0x[a-fA-F0-9]{40}$Example:
"0x742d35Cc6634C0532925a3b844Bc9e7595f5fE4b"
Available options:
EXACT_IN, EXACT_OUT Amount (smallest units as string). Interpretation depends on tradeType.
Example:
"1000000"
Required range:
0 <= x <= 5000Recipient address for swap outputs (when applicable)
Pattern:
^0x[a-fA-F0-9]{40}$Example:
"0x742d35Cc6634C0532925a3b844Bc9e7595f5fE4b"
Response
Swap plan
Show child attributes
Show child attributes
Ordered list of on-chain instructions required to complete the plan.
Notes:
- For same-chain swaps, this will usually contain exactly 1 instruction.
- Future upgrades (e.g. approvals, multi-call routers, cross-chain) can return 2+ items.
Show child attributes
Show child attributes
⌘I