NAV
shell

Introduction

Welcome to the Bonfida API! You can use our API to access Serum DEX data and other crypto market analytics.

The current rate limit is 30 requests per second - please reach out if you’re building something and need a higher limit.

Project Serum

For more information about Serum visit Project Serum

REST endpoint URL: https://serum-api.bonfida.com

Get all pairs

curl "https://serum-api.bonfida.com/pairs"

The above command returns JSON structured like this:

{
  "success": true,
  "data": [
    "ALEPH/USDT",
    "ALEPH/WUSDC",
    "BTC/USDT",
    "BTC/WUSDC",
    "ETH/USDT",
    "ETH/WUSDC",
    "SOL/USDT",
    "SOL/WUSDC"
  ]
}

Provides a list of all trading pairs on the Serum DEX.

HTTP Request

GET https://serum-api.bonfida.com/pairs

Get recent trades by market name

curl "https://serum-api.bonfida.com/trades/ETHUSDT"

The above command returns JSON structured like this:

{
  "success": true,
  "data": [
    {
      "market": "ETH/USDT",
      "price": 451.51,
      "size": 0.5,
      "side": "buy",
      "time": 1604767562476.2188,
      "orderId": "833220983065386731245551",
      "feeCost": 0.225755,
      "marketAddress": "5abZGhrELnUnfM9ZUnvK6XJPoBU5eShZwfFPkdhAC7o"
    }
  ]
}

Provides a list of all market fills from the last 24 hours on the Serum DEX.

HTTP Request

GET https://serum-api.bonfida.com/trades/{marketName}

URL Parameters

Parameter Description
marketName The name of the market you want to retrieve data from

Get recent trades by market address

curl "https://serum-api.bonfida.com/trades/address/5abZGhrELnUnfM9ZUnvK6XJPoBU5eShZwfFPkdhAC7o"

The above command returns JSON structured like this:

{
  "success": true,
  "data": [
    {
      "market": "ETH/USDT",
      "price": 451.51,
      "size": 0.5,
      "side": "buy",
      "time": 1604767562476.2188,
      "orderId": "833220983065386731245551",
      "feeCost": 0.225755,
      "marketAddress": "5abZGhrELnUnfM9ZUnvK6XJPoBU5eShZwfFPkdhAC7o"
    }
  ]
}

Provides a list of all market fills from the last 24 hours on the Serum DEX.

HTTP Request

GET https://serum-api.bonfida.com/trades/address/{marketAddress}

URL Parameters

Parameter Description
marketAddress The market address you want to retrieve data from

Get all recent trades

curl "https://serum-api.bonfida.com/trades"

The above command returns JSON structured like this:

{
  "success": true,
  "data": [
    {
      "market": "ETH/USDT",
      "price": 451.51,
      "size": 0.5,
      "side": "buy",
      "time": 1604767562476.2188,
      "orderId": "833220983065386731245551",
      "feeCost": 0.225755,
      "marketAddress": "5abZGhrELnUnfM9ZUnvK6XJPoBU5eShZwfFPkdhAC7o"
    }
  ]
}

Provides a list of all market fills from the last 24 hours on the Serum DEX.

HTTP Request

GET https://serum-api.bonfida.com/trades

Get volume

curl "https://serum-api.bonfida.com/volumes/ETHUSDT"

The above command returns JSON structured like this:

{
  "success": true,
  "data": [
    {
      "volumeUsd": 377446.7586900001,
      "volume": 835.2339999999999
    }
  ]
}

Provides a view of rolling 24 hour volume on the Serum DEX - use ‘all’ as the market for an aggregate of traded volume across all markets.

HTTP Request

GET https://serum-api.bonfida.com/volumes/{marketName}

URL Parameters

Parameter Description
marketName The name of the market you want to retrieve data from

Get orderbook

curl "https://serum-api.bonfida.com/orderbooks/ETHUSDT"

The above command returns JSON structured like this:

{
  "success": true,
  "data": {
    "market": "ETH/USDT",
    "bids": [
      { "price": 452.77, "size": 5 },
      { "price": 452.71, "size": 0.5 },
      { "price": 452.17, "size": 10 },
      { "price": 451.98, "size": 184.238 },
      { "price": 451.64, "size": 221.099 },
      { "price": 450.6, "size": 200 },
      { "price": 449.94, "size": 228.41 },
      { "price": 449.9, "size": 232.205 },
      { "price": 449, "size": 295.667 },
      { "price": 448.66, "size": 412.566 },
      { "price": 446.04, "size": 468.99 },
      { "price": 446, "size": 644.819 },
      { "price": 443.78, "size": 536.219 },
      { "price": 436.98, "size": 700.985 },
      { "price": 399.19, "size": 0.15 }
    ],
    "asks": [
      { "price": 453.19, "size": 105.534 },
      { "price": 453.41, "size": 10 },
      { "price": 453.49, "size": 114.203 },
      { "price": 453.7, "size": 0.5 },
      { "price": 454.1, "size": 50 },
      { "price": 454.77, "size": 0.047 },
      { "price": 454.87, "size": 200 },
      { "price": 455.36, "size": 85.251 },
      { "price": 455.38, "size": 0.013 },
      { "price": 455.99, "size": 158.496 },
      { "price": 457.16, "size": 0.004 },
      { "price": 457.35, "size": 0.004 },
      { "price": 457.87, "size": 201.712 },
      { "price": 457.98, "size": 280.23 },
      { "price": 458.71, "size": 340.135 },
      { "price": 459.39, "size": 256.345 },
      { "price": 459.56, "size": 0.019 },
      { "price": 460.36, "size": 317.861 },
      { "price": 460.41, "size": 0.029 },
      { "price": 461.14, "size": 5 },
      { "price": 461.41, "size": 50 },
      { "price": 461.43, "size": 50 },
      { "price": 461.45, "size": 50 },
      { "price": 461.89, "size": 200 },
      { "price": 461.92, "size": 340.802 },
      { "price": 461.98, "size": 250 },
      { "price": 462.11, "size": 50 },
      { "price": 462.22, "size": 200 },
      { "price": 462.68, "size": 50 },
      { "price": 462.8, "size": 50 },
      { "price": 462.9, "size": 468.001 },
      { "price": 464.43, "size": 0.022 },
      { "price": 468.8, "size": 0.052 },
      { "price": 469.79, "size": 0.1 },
      { "price": 479.23, "size": 0.196 }
    ],
    "marketAddress": "5abZGhrELnUnfM9ZUnvK6XJPoBU5eShZwfFPkdhAC7o"
  }
}

Provides the current orderbook of the market.

HTTP Request

GET https://serum-api.bonfida.com/orderbooks/{marketName}

URL Parameters

Parameter Description
marketName The name of the market you want to retrieve data from

Get historical prices

curl "https://serum-api.bonfida.com/candles/BTCUSDC?resolution=3600"

The above command returns JSON structured like this:

{
  "success": true,
  "data": [
    {
      "close": 16001.05,
      "open": 15942.05,
      "low": 15942.05,
      "high": 16013.3,
      "startTime": 1605416400000,
      "market": "BTC/USDC",
      "volumeBase": 0,
      "volumeQuote": 0
    },
    {
      "close": 15942.05,
      "open": 15949.95,
      "low": 15899.1,
      "high": 15978.5,
      "startTime": 1605412800000,
      "market": "BTC/USDC",
      "volumeBase": 0,
      "volumeQuote": 0
    }
  ]
}

HTTP Request

GET https://serum-api.bonfida.com/candles/{marketName}?resolution={resolution}&startTime={startTime}&endTime={endTime}&limit={limit}

URL Parameters

Parameter Description
marketName The name of the market you want to retrieve data from
resolution Window length in seconds. options: 60, 3600, 14400, 86400
startTime Optional (in ms)
endTime Optional (in ms)
limit Optional. Max and default 1000

Get all pools

curl "https://serum-api.bonfida.com/pools"

The above command returns JSON structured like this:

{
  "success": true,
  "data": [
    {
      "name": "USDT/SOL",
      "pool_identifier": "H2mJpdQTBcsfGUJvVJjRpPd95RKf2stDadJnR3Mf2qq7",
      "liquidity_locked": 190685.5960057655,
      "apy": 0.06389282452440433,
      "volume": 57038.58298187185,
      "mints": [
        "BQcdHdAQW1hczDbBi9hiegXAR7A98Q9jx3X3iBBBDiq4",
        "So11111111111111111111111111111111111111112"
      ],
      "liquidityA": 95928.930894,
      "liquidityAinUsd": 95928.930894,
      "liquidityB": 61912.228103081,
      "liquidityBinUsd": 94756.66511176547,
      "supply": 10.0216061,
      "fees": 171.11574894561554,
      "time": 1604204796661
    }
  ]
}

Provides data about Serum pools over the last 6 hours. A new data point is added every 30 minutes for each pool.

HTTP Request

GET https://serum-api.bonfida.com/pools

The following endpoint returns the most recent data points:

GET https://serum-api.bonfida.com/pools-recent

Get pool

curl "https://serum-api.bonfida.com/pools/BQcdHdAQW1hczDbBi9hiegXAR7A98Q9jx3X3iBBBDiq4/SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt?endTime=1605531090000&startTime=1605444690000&limit=100"

The above command returns JSON structured like this:

{
  "success": true,
  "data": [
    {
      "name": "USDT/SRM",
      "pool_identifier": "2gJPRt8a9PNfjU4vFGtq4aH3ud1XY44tk9HvQVyF4eio",
      "liquidity_locked": 1522372.655400426,
      "apy": 1.1198276808045515,
      "volume": 2465262.921672771,
      "mints": [
        "BQcdHdAQW1hczDbBi9hiegXAR7A98Q9jx3X3iBBBDiq4",
        "SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt"
      ],
      "liquidityA": 760150.113927,
      "liquidityAinUsd": 760150.113927,
      "liquidityB": 588816.177268,
      "liquidityBinUsd": 762222.5414734259,
      "supply": 65.14360704,
      "fees": 7395.788765018314,
      "time": 1605529983607,
      "volume24hA": 124930.352732,
      "volume24hB": 98014.950623
    }
  ]
}

Provides historical data about Serum pools

HTTP Request

GET https://serum-api.bonfida.com/pools/{mintA}/{mintB}?startTime={startTime}&endTime={endTime}&limit={limit}

URL Parameters

Parameter Description
mintA Mint address A
mintB Mint address B
startTime Optional (in ms)
endTime Optional (in ms)
limit Optional. Max and default 1000

Get pool trades

curl "https://serum-api.bonfida.com/pools/trades?symbolSource=BTC&symbolDestination=USDC&bothDirections=true"

The above command returns JSON structured like this:

{
  "success": true,
  "data": [
    {
      "signature": "XaaGc8DKMza8uBfNMA5GzXATF1nz9cJMSnxPqRExzk4GG5ADhddsKi6mfeBAq3vd9G2GAUoAouEGnbgHrVw6Unb",
      "symbolSource": "BTC",
      "poolSourceMint": "9n4nbM75f5Ui33ZbPYXn59EwSgE8CGsHtAeTH5YFeJ9E",
      "symbolDestination": "USDC",
      "poolDestinationMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
      "amountIn": 0.006892,
      "amountOut": 79.564554,
      "poolMintAuthority": "5W46iojjAEWk56oDUFL7FSyaqJEY7SvWvEZxBS38Daix",
      "time": 1604761992156
    }
  ]
}

Provides a list of all trades fills from the last 24 hours on the Serum Swap

HTTP Request

GET https://serum-api.bonfida.com/pools/trades

URL Parameters

Parameter Description
symbolSource optional Source coin of the swap
symbolDestination optional Destination coin of the swap
bothDirections optional To retrieve trades from both directions

If no parameters are given it will return all trades from the last 24 hours

Get pools last 24h volume

curl "https://serum-api.bonfida.com/pools/volumes/recent"

The above command returns JSON structured like this:

{ "success": true, "data": [{ "volume": 408399.18767858105 }] }

Provides a view of rolling 24 hour volume on the Serum Swap

HTTP Request

GET https://serum-api.bonfida.com/pools/volumes/recent

Get pools historical volume

curl "https://serum-api.bonfida.com/pools/volumes?mintA=9S4t2NEAiJVMvPdRYKVrfJpBafPBLtvbvyS3DecojQHw&mintB=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v&endTime=1605605529000&startTime=1605259529000&limit=2"

The above command returns JSON structured like this:

{
  "success": true,
  "data": [
    {
      "mintA": "9S4t2NEAiJVMvPdRYKVrfJpBafPBLtvbvyS3DecojQHw",
      "mintB": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
      "volume": 9838.425721988495,
      "time": 1605571200000
    },
    {
      "mintA": "9S4t2NEAiJVMvPdRYKVrfJpBafPBLtvbvyS3DecojQHw",
      "mintB": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
      "volume": 5999.188775463499,
      "time": 1605484800000
    },
    {
      "mintA": "9S4t2NEAiJVMvPdRYKVrfJpBafPBLtvbvyS3DecojQHw",
      "mintB": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
      "volume": 33847.21026596426,
      "time": 1605398400000
    }
  ]
}

Provides historical volume data for pools.

HTTP Request

GET https://serum-api.bonfida.com/pools/volumes?mintA={mintA}&mintB={mintB}&endTime={endTime}&startTime={startTime}&limit={limit}

URL Parameters

Parameter Description
mintA Mint address A
mintB Mint address B
startTime Optional (in ms)
endTime Optional (in ms)
limit Optional. Max and default 100

Get pools historical liquidity

curl "https://serum-api.bonfida.com/pools/liquidity?mintA=9S4t2NEAiJVMvPdRYKVrfJpBafPBLtvbvyS3DecojQHw&mintB=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v&endTime=1605605529000&startTime=1605259529000&limit=2"

The above command returns JSON structured like this:

{
  "success": true,
  "data": [
    {
      "mintA": "9n4nbM75f5Ui33ZbPYXn59EwSgE8CGsHtAeTH5YFeJ9E",
      "mintB": "SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt",
      "liquidityAinUsd": 624513.720168704,
      "liquidityBinUsd": 620145.0892474919,
      "liquidityA": 37.25022792401123,
      "liquidityB": 491481.99210968224,
      "time": 1605571200000
    }
  ]
}

Provides historical volume data for pools.

HTTP Request

GET https://serum-api.bonfida.com/pools/liquidity?mintA={mintA}&mintB={mintB}&endTime={endTime}&startTime={startTime}&limit={limit}

URL Parameters

Parameter Description
mintA Mint address A
mintB Mint address B
startTime Optional (in ms)
endTime Optional (in ms)
limit Optional. Max and default 100

Trading View

Bonfida built an API that follows TradingView UDF specifications. This means that Bonfida API can be used out of the box with any TradingView widget. You simply need to use https://serum-api.bonfida.com/tv for the datafeedUrl field in the TradingView widget constructor.

const defaultProps: ChartContainerProps = {
  // ...
  datafeedUrl: "https://serum-api.bonfida.com/tv"
  // ...
};

const widgetOptions: ChartingLibraryWidgetOptions = {
  // ...
  datafeed: new (window as any).Datafeeds.UDFCompatibleDatafeed(
    defaultProps.datafeedUrl
  )
  // ...
};

const tvWidget = new widget(widgetOptions);

Exchanges

REST endpoint URL: https://bonfida.com/api

Get order placement latencies

curl "https://bonfida.com/api/latency-order"

The above command returns JSON structured like this:

[
  { "exchange": "bybit", "latency": 132578, "lastUpdate": 1604804743 },
  { "exchange": "ftx", "latency": 78446, "lastUpdate": 1604804743 },
  { "exchange": "binance", "latency": 29762, "lastUpdate": 1604804743 },
  { "exchange": "bitmex", "latency": 829601, "lastUpdate": 1604804743 }
]

Returns the last latency measured for order placement through REST API for Bybit, FTX, Binance and Bitmex. The latency is measured from AWS Tokyo.

The following endpoints measure from different AWS locations:

HTTP Request

GET https://bonfida.com/api/latency-order

Get open interests

curl "https://bonfida.com/api/open-interest"

The above command returns JSON structured like this:

[
  {
    "exchange": "deribit",
    "openInterest": 183565810,
    "lastUpdate": 1604802624
  },
  {
    "exchange": "bybit",
    "openInterest": 557734465.52,
    "lastUpdate": 1604802624
  },
  { "exchange": "huobi", "openInterest": 207408300, "lastUpdate": 1604802624 },
  {
    "exchange": "binance",
    "openInterest": 591827555.328125,
    "lastUpdate": 1604802624
  },
  { "exchange": "okex", "openInterest": 142929500, "lastUpdate": 1604802624 },
  { "exchange": "bitmex", "openInterest": 357241514, "lastUpdate": 1604802624 },
  {
    "exchange": "ftx",
    "openInterest": 214813290.58319998,
    "lastUpdate": 1604802624
  }
]

Returns the open interest of Deribit, Bybit, Okex and FTX.

HTTP Request

GET https://bonfida.com/api/open-interest

Get BTC implied volatility

curl "https://bonfida.com/api/vol/today"

The above command returns JSON structured like this:

0.6514701843261719

Returns the BTC implied volatility.

HTTP Request

GET https://bonfida.com/api/vol/{time}

URL Parameters

Parameter Description
time today, tomorrow, this-week, next-week

Get long and short ratios

curl "https://bonfida.com/api/long-short-ratio?exchange=ftx&market=BTC-PERP"

The above command returns JSON structured like this:

{ "longRatio": 0.4852245862884161, "lastUpdate": 1604805231 }

Returns long and short ratios for the specified exchange and specified market

HTTP Request

GET https://bonfida.com/api/long-short-ratio?exchange={exchange}&market={market}

URL Parameters

Parameter Description
exchange Exchange from which you want the ratio (only FTX, Bybit, Binance and Phemex are supported)
market market from which you want the ratio (e.g BTC-PERP)