price
API reference to fetch an indicative price for a swap.
Query parameters
sellTokenstringRequiredExample:
Address of the sell token
0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48buyTokenstringRequiredExample:
Address of the buy token
0x2260fac5e5542a773aa44fbcfedf7c193bc2c599sellAmountstringRequiredExample:
Sell amount in token base units (e.g. Wei for ETH)
1000000000000Header parameters
x-api-keystringOptional
31Third API key (Request via dev@31third.com)
chain-idstringOptional
Chain ID as hex string. (e.g.: 0x1 for Ethereum mainnet)
Responses
200Success
application/json
idstringRequiredExample:
Unique ID of the calculated swap price.
0096124c-19df-4459-8cbb-7615fdc7c157sellAmountinteger · int64RequiredExample:
Amount to sell. (In sell token units)
100000000buyAmountinteger · int64RequiredExample:
Estimated buy amount. (In buy token units)
99500000pricenumberRequiredExample:
Price of the buy token in sell token. E.g. 1 BTC = 100.000 USD; you sell WBTC and buy USDC; the price is 0.000001
0.999955priceImpactBpsnumber · min: -10000 · max: 10000RequiredExample:
Estimated price impact in basis points. [-10_000;10_000]. > 0 = value loss. < 0 = value gain
31get/1.3/swap/price
GET /1.3/swap/price?sellToken=0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48&buyToken=0x2260fac5e5542a773aa44fbcfedf7c193bc2c599&sellAmount=1000000000000 HTTP/1.1
Accept: */*
200Success
{
"id": "0096124c-19df-4459-8cbb-7615fdc7c157",
"sellToken": "0xdac17f958d2ee523a2206206994597c13d831ec7",
"buyToken": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"sellAmount": "100000000",
"buyAmount": "99500000",
"price": 0.999955,
"priceImpactBps": 31
}Last updated