Price API
๐ endpointโ
GET https://alpha.clober.io/api/price/{tokenAddress}
{tokenAddress}
: the ERC-20 address you want priced.- Quoted currency is always USDC.
- Default quote size is 1 USDC (
1000000
in 6 decimals).
๐ฆ example requestโ
GET https://alpha.clober.io/api/price/0xB5a30b0FDc5EA94A52fDc42e3E9760Cb8449Fb37
๐งช minimal typeScript usageโ
import axios from 'axios'
async function getUsdPrice(tokenAddress: string) {
const { data } = await axios.get(
`https://alpha.clober.io/api/price/${tokenAddress}`
)
return data.usdPrice as string
}
๐ sample responseโ
{
"usdPrice": "3868.194388443900535173",
"currency": {
"address": "0xB5a30b0FDc5EA94A52fDc42e3E9760Cb8449Fb37",
"name": "Wrapped ETH",
"symbol": "WETH",
"decimals": 18
},
"source": [
{
"amountIn": "1000000",
"inputCurrency": {
"address": "0xf817257fed379853cDe0fa4F97AB987181B1E5Ea",
"name": "USD Coin",
"symbol": "USDC",
"decimals": 6
},
"amountOut": "258518548857696",
"outputCurrency": {
"address": "0xB5a30b0FDc5EA94A52fDc42e3E9760Cb8449Fb37",
"name": "Wrapped ETH",
"symbol": "WETH",
"decimals": 18
},
"usdPrice": "3868.194388443900535173",
"aggregator": "OpenOcean",
"executionMilliseconds": 333.387489999877
},
{
"amountIn": "1000000",
"inputCurrency": {
"address": "0xf817257fed379853cDe0fa4F97AB987181B1E5Ea",
"name": "USD Coin",
"symbol": "USDC",
"decimals": 6
},
"amountOut": "256998637574201",
"outputCurrency": {
"address": "0xB5a30b0FDc5EA94A52fDc42e3E9760Cb8449Fb37",
"name": "Wrapped ETH",
"symbol": "WETH",
"decimals": 18
},
"usdPrice": "3891.071211267719756112",
"aggregator": "Monorail",
"executionMilliseconds": 848.055464999983
}
]
}
usdPrice
: final price of{tokenAddress}
in USDC, as a string with full precision.currency
: metadata for the token you requested.source
: array of per-aggregator quotes used to deriveusdPrice
.amountIn
: USDC amount used for the quote (smallest units, default1000000
).inputCurrency
: always USDC (address, symbol, decimals).amountOut
: expected output token amount foramountIn
USDC (smallest units of the token).outputCurrency
: echoes the priced token metadata.usdPrice
: implied price from this aggregator for the given size.aggregator
: name of the router/aggregator.executionMilliseconds
: time taken to fetch/compute this quote.