GraphQL Endpoint

DIA made API data easily accessibly through GraphQL endpoint.

You can use the following link to send GraphQL requests:

https://api.diadata.org/graphql/query

Also you can use a dedicated front-end to try out queries:

https://api.diadata.org/graphql/

Currently only tokens price feed data is available on GraphQL.

Example of schema that can be used for quoting data:

Sample Schema
query  {
     GetFeed(
      Filter: "mair",
      BlockSizeSeconds: 480,
      BlockShiftSeconds: 480,
      StartTime: 1690449575,
      EndTime: 1690535975,
      FeedSelection: [
        {
          Address: "0x6B175474E89094C44Da98b954EedeAC495271d0F",
          Blockchain:"Ethereum",
          Exchangepairs:[],
        },
      ],
    )
  {
    Name
    Time
    Value
    Address
    Pools
    Pairs
  }
}

The schema will return the moving average price of ETH calculated every 5min (300 sec) by counting 2min trade blocks.

Query parameters rundown

ParameterDescription

filter

Select trades processing methodology (e.g. VWAP, MAIR, find out all available filters here)

BlockSizeSeconds

Determine the window for trades inclusion in seconds (e.g. 120 will include all trades into price calculation that happened during the last 2 minutes)

BlockShiftSeconds

Determine the frequency of price updates in seconds during the selected timeframe (e.g. 600 will return price for every 5min during the selected period)

StartTime

The start time of the preferred period for price calculation in timestamp format (e.g. 1655084380 will start calculating price from 13.06.2022 01:39:40 GMT time)

EndTime

The end time of the preferred period for price calculation in timestamp format (e.g. 1655090649 will calculate price until 13.06.2022 03:24:09 GMT time)

FeedSelection

This is the main module of the query which is responsible for parametrizing asset(s) for which the price data should be retrieved. Available parameters for FeedSelection are described in detail below.

FeedSelection filtering options

There are a number of ways to filter out exchanges with DIA's GraphQL endpoints.

First of all, you should define the desired asset. DIA uses blockchain-address asset identification methodology. You can search for available assets and find out blockchain/address information in the DIA APP asset explorer.

Here's an example how to define FeedSelection query to return a price for a given range with all sources included:

FeedSelection: [
        {
          Address: "0x6B175474E89094C44Da98b954EedeAC495271d0F",
          Blockchain:"Ethereum",
          Exchangepairs:[],
        },
      ]

There are number of ways to filter desired sources from the entire sources library for a given asset. We'll go over examples of these filters.

To select specific exchanges you can use the following format:

FeedSelection: [
        {
          Address: "0x6B175474E89094C44Da98b954EedeAC495271d0F",
          Blockchain:"Ethereum",
          Exchangepairs:[{Exchange:"CoinBase"},{Exchange:"UniswapV3"}],
        },
      ]

It is also possible to select specific pairs from a given exchange. The query would look as follows:

FeedSelection: [
        {
          Address: "0x6B175474E89094C44Da98b954EedeAC495271d0F",
          Blockchain:"Ethereum",
          Exchangepairs:[
            {
              Exchange: "CoinBase",
              Pairs:["DAI-USD"],
            },
            {
              Exchange: "UniswapV3",
              Pairs:["0x60594a405d53811d3BC4766596EFD80fd545A270","0x6f48ECa74B38d2936B02ab603FF4e36A6C0E3A77"],
            },
       ]

Another filtering option is to include sources based on available liquidity in the pool. For example if you select a liquidity threshold of $5 000 000, the response will calculate the price of an asset only by including liquidity pools from DEXes which have higher than $5 000 000 liquidity. The query looks as follows:

FeedSelection: [
          {
          Address: "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",
          Blockchain:"Ethereum",
          LiquidityThreshold:5000000.0
          Exchangepairs: [],
          },
       ]

It is also possible to merge pairs selection with LiquidityThreshold, which would result in such query:

FeedSelection: [
        {
          Address: "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",
          Blockchain:"Ethereum",
          Exchangepairs:[
            {
              Exchange: "CoinBase",
              Pairs:["DAI-USD"],
            },
          ]
        },
        {
          Address: "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",
          Blockchain:"Ethereum",
          LiquidityThreshold:5000000.0
          Exchangepairs: [],
        },
      ],

One more option is to use two different assets to calculate one unified price. It might be useful for cross-chain assets, e.g. DAI on ETH mainnet & DAI on Arbitrum One. The query which can be used for such cases would look as follows:

FeedSelection: [
        {
          Address: "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",
          Blockchain:"Ethereum",
          Exchangepairs:[]
        },
        {
          Address: "0xda10009cbd5d07dd0cecc66161fc93d7c9000da1",
          Blockchain:"Arbitrum",
          Exchangepairs:[]
        },
      ],

Response fields

In the table below you can find the description of response fields:

FieldDescription

Time

Time at which the value was generated

Value

Price of an asset at a give time

Pools

Pools which had a trade during the block time period and were involved in the price calculation

Pairs

CEX pairs which had a trade during the block time period and were involved in the price calculation

Blockchain

Blockchain of an asset

Address

Address of an asset

In the next page you can find examples on how to query DIA's GraphQL endpoint in different programming languages.