Bitquery API integration with TradingView Technical Analysis Charts (DEX APIs)

Try running the code below in our GraphQL IDE and you’ll get the data relevant to Candlestick charts.

{
  ethereum(network: bsc) {
    dexTrades(
      options: {asc: "timeInterval.minute"}
      date: {since: "2021-06-20T07:23:21.000Z", till: "2021-06-23T15:23:21.000Z"}
      exchangeAddress: {is: "0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73"}
      baseCurrency: {is: "0x2170ed0880ac9a755fd29b2688956bd959f933f8"},
      quoteCurrency: {is: "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c"},
      tradeAmountUsd: {gt: 10}
    ) 
    {
      timeInterval {
        minute(count: 15, format: "%Y-%m-%dT%H:%M:%SZ")  
      }
      volume: quoteAmount
      high: quotePrice(calculate: maximum)
      low: quotePrice(calculate: minimum)
      open: minimum(of: block, get: quote_price)
      close: maximum(of: block, get: quote_price) 
    }
  }
}

isnt it the same query as the one in the tutorial code ? and Yes i tried it yesterday just to make sure that the query does return something , and it was giving the relevant candle data
but then again why does it return empty array when its used inside of bitquery.js in the tutorial ?

Yes it’s the same query in the tutorial.

okay but any suggestion as to why it isnt working with the charts?

I just checked the API call and it seems that

const response2 = await axios.post(Bitquery.endpoint, {
                query: Bitquery.GET_COIN_BARS,
                variables: {
                    "from": new Date("2021-06-20T07:23:21.000Z").toISOString(),
                    "to": new Date("2021-06-23T15:23:21.000Z").toISOString(),
                    "interval": Number(resolution),
                    "tokenAddress": symbolInfo.ticker
                },
                mode: 'cors',
                headers: {
                    "Content-Type": "application/json",
                    "X-API-KEY": "YOUR UNIQUE API KEY"
                }
            })
           
  // Console logging the query result --> 
            console.log(response2.data.data.ethereum.dexTrades[0].high);
            
            const bars = response2.data.data.ethereum.dexTrades.map(el => ({
                time: new Date(el.timeInterval.minute).getTime(), // date string in api response
                low: el.low,
                high: el.high,
                open: Number(el.open),
                close: Number(el.close),
                volume: el.volume
            }))

the query does return the data from the API. You just need to console.log(); in order to check it if you want.

console.log(response2.data.data.ethereum.dexTrades[0].high);

I did , but i dont think its working :

it logs : Cannot read property ‘high’ of undefined

I have the same problem. i install all and get the chart view. But the view is very smal.

But this is not the Problem. The Problem is that i have no idea where the chart show the candles. is also blank…

have anyone a solution?

dexTrades returns an array and hence to get a single value of a candlestick property, you might need to iterate over the array

1 Like

Try removing the “tradeAmountUsd: {gt: 10}” from your query.

Any information on how to subscribe to bitQuery. I’ve been working on a project similar to this and I can’t get a live chart no matter what I’ve tried. Any information about this would be greatly appreciated.

Hi @cryptoMav you can refer to this tutorial as it is the updated one Integrating Tradingview’s Technical Analysis Charts with Bitquery GraphQL API using VueJS

in the 1m interval the candles looks bar how can we fix this?

You can smoothen the data through a few filters like

priceAsymmetry - use something like priceAsymmetry: {lteq: 20}, this basically removes trades where both sides of USD price difference is more than 20 dollar.

tradeAmountUsd - use something link tradeAmountUsd: {gteq: 1}, this basically remove trades less than 1 dollar.

let me know how it worked.

i change the query like this it seems doesn’t work

This is correct, how you are comparing the charts? Which service you are using to compare our charts?

Hi, Thanks for response i already solved my problem by changing timeInterval to 1min

 timeInterval {
      minute(count: 1, format: "%Y-%m-%dT%H:%M:%SZ")  
 }

but when i changing the chart to 5mins it will not load but it shows no error on console i think the problem is updating the chart, its hard it to me i can’t find any documentation about this

@gaurav you can help me please my issue is getBars function call api infinite loop i cant resolve it

Hi,
Followed the document as mentioned above , but the thing is the charting library accessed from Github (from Trading-view) has errors. Can anyone who have come across with the same errors in charting.js file please help me out to solve .
I will be attaching the screenshot of the errors mentioned

Hello,

i am also getting the same, how to resolve this??

After integrating i am getting this error. Updated with new API key address, how to get resolved???

1 Like