Get Token Prices

Returns real-time or historical prices for a list of tokens.

Endpoint: getTokenPrices

Method: POST

Price Calculation

Defined prices are calculated by routing along the highest liquidity path to a known pair of stablecoins, and handles the case if a stablecoin ever depegs from 1 USD.

Arguments

NameTypeDescription
inputs[GetPriceInput]

A list of GetPriceInputs. Accepts a maximum of 25 inputs (anything over will be truncated).

NameTypeDescription
addressString!

The contract address of the token.

Required
networkIdInt!

The network ID the token is deployed on.

Required
timestampInt

The unix timestamp for the price. Lookup is limited to the last three months.

Response

NameTypeDescription
addressString!The contract address of the token.
confidenceFloatRatio of how confident we are in the price
networkIdInt!The network ID the token is deployed on.
priceUsdFloat!The token price in USD.
timestampInt!The unix timestamp for the price.

Examples

Current Prices Query

Use this query to find current prices for multiple tokens.

{
  getTokenPrices(
    inputs: [
      { address: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", networkId: 1 }
      { address: "0x4d224452801aced8b2f0aebe155379bb5d594381", networkId: 1 }
    ]
  ) {
    address
    networkId
    priceUsd
  }
}
Historical Price Query

Use this query to find historical prices for a token over a 3 day period.

{
  getTokenPrices(
    inputs: [
      { 
        address: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
        networkId: 1
        timestamp: 1694198174
      }
      { 
        address: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
        networkId: 1
        timestamp: 1694111774
      }
      { 
        address: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
        networkId: 1
        timestamp: 1694025374 
      }
    ]
  ) {
    priceUsd
  }
}

Explore

πŸ‘‹

Join our Discord

Ask questions, share what you're working on and request new features πŸ‘¬πŸ‘­