Skip to main content

API Documentation

Minimal Exploration tool

A minimal graphql endpoint to test access tokens without admin access can be found at https://graphiql-online.com/
-set the Authorization: Bearer ..... header like so

image-1650893954304.png

and enter a valid graphql query.
This will allow you to visualize the data available to you via the bearer tokenĀ 
--------------------------------------------------------------------------

The GraphQL Endpoint for RomeNET is api.romenet.io/v1/graphql. Both HTTP Post queries and Websocket subscriptions are available.
Refer to the Hasura docs for more in-depth query documentation.

Authentication

POST api.romenet.io/v1/graphql

A JSON Web Token (JWT) is required for all interactions with this API.
Check the Fetching Auth tokens page for more details.

Parameters

Header

Authorization Bearer eyJh.........UAKE

Schema

The schema can be found in the schema.graphql file below.

Authentication Example

Replace KEY_GOES_HERE with your valid JWT


Sample Queries

Search pairs by keyword

Query
query SearchPairsByKeyword($exchange: String, $input: String) {
  pairs: avalanche_pair_search(
    where: { exchange: { _eq: $exchange }, concat_ws: { _ilike: $input } }
    limit: 50
    order_by: { last_24hour_usd_volume: desc_nulls_last }
  ) {
    exchange
    pair_address
    token1_address
    token0_address
    token0 {
      primary_img_uri
      name
      symbol
      decimals
    }
    token1 {
      primary_img_uri
      name
      symbol
      decimals
    }
    last_24hour_usd_volume
  }
}
Sample Parameters
{
  "exchange": "pangolin",
  "input": "%wavax%"
}
Sample Results
{
  "data": {
    "pairs": [
      {
        "exchange": "pangolin",
        "pair_address": "0xe28984e1EE8D431346D32BeC9Ec800Efb643eef4",
        "token1_address": "0xc7198437980c041c805A1EDcbA50c1Ce5db95118",
        "token0_address": "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",
        "token0": {
          "primary_img_uri": null,
          "name": "Wrapped AVAX",
          "symbol": "WAVAX",
          "__typename": "avalanche_tokens"
        },
        "token1": {
          "primary_img_uri": null,
          "name": "Tether USD",
          "symbol": "USDT.e",
          "__typename": "avalanche_tokens"
        },
        "last_24hour_usd_volume": "8520140.3712497457808700",
        "__typename": "avalanche_pair_search"
      },
      {
        "exchange": "pangolin",
        "pair_address": "0x7c05d54fc5CB6e4Ad87c6f5db3b807C94bB89c52",
        "token1_address": "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",
        "token0_address": "0x49D5c2BdFfac6CE2BFdB6640F4F80f226bc10bAB",
        "token0": {
          "primary_img_uri": null,
          "name": "Wrapped Ether",
          "symbol": "WETH.e",
          "__typename": "avalanche_tokens"
        },
        "token1": {
          "primary_img_uri": null,
          "name": "Wrapped AVAX",
          "symbol": "WAVAX",
          "__typename": "avalanche_tokens"
        },
        "last_24hour_usd_volume": "6154403.6941218047908266",
        "__typename": "avalanche_pair_search"
      },
...

Search pair by token addresses

Query
query SearchPairByTokens(
  $exchange: String
  $token0: String
  $token1: String
) {
  pairs: avalanche_pair_search(
    where: {
      exchange: { _eq: $exchange }
      token0: { address: { _eq: $token0 } }
      token1: { address: { _eq: $token1 } }
    }
  ) {
    exchange
    pair_address
    token1_address
    token0_address
    token0 {
      primary_img_uri
      name
      symbol
    }
    token1 {
      primary_img_uri
      name
      symbol
    }
    last_24hour_usd_volume
  }
}
Sample Parameters
{
  "exchange": "pangolin",
  "token0": "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",
  "token1": "0xc7198437980c041c805A1EDcbA50c1Ce5db95118"
}
Sample Results
{
  "data": {
    "pairs": [
      {
        "exchange": "pangolin",
        "pair_address": "0xe28984e1EE8D431346D32BeC9Ec800Efb643eef4",
        "token1_address": "0xc7198437980c041c805A1EDcbA50c1Ce5db95118",
        "token0_address": "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",
        "token0": {
          "primary_img_uri": null,
          "name": "Wrapped AVAX",
          "symbol": "WAVAX"
        },
        "token1": {
          "primary_img_uri": null,
          "name": "Tether USD",
          "symbol": "USDT.e"
        },
        "last_24hour_usd_volume": "8481990.8451945933517400"
      }
    ]
  }
}

Get historical OHLC for pair

Query
query PricesQuery($exchange: String, $pairAddress: String, $baseToken: String, $quoteToken: String, $fromDate: Int, $toDate: Int, $resolution: Int, $isUSDView: Boolean!) {
  prices: avalanche_swap_candles_cached(
    order_by: {candle_start: asc}
    where: {exchange: {_eq: $exchange}, pair_address: {_eq: $pairAddress}, base_token: {_eq: $baseToken}, quote_token: {_eq: $quoteToken}, resolution_seconds: {_eq: $resolution}, candle_start: {_gte: $fromDate, _lte: $toDate}}
  ) {
    candle_start
    close @skip(if: $isUSDView)
    high @skip(if: $isUSDView)
    low @skip(if: $isUSDView)
    open @skip(if: $isUSDView)
    close_usd @include(if: $isUSDView)
    high_usd @include(if: $isUSDView)
    low_usd @include(if: $isUSDView)
    open_usd @include(if: $isUSDView)
    usd_volume
    generation_time
    __typename
  }
}
Sample Parameters
{
  "baseToken": "0xa7d7079b0fead91f3e65f86e8915cb59c1a4c664",
  "exchange": "traderjoe",
  "fromDate": 1644868178,
  "isUSDView": true,
  "pairAddress": "0xA389f9430876455C36478DeEa9769B7Ca4E3DDB1",
  "quoteToken": "0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7",
  "resolution": 60,
  "toDate": 1644954758
}
Sample Results
{
  "data": {
    "prices": [
      {
        "candle_start": 1644868200,
        "close_usd": "79.742421439079554658",
        "high_usd": "79.742421439079554658",
        "low_usd": "79.742421439079554658",
        "open_usd": "79.742421439079554658",
        "usd_volume": "3599.909039598979527162828961111309760912",
        "generation_time": 1644882482,
        "__typename": "avalanche_swap_candles_cached"
      },
      {
        "candle_start": 1644868260,
        "close_usd": "80.127953476660781009",
        "high_usd": "80.127953476660781009",
        "low_usd": "80.127953476660781009",
        "open_usd": "80.127953476660781009",
        "usd_volume": "39415.031942422773557812640601274972014817",
        "generation_time": 1644882663,
        "__typename": "avalanche_swap_candles_cached"
      },
...
    ]
  }
}

Get latest OHLC for pair

Query
query LatestPriceQuery(
  $exchange: String
  $pairAddress: String
  $baseToken: String
  $quoteToken: String
  $resolution: Int
  $isUSDView: Boolean!
) {
  prices: avalanche_swap_candles_cached(
    order_by: { candle_start: desc }
    limit: 1
    where: {
      exchange: { _eq: $exchange }
      pair_address: { _eq: $pairAddress }
      base_token: { _eq: $baseToken }
      quote_token: { _eq: $quoteToken }
      resolution_seconds: { _eq: $resolution }
    }
  ) {
    candle_start
    close @skip(if: $isUSDView)
    high @skip(if: $isUSDView)
    low @skip(if: $isUSDView)
    open @skip(if: $isUSDView)
    close_usd @include(if: $isUSDView)
    high_usd @include(if: $isUSDView)
    low_usd @include(if: $isUSDView)
    open_usd @include(if: $isUSDView)
  }
}
Sample Parameters
{
  "baseToken": "0xa7d7079b0fead91f3e65f86e8915cb59c1a4c664",
  "exchange": "traderjoe",
  "isUSDView": true,
  "pairAddress": "0xA389f9430876455C36478DeEa9769B7Ca4E3DDB1",
  "quoteToken": "0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7",
  "resolution": 60
}
Sample Results
{
  "data": {
    "prices": [
      {
        "candle_start": 1644867660,
        "close_usd": "79.813972842561577793",
        "high_usd": "79.813972842561577793",
        "low_usd": "79.813972842561577793",
        "open_usd": "79.813972842561577793",
        "usd_volume": "18.135991686135879947652541107432242542",
        "generation_time": 1644881943,
        "__typename": "avalanche_swap_candles_cached"
      },
      {
        "candle_start": 1644867720,
        "close_usd": "80.073025407152933438",
        "high_usd": "80.073025407152933438",
        "low_usd": "80.073025407152933438",
        "open_usd": "80.073025407152933438",
        "usd_volume": "6665.905708930259917308382290151446310832",
        "generation_time": 1644882122,
        "__typename": "avalanche_swap_candles_cached"
      },
...
    ]
  }
}

Get swaps for pair

Query
query GetSwapQuery($exchange: String, $baseToken: String, $quoteToken: String, $pairAddress: String, $limit: Int, $offset: Int, $orderBy: [avalanche_dex_swaps_with_prices_order_by!]) {
  swap: avalanche_dex_swaps_with_prices(
    order_by: $orderBy
    where: {exchange: {_eq: $exchange}, base_token: {_eq: $baseToken}, quote_token: {_eq: $quoteToken}, pair_address: {_eq: $pairAddress}, swapindex: {_gte: 0}, unusual: {_eq: false}}
    limit: $limit
    offset: $offset
  ) {
    txhash
    timestamp
    direction
    base_token
    quote_token
    price
    base_amount
    swapindex
    quote_amount
    native_price
    usd_price
    base_decimals
    quote_decimals
    __typename
  }
}
Sample Parameters
{
  "baseToken": "0xc7198437980c041c805a1edcba50c1ce5db95118",
  "exchange": "traderjoe",
  "limit": 50,
  "offset": 0,
  "orderBy": {
    "timestamp": "desc"
  },
  "pairAddress": "0xeD8CBD9F0cE3C6986b22002F03c6475CEb7a6256",
  "quoteToken": "0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7"
}
Sample Results
{
  "data": {
    "swap": [
      {
        "txhash": "0x87bcba472a69984281cb3dbf5d488881f787fd40cfb0cc71650886c73e6fb152",
        "timestamp": 1644955201,
        "direction": "sell",
        "base_token": "0xc7198437980c041c805a1edcba50c1ce5db95118",
        "quote_token": "0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7",
        "price": "89.80331601821327606825917031102",
        "base_amount": "554.084589",
        "swapindex": 1,
        "quote_amount": "6.169979167446605937",
        "native_price": "1",
        "usd_price": "89.803316018213276068",
        "base_decimals": 6,
        "quote_decimals": 18,
        "__typename": "avalanche_tokenswaps_with_prices"
      },
      {
        "txhash": "0xde9faebb341310a232fcc7569ca33f123e78b7f7fec371c546d71f13de86d7ac",
        "timestamp": 1644955198,
        "direction": "sell",
        "base_token": "0xc7198437980c041c805a1edcba50c1ce5db95118",
        "quote_token": "0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7",
        "price": "89.8046925503516222949250482438",
        "base_amount": "592.126261",
        "swapindex": 1,
        "quote_amount": "6.593489094882287220",
        "native_price": "1",
        "usd_price": "90.264950120115276615",
        "base_decimals": 6,
        "quote_decimals": 18,
        "__typename": "avalanche_tokenswaps_with_prices"
      },
...
    ]
  }
}

Get token details

Query
query TokenDetails($pair_address: String!, $exchange: String!) @cached {
  pair: avalanche_pair_summary(
    where: {exchange: {_eq: $exchange}, pair_address: {_eq: $pair_address}}
  ) {
    exchange
    start_pair_price
    start_token1_native_price
    start_token1_usd_price
    start_token0_native_price
    start_token0_usd_price
    last_24hour_native_volume
    last_24hour_usd_volume
    latest_pair_price
    latest_token1_native_price
    latest_token1_usd_price
    latest_token0_native_price
    latest_token0_usd_price
    pair_address
    pair_creation_date
    token0_address
    token0_name
    token0_pooled
    token0_symbol
    token0_total_supply
    token1_address
    token1_name
    token1_pooled
    token1_symbol
    token1_total_supply
    __typename
  }
  all_txs: avalanche_get_pair_tx_count(
    args: {_exchange: $exchange, _pair_address: $pair_address}
  ) {
    tx_count
    __typename
  }
}
Sample Parameters
{
  "exchange": "traderjoe",
  "pair_address": "0xA389f9430876455C36478DeEa9769B7Ca4E3DDB1"
}
Sample Results
{
  "data": {
    "pair": [
      {
        "exchange": "traderjoe",
        "start_pair_price": "80.274367932313870699111894163988",
        "start_token1_native_price": "1",
        "start_token1_usd_price": "79.801002212091048303",
        "start_token0_native_price": "0.012457276534935595261000000000",
        "start_token0_usd_price": "0.994103152321025346589105323495",
        "last_24hour_native_volume": "561162.401191530877315548",
        "last_24hour_usd_volume": "48243643.688596381587286912639919367281248143",
        "latest_pair_price": "90.392276415584415584415584415584",
        "latest_token1_native_price": "1",
        "latest_token1_usd_price": "90.329862996610643873",
        "latest_token0_native_price": "0.011062892092709718416402960795",
        "latest_token0_usd_price": "0.999309527080756082225490865278",
        "pair_address": "0xA389f9430876455C36478DeEa9769B7Ca4E3DDB1",
        "pair_creation_date": null,
        "token0_address": "0xA7D7079b0FEaD91F3e65f86E8915Cb59c1a4C664",
        "token0_name": "USD Coin",
        "token0_pooled": "122787068.972896000000000000000000000000",
        "token0_symbol": "USDC.e",
        "token0_total_supply": "1833999110.395129000000000000000000000000",
        "token1_address": "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",
        "token1_name": "Wrapped AVAX",
        "token1_pooled": "1366676.921595790676533543000000000000",
        "token1_symbol": "WAVAX",
        "token1_total_supply": "16914010.367371207675175616000000000000",
        "__typename": "avalanche_pair_summary"
      }
    ],
    "all_txs": [
      {
        "tx_count": "1422989",
        "__typename": "avalanche_pairs_tx_count"
      }
    ]
  }
}

Sample Websocket Subscriptions

Subscribe to candles for pair

Query
subscription SubscribePricesQuery(
  $exchange: String!
  $pairAddress: String!
  $baseToken: String!
  $quoteToken: String!
  $resolution: Int!
  $isUSDView: Boolean!
) {
  prices: avalanche_get_swap_candles (
    order_by: { candle_start: desc }
    limit: 4
    args: {
      _exchange: $exchange
      _pair_address: $pairAddress
      _base_token: $baseToken
      _quote_token: $quoteToken
      _resolution: $resolution
    }
  ) {
    candle_start
    close @skip(if: $isUSDView)
    high @skip(if: $isUSDView)
    low @skip(if: $isUSDView)
    open @skip(if: $isUSDView)
    close_usd @include(if: $isUSDView)
    high_usd @include(if: $isUSDView)
    low_usd @include(if: $isUSDView)
    open_usd @include(if: $isUSDView)
    usd_volume
    generation_time
  }
}
Sample Parameters
{
    "baseToken": "0xa7d7079b0fead91f3e65f86e8915cb59c1a4c664",
    "exchange": "traderjoe",
    "limit": 2,
    "pairAddress": "0xA389f9430876455C36478DeEa9769B7Ca4E3DDB1",
    "quoteToken": "0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7"
}
Sample Results
{
    "type": "data",
    "id": "2",
    "payload": {
        "data": {
            "swap": [
                {
                    "txhash": "0xcaeedaf4755724d0bcefd8075b48f44261ddcc2c7236becfb0f4cc72ea95f1ec",
                    "timestamp": 1644955299,
                    "direction": "buy",
                    "base_token": "0xa7d7079b0fead91f3e65f86e8915cb59c1a4c664",
                    "quote_token": "0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7",
                    "price": "90.391024943866636484410425576168",
                    "base_amount": "106.000000",
                    "swapindex": 0,
                    "quote_amount": "1.172682797499271966",
                    "native_price": "1",
                    "usd_price": "90.124990444212817887",
                    "base_decimals": 6,
                    "quote_decimals": 18,
                    "__typename": "avalanche_tokenswaps_with_prices"
                },
                {
                    "txhash": "0x62451fb783205f03524832b0895272a541bca01ed489ae3a80cf279ee0574a76",
                    "timestamp": 1644955292,
                    "direction": "sell",
                    "base_token": "0xa7d7079b0fead91f3e65f86e8915cb59c1a4c664",
                    "quote_token": "0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7",
                    "price": "89.852002925985293743480141465028",
                    "base_amount": "3531.453271",
                    "swapindex": 0,
                    "quote_amount": "39.303000000000000000",
                    "native_price": "1",
                    "usd_price": "90.125742291457316715",
                    "base_decimals": 6,
                    "quote_decimals": 18,
                    "__typename": "avalanche_tokenswaps_with_prices"
                }
            ]
        }
    }
}

Subscribe to new swaps for pair

Query
subscription OnSwapQuery(
  $exchange: String
  $pairAddress: String
  $baseToken: String
  $quoteToken: String
  $limit: Int
) {
  swap: avalanche_tokenswaps_with_prices(
    order_by: { timestamp: desc }
    limit: $limit
    where: {
      exchange: { _eq: $exchange }
      base_token: { _eq: $baseToken }
      quote_token: { _eq: $quoteToken }
      pair_address: { _eq: $pairAddress }
      swapindex: { _gte: 0 }
      unusual: { _eq: false }
    }
  ) {
    txhash
    timestamp
    direction
    base_token
    quote_token
    price
    base_amount
    swapindex
    quote_amount
    native_price
    usd_price
    base_decimals
    quote_decimals
  }
}
Sample Parameters
{
    "baseToken": "0x55d398326f99059ff775485246999027b3197955",
    "exchange": "mdex",
    "limit": 5,
    "pairAddress": "0x0FB881c078434b1C0E4d0B64d8c64d12078b7Ce2",
    "quoteToken": "0x2170ed0880ac9a755fd29b2688956bd959f933f8"
}
Sample Results
{
    "type": "data",
    "id": "2",
    "payload": {
        "data": {
            "swap": [
                {
                    "txhash": "0x1a305e1addc1ce81fcd079778b047c997984f5afc9c17a82ae3f7b2f0923bd41",
                    "timestamp": 1644954040,
                    "direction": "buy",
                    "base_token": "0x55d398326f99059ff775485246999027b3197955",
                    "quote_token": "0x2170ed0880ac9a755fd29b2688956bd959f933f8",
                    "price": "3121.087490281765862636705504856395",
                    "base_amount": "854.370440461931833799",
                    "swapindex": 2,
                    "quote_amount": "0.273741265863970026",
                    "native_price": "7.212155487420120625842102267636",
                    "usd_price": "3117.319146455634017042679271719585",
                    "base_decimals": 18,
                    "quote_decimals": 18,
                    "__typename": "bsc_tokenswaps_with_prices"
                },
                {
                    "txhash": "0x1a305e1addc1ce81fcd079778b047c997984f5afc9c17a82ae3f7b2f0923bd41",
                    "timestamp": 1644954040,
                    "direction": "sell",
                    "base_token": "0x55d398326f99059ff775485246999027b3197955",
                    "quote_token": "0x2170ed0880ac9a755fd29b2688956bd959f933f8",
                    "price": "3102.269746187480161738353629610034",
                    "base_amount": "212.643032336757105071",
                    "swapindex": 1,
                    "quote_amount": "0.068544340026551128",
                    "native_price": "7.212155487420120625842102267636",
                    "usd_price": "3117.319146455634017042679271719585",
                    "base_decimals": 18,
                    "quote_decimals": 18,
                    "__typename": "bsc_tokenswaps_with_prices"
                },
...
            ]
        }
    }
}