Notus API
Swaps

Create Swap

This endpoint provides a real-time quote for a token swap, detailing the estimated destination token amount, fees, and other relevant parameters.

POST
/api/v1/crypto/swap
x-api-key<token>

In: header

amountInstring

The amount to be swapped, expressed as a decimal string. Example: "1.2".

chainIdInnumber

The blockchain network where the swap originates. Supported chains:

  • Arbitrum One: 42161
  • Avalanche: 43114
  • Base: 8453
  • BNB Smart Chain: 56
  • Ethereum: 1
  • OP Mainnet: 10
  • Polygon: 137
  • Gnosis: 100
chainIdOutnumber

The blockchain network where the swapped asset will be sent to. Supported chains:

  • Arbitrum One: 42161
  • Avalanche: 43114
  • Base: 8453
  • BNB Smart Chain: 56
  • Ethereum: 1
  • OP Mainnet: 10
  • Polygon: 137
  • Gnosis: 100
swapProviders?array<string>

Optional array of providers for the quote process. - Scenario 1: If not provided and the swap is within the same chain, the default provider will be "ODOS". - Scenario 2: If not provided and the swap is cross-chain, the default provider will be "RANGO". - Scenario 3: If an array is provided (e.g., ["XY", "LIFI", "PARASWAP"]), a quote will be performed for each specified provider.

gasFeePaymentMethodstring

Defines how the fee will be paid: "ADD_TO_AMOUNT" adds it to the input amount, while "DEDUCT_FROM_AMOUNT" subtracts it from the input amount.

Value in"ADD_TO_AMOUNT" | "DEDUCT_FROM_AMOUNT"
payGasFeeTokenstring

The token address (in hexadecimal format) used to pay the transaction fee.

Match^0x[a-fA-F0-9]{40}$
tokenInstring

The address (in hexadecimal format) of the token being swapped from.

Match^0x[a-fA-F0-9]{40}$
tokenOutstring

The address (in hexadecimal format) of the token being swapped to.

Match^0x[a-fA-F0-9]{40}$
walletAddressstring

The wallet address (in hexadecimal format) initiating the swap.

Match^0x[a-fA-F0-9]{40}$
toAddressstring

The address (in hexadecimal format) receiving the swap.

Match^0x[a-fA-F0-9]{40}$
transactionFeePercent?number

Percentage fee to be charged (0 to 99%). The fee is deducted from the input token and sent to the treasuryAddress if configured.

Rangevalue <= 99.99
slippage?number

Optional parameter controlling the maximum deviation allowed of the expected price of a trade and the actual price at which the trade is executed, with a minimum value of 0.5 and a maximum value of 99, default is 0.5, where 1 unit equals 1%.

Default0.5
Range0.5 <= value <= 99
metadata?object

Custom metadata for the transaction. Key-value pairs with string values. Max 1KB size.

Empty Object

Response Body

curl -X POST "https://api.notus.team/api/v1/crypto/swap" \
  -H "Content-Type: application/json" \
  -d '{
    "amountIn": "string",
    "chainIdIn": 0,
    "chainIdOut": 0,
    "gasFeePaymentMethod": "ADD_TO_AMOUNT",
    "payGasFeeToken": "string",
    "tokenIn": "string",
    "tokenOut": "string",
    "walletAddress": "string",
    "toAddress": "string"
  }'
const body = JSON.stringify({
  "amountIn": "string",
  "chainIdIn": 0,
  "chainIdOut": 0,
  "gasFeePaymentMethod": "ADD_TO_AMOUNT",
  "payGasFeeToken": "string",
  "tokenIn": "string",
  "tokenOut": "string",
  "walletAddress": "string",
  "toAddress": "string"
})

fetch("https://api.notus.team/api/v1/crypto/swap", {
  body
})
package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
  "strings"
)

func main() {
  url := "https://api.notus.team/api/v1/crypto/swap"
  body := strings.NewReader(`{
    "amountIn": "string",
    "chainIdIn": 0,
    "chainIdOut": 0,
    "gasFeePaymentMethod": "ADD_TO_AMOUNT",
    "payGasFeeToken": "string",
    "tokenIn": "string",
    "tokenOut": "string",
    "walletAddress": "string",
    "toAddress": "string"
  }`)
  req, _ := http.NewRequest("POST", url, body)
  req.Header.Add("Content-Type", "application/json")
  res, _ := http.DefaultClient.Do(req)
  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))
}
import requests

url = "https://api.notus.team/api/v1/crypto/swap"
body = {
  "amountIn": "string",
  "chainIdIn": 0,
  "chainIdOut": 0,
  "gasFeePaymentMethod": "ADD_TO_AMOUNT",
  "payGasFeeToken": "string",
  "tokenIn": "string",
  "tokenOut": "string",
  "walletAddress": "string",
  "toAddress": "string"
}
response = requests.request("POST", url, json = body, headers = {
  "Content-Type": "application/json"
})

print(response.text)
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.http.HttpResponse.BodyHandlers;
import java.time.Duration;
import java.net.http.HttpRequest.BodyPublishers;

var body = BodyPublishers.ofString("""{
  "amountIn": "string",
  "chainIdIn": 0,
  "chainIdOut": 0,
  "gasFeePaymentMethod": "ADD_TO_AMOUNT",
  "payGasFeeToken": "string",
  "tokenIn": "string",
  "tokenOut": "string",
  "walletAddress": "string",
  "toAddress": "string"
}""");
HttpClient client = HttpClient.newBuilder()
  .connectTimeout(Duration.ofSeconds(10))
  .build();

HttpRequest.Builder requestBuilder = HttpRequest.newBuilder()
  .uri(URI.create("https://api.notus.team/api/v1/crypto/swap"))
  .header("Content-Type", "application/json")
  .POST(body)
  .build();

try {
  HttpResponse<String> response = client.send(requestBuilder.build(), BodyHandlers.ofString());
  System.out.println("Status code: " + response.statusCode());
  System.out.println("Response body: " + response.body());
} catch (Exception e) {
  e.printStackTrace();
}
using System;
using System.Net.Http;
using System.Text;

var body = new StringContent("""
{
  "amountIn": "string",
  "chainIdIn": 0,
  "chainIdOut": 0,
  "gasFeePaymentMethod": "ADD_TO_AMOUNT",
  "payGasFeeToken": "string",
  "tokenIn": "string",
  "tokenOut": "string",
  "walletAddress": "string",
  "toAddress": "string"
}
""", Encoding.UTF8, "application/json");

var client = new HttpClient();
var response = await client.PostAsync("https://api.notus.team/api/v1/crypto/swap", body);
var responseBody = await response.Content.ReadAsStringAsync();
{
  "quotes": [
    {
      "metadata": {
        "key": "value"
      },
      "quoteId": "string",
      "userOperationHash": "string",
      "walletAddress": "string",
      "tokenIn": "string",
      "amountIn": "string",
      "tokenOut": "string",
      "chainIn": 0,
      "chainOut": 0,
      "minAmountOut": "string",
      "estimatedGasFees": {
        "payGasFeeToken": "string",
        "maxGasFeeToken": "string",
        "gasFeeTokenAmount": "string",
        "gasFeeTokenAmountUSD": "string",
        "maxGasFeeNative": "string"
      },
      "estimatedCollectedFee": {
        "collectedFeeToken": "string",
        "collectedFee": "string",
        "collectedFeePercent": "string",
        "notusCollectedFee": "string",
        "notusCollectedFeePercent": "string"
      },
      "amountInUSD": "string",
      "amountOutUSD": "string",
      "tokenInPrice": "string",
      "swapProvider": "PARASWAP",
      "expiresAt": 0
    }
  ]
}
{
  "statusCode": 400,
  "id": "NOT_AUTHORIZED_TOKENS",
  "message": "The tokens '[0x]' are not authorized yet."
}
{
  "statusCode": 500,
  "id": "SWAP_QUOTE",
  "message": "Failed to get a swap quote. Please try again later"
}