DIA made API data easily accessibly through GraphQL endpoint.
You can use the following link to send GraphQL requests:
Also you can use a dedicated front-end to try out queries:
Currently only tokens price feed data is available on GraphQL.
Example of schema that can be used for quoting data:
The schema will return the moving average price of ETH calculated every 5min (300 sec) by counting 2min trade blocks.
FeedSelection
filtering optionsThere are a number of ways to filter out exchanges with DIA's GraphQL endpoints.
Here's an example how to define FeedSelection query to return a price for a given range with all sources included:
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:
It is also possible to select specific pairs from a given exchange. The query would look as follows:
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:
It is also possible to merge pairs selection with LiquidityThreshold
, which would result in such query:
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:
In the table below you can find the description of response fields:
In the next page you can find examples on how to query DIA's GraphQL endpoint in different programming languages.
Parameter | Description |
---|
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 .
Field | Description |
---|
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 |
|
| Determine the window for trades inclusion in seconds (e.g. |
| Determine the frequency of price updates in seconds during the selected timeframe (e.g. |
| The start time of the preferred period for price calculation in timestamp format (e.g. |
| The end time of the preferred period for price calculation in timestamp format (e.g. |
| 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 |
Select trades processing methodology (e.g. VWAP
, MAIR
, find out all available filters )