GraphQL is a query language for APIs that gives clients the power execute more complex queries, and to ask for exactly what they need and nothing more. To read more about GraphQL, please visit https://graphql.org.
Pros
- Use GraphQL if you are used to working with this.
- Call multiple indicators at once using bulk queries.
- The Client method is also fully integrated to take advantage of bulk queries, but is much simpler to use.
Cons
- Slightly more complicated than the REST Method.
Getting started
You can calculate TA off of any candle set you have. GraphQL always uses POSTs.
Build your query, and send it off to:
[POST] https://api.taapi.io/graphql
Your query must include the parameters secret
, indicator
and candles
. The candles must be sent as key / value pairs in an array:
- timestamp: An integer, unix timestamp in milliseconds
- open: A float, containing the open price of the candle
- high: A float, containing the high price of the candle
- low: A float, containing the low price of the candle
- close: A float, containing the close price of the candle
- volume: A float, containing the volume of the candle
Candles must be submitted in ascending order, being the latest / newest candle last. The order of the keys does not matter.
[
{
'timestamp': 1571320286000, // In milliseconds
'open': 238.32,
'high': 343.12,
'low': 125.94,
'close': 243.48,
'volume': 84342.84823
},
{
'timestamp': 1571320286000, // In milliseconds, optional
'open': 238.32,
'high': 343.12,
'low': 125.94,
'close': 243.48,
'volume': 84342.84823
},
... n candles
]
The amount of candles depends on which indicator is used. If not sure, then send 300 candles. This amount will work for more or less all indicators. However, you can only send a maximum of 500 candles.
Parameters
Below a list of mandatory parameters, needed in your GraphQL Query:
Parameter | Type | Required? | Description |
---|---|---|---|
secret | String | Yes | The secret which is emailed to you when you Request an API key. |
indicator | String | Yes | The Indicator you wish to calculate. |
params | Array | No | An array of indicator parameters to be used with the above indicator. Not required by GraphQL but may be by some indicators. |
candles | Array | Yes | An array with set of key / value pairs containing candle information, ascending order (as described above) |
There may be additional optional / mandatory parameters based on the indicator. Please refer to the Indicator endpoints page for more information.
Example
Below is an example for how to query a single indicator:
query {
indicator(
secret: "MY_SECRET"
indicator: "rsi",
params: [
{ name: "optInTimePeriod", value: "14" }
],
candles: [
{
timestamp: 1234234,
open: 129383,
high: 13282,
low: 123829,
close: 123982,
volume: 12839283,
},{
timestamp: 21234234,
open: 2129383,
high: 213282,
low: 2123829,
close: 2123982,
volume: 212839283,
},
... n candles
]
) {
indicator,
result {
key,
value
}
}
}
Returns
You can ask for the following return parameters:
- indicator: Simply returns the indicator name you asked for
- result: An array of objects with keys:
key
andvalue
. These differ from indicator to indicator. As an example, theMACD
will return the following:
"result": [
{
"key": "valueMACD",
"value": "-7.474092625563571"
},
{
"key": "valueMACDSignal",
"value": "11.345715620548766"
},
{
"key": "valueMACDHist",
"value": "-18.819808246112338"
}
]
And the RSI
will return:
"result": [
{
"key": "value",
"value": "69.8259211745199"
},
]
* All values are returned as strings.
As stated above, the key
value depends on which indicator is called. Unfold each indicator to view their respective return keys.
Bulk Queries
With this method you can query multiple indicators all in 1 call. The amount of calls depends on your plan. Please note that this feature will only be useful on our Pro or Expert plans, as these are the only ones allowing more than 1 call / second. If you are on Free / Basic plan, consider upgrading to take full advantage of Bulk Queries.
For querying multiple indicators, use the indicators endpoint instead of the indicator
Parameters
Parameter | Type | Required? | Description |
---|---|---|---|
secret | String | Yes | The secret which is emailed to you when you Request an API key. |
candles | No | Array | An array with set of key / value pairs containing candle information, ascending order (as described above) |
queries | String | Yes | An array of queries to execute in bulk. Each query will take the same parameters as stated for the above single query, except the secret, [indicator, params, candles]. |
Example
query {
indicators(
secret: "MY_SECRET",
candles: [
{
timestamp: 93249032,
open: 238,
close: 328,
high: 382,
low: 281,
volume: 2839283,
},{
timestamp: 93249032,
open: 238,
close: 328,
high: 382,
low: 281,
volume: 2839283,
},
... n candles
],
queries: [{
indicator: "rsi",
candles: [
{
timestamp: 93249032,
open: 238,
close: 328,
high: 382,
low: 281,
volume: 2839283,
},{
timestamp: 93249032,
open: 238,
close: 328,
high: 382,
low: 281,
volume: 2839283,
},
... n candles
],
},{
indicator: "macd",
params: [
{ name: "optInFastPeriod", value: "8" },
{ name: "optInSlowPeriod", value: "12" },
{ name: "optInSignalPeriod", value: "5" },
],
}]
) {
id,
indicator,
result {
key,
value
}
}
}
There is a lot going on in the above example. Please note:
secret: Mandatory for account validation.
candles: Used by all the queries, unless an individual query specifies other candles to use. These are optional, if every query provides their own candles.
queries: Expects the following parameters:
- indicator: The indicator to be requested.
- params: An array of parameters individual for every indicator endpoint, optional in some cases. This depends on the indicator.
- candles: Needed candles for this query. Optional if default candles are provided.
Rate limits
The same rate limits apply as with the REST Connection method.