Data API
For simplicity, we can create an api that runs in Kubernetes that queries QuestDB for candlesticks. For this, I'm using Hapi. You are free to use Express or whichever API framework you like.
Routes
I'm not going to go over how to create routes but in a simplistic view, the idea is to use QuestDb's rest api to query candlesticks. Let's look at the query and not it's very similar to our Grafana query:
- Note that because tables can't have certain symbol, we have to replace our underscore and replace it with '/'.
- We use SAMPLE BY in order to downsample to different timeframes
- We add a LIMIT to the query so it limits the amount of data returned
- We use encodeURIComponent to ensure the query get's parameratized properly