LogoLogo
SwapKit's websiteRegister for an API Key
  • 🏑Getting started
    • SwapKit's trade offerings
  • πŸ’°Monetization
  • 🀝Partnership
  • ⚠️Smart contract limitations
  • SwapKit API
    • Introduction
    • /providers - Request supported chains by a swap provider
    • /tokens - Request supported tokens by a swap provider
    • /quote - Request a trade quote
    • /quote - Understanding the response
    • /chainflip/broker/channel - Opening a Chainflip deposit channel
    • /track - Request the status of a swap
    • /screen - Check AML compliance
    • /price - Lookup token prices
Powered by GitBook
On this page
  • Endpoint
  • Request parameters
  • Example requests
  • Response format
  1. SwapKit API

/price - Lookup token prices

Endpoint

Method: POST URL: https://api.swapkit.dev/price


Request parameters

Parameter
Type
Description

tokens

array

List of token identifiers to fetch price for. Each item is an object with an identifier field (e.g., { "identifier": "ETH.ETH" }).

metadata

boolean

If true, includes extended CoinGecko metadata (currently always included, even if set to false).

Identifiers follow the format Chain.Asset, such as ETH.ETH, BTC.BTC or SOL.SOL, with the contract address added at the end when necessary, such as ARB.PENDLE-0x0c880f6761F1af8d9Aa9C466984b80DAb9a8c9e8. This is the same formatting used in our /quote endpoint.


Example requests

curl -X POST \
  'https://api.swapkit.dev/price' \
  -H 'Content-Type: application/json' \
  -H "x-api-key: YOUR_VARIABLE_HERE" \
  -d '{
    "tokens": [
      { "identifier": "ETH.ETH" },
      { "identifier": "BTC.BTC" },
      { "identifier": "SOL.SOL" },
      {"identifier": "BSC.CAKE-0x0E09FaBB73Bd3Ade0a17ECC321fD13a19e81cE82"}
    ],
    "metadata": true
  }'
curl -X POST \
  'https://api.swapkit.dev/price' \
  -H 'Content-Type: application/json' \
  -H "x-api-key: YOUR_VARIABLE_HERE" \
  -d '{
    "tokens": [
      { "identifier": "ETH.ETH" }
    ],
    "metadata": true
  }'

Response format

The endpoint returns an array of token price objects.

[
  {
    "identifier": "ETH.ETH",
    "provider": "",
    "cg": {
      "id": "ethereum",
      "name": "Ethereum",
      "market_cap": 197138665861,
      "total_volume": 12560864823,
      "price_change_24h_usd": -39.89,
      "price_change_percentage_24h_usd": -2.38,
      "sparkline_in_7d": [...],
      "timestamp": "2025-04-15T12:30:44.643Z"
    },
    "price_usd": 1653.61,
    "timestamp": 1744720254562
  }
]

For each token, it includes the following fields:

Field
Type
Description

identifier

string

The token identifier you queried (e.g., ETH.ETH).

price_usd

number

The current price of the token in USD.

timestamp

number

Millisecond timestamp of the price fetch.

cg

object

(If metadata: true β€” currently always present) CoinGecko metadata.

└─ id

string

CoinGecko’s internal ID.

└─ name

string

Full name of the token.

└─ market_cap

number

Total market capitalization in USD.

└─ total_volume

number

24-hour trading volume in USD.

└─ price_change_24h_usd

number

Price change in absolute USD over the last 24 hours.

└─ price_change_percentage_24h_usd

number

Percentage price change over the last 24 hours.

└─ sparkline_in_7d

array

7-day price history (useful for drawing sparkline charts).

└─ timestamp

string

Timestamp of the CoinGecko data.

When a token's price is not found, or the token name is not correctly specified, the endpoint will return a price of 0 USD for that token. Not how ETH.HTE is not a correct identifier so the example response here fails to return a correct price:

[
  {
    "identifier": "ETH.EHT",
    "provider": "",
    "price_usd": 0,
    "timestamp": 0
  }
]
Previous/screen - Check AML compliance

Last updated 2 months ago