📈Subgraph Query Examples

Current Global Data

An example querying total pair counts, total liquidity in USD, and total Volume in USD:

{
  surgeswaps {
    pairCount
    totalLiquidityUSD
    totalVolumeUSD
  }
}

Ticker Data

If you want to get the ticker data for a specific contract address, use the lower case address (except for the SRG address) as an id as follows.


{
  ticker(id: "0x9f19c8e321bD14345b797d43E01f0eED030F5Bff") {
    target_volume
    target_currency
    pool_id
    liquidity_in_usd
    last_price
    base_volume
    base_currency
    id
  }
}
 

Pair Data

If you want to get the pair data use the following as id: 0x9f19c8e321bD14345b797d43E01f0eED030F5Bff_0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c for SRG-BNB

[contract address]_0x9f19c8e321bD14345b797d43E01f0eED030F5Bff for all others


{
  pair(id: "0x9f19c8e321bD14345b797d43E01f0eED030F5Bff_0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c") {
    target
    pool_id
    id
    base
  }
}

All tickers Data

To get all current tickers data you can query tickers as follows.


{
  tickers {
    liquidity_in_usd
    last_price
    target_currency
    target_volume
    base_volume
    base_currency
  }
}

All pairs Data

To get all current pairs data you can query pairs as follows.

 {
     pairs { 
     base 
     id 
     pool_id 
     target } 
 }

Helpful Notes

Getting Historical Data

You can also query historical data by specifying a block number as shown below.


{
  tickers( block: {number:24726000}) {
    liquidity_in_usd
    last_price
    target_currency
    target_volume
    base_volume
    base_currency
  }
}

Getting volume for a window (e.g. 24 hours)

The volume provided for the tickers is cumulative, so subtract the current volume from the volume 24 hours ago if you want day volume for example.

Getting Data with more than 1000 items

The maximum items you can query at once is 1000. Thus, to get all possible pairs or ticker data, you can integrate using the skip variable. To get items beyond the first 1000 you can also set the skip as shown below.


{
  tickers( skip:1000){
    id
    }
}

Last updated