Integration – Direct

You can query the API with a simple GET request. All that is needed is to send your request to: https://api.taapi.io with at least the mandatory parameters.

Pros

  • Easy to get started
  • Works with NodeJS, PHP, Python, Ruby, Curl or via browser
  • Supports bulk queries

Cons

  • Only Binance supported
  • Candles only update on candle close

Getting started

To get started, simply make an HTTPS GET Request or call in your browser:

[GET] https://api.taapi.io/rsi?secret=MY_SECRET&exchange=binance&symbol=BTC/USDT&interval=1h

A JSON Response is returned:

{
  "value": 69.8259211745199
}

Mandatory Parameters

Using this “Direct” method requires at least the below parameters:

ParameterTypeDescription
secretStringThe secret which is emailed to you when you Request an API key.
exchangeStringThe exchange you want to calculate TA from: [“binance”] . So far TAAPI.IO only supports Binance for this integration method. For other crypto / stock exchanges, please refer to our Client or Manual integration methods.
symbolStringSymbol names are always upper-case, with the coin separated by a forward slash and the market: COIN/MARKET. Example: ‘BTC/USDT’ Bitcoin to Tether, or LTC/BTC Litecoin to Bitcoin.
intervalStringInterval or time frame: Binance have the following time frames or intervals: [“1m”, “3m”, “5m”, “15m”, “30m”, “1h”, “2h”, “4h”, “6h”, “8h”, “12h”, “1d”, “3d”, “1w”, “1M”].

Depending on the indicator you call, there may or may not be more mandatory parameters. Additionally, there may be several other optional paramters, also depending on the indicator. Please refer to the Indicators page for more information.

Optional Parameters

Below is a list of optional parameters that all the indicators will take:

ParameterType
backtrackIntegerThis ‘backtrack’ parameter, removes candles from the data set, and thus calculates the indicator value, x amount of candles back. So, if you’re fetching the RSI on the hourly, and you want to know what the RSI was 5 hours ago, set backtrack=5. Default here is 0, and a max of 50.
chartStringThis ‘chart’ parameter, takes one of 2 values: [candles, heikinashi]. Candles are default, but if you set this to ‘heikinashi’, the indicator values will be calculated using Heikin Ashi candles. Note: Pro & Expert Plans only.

Examples

Below you’ll find some examples, how to connect, authenticate and query the API:

NodeJS

// Require taapi (using the NPM client: npm i taapi --save)
const taapi = require("taapi");
 
// Setup client with authentication
const client = taapi.client("MY_SECRET");
 
// Get the BTC/USDT RSI value on the 1 minute time frame from binance
client.getIndicator("rsi", "binance", "BTC/USDT", "1m").then(function(result) {
    console.log("Result: ", result);
});

// --- Or ---

// Require axios: npm i axios
var axios = require('axios');

axios.get('https://api.taapi.io/rsi', {
  params: {
    secret: MY_SECRET,
    exchange: "binance",
    symbol: "BTC/USDT",
    interval: "1h",
  }
})
.then(function (response) {
  console.log(response.data);
})
.catch(function (error) {
  console.log(error.response.data);
});

PHP

<?php

$endpoint = 'rsi';

$query = http_build_query(array(
  'secret' => 'MY_SECRET',
  'exchange' => 'binance',
  'symbol' => 'BTC/USDT',
  'interval' => '1h'
));

// Define endpoint
$url = "https://api.taapi.io/{$endpoint}?{$query}";

// create curl resource 
$ch = curl_init(); 

// set url 
curl_setopt($ch, CURLOPT_URL, $url); 

//return the transfer as a string 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 

// $output contains the output string 
$output = curl_exec($ch); 

// close curl resource to free up system resources 
curl_close($ch);

// View result
print_r(json_decode($output));

Python

# Import the requests library 
import requests 

# Define indicator
indicator = "rsi"
  
# Define endpoint 
endpoint = f"https://api.taapi.io/{indicator}"
  
# Define a parameters dict for the parameters to be sent to the API 
parameters = {
    'secret': 'MY_SECRET',
    'exchange': 'binance',
    'symbol': 'BTC/USDT',
    'interval': '1h'
    } 
  
# Send get request and save the response as response object 
response = requests.get(url = endpoint, params = parameters)
  
# Extract data in json format 
result = response.json() 

# Print result
print(result)

Ruby

require 'net/http'
uri = URI("https://api.taapi.io/rsi?secret=MY_SECRET&exchange=binance&symbol=BTC/USDT&interval=1h")
puts Net::HTTP.get(uri)

Curl

curl "https://api.taapi.io/rsi?secret=MY_SECRET&exchange=binance&symbol=BTC/USDT&interval=1h"

Bulk Queries

Pro & Expert Plans only

Bulk queries provides a convenient way of fetching more than one indicator calculations in just one call. This feature is only available for Pro & Expert plans, as these are the only plans providing more than one call per second.

Getting started

To get started you must send a POST with a JSON body containing your query, to the endpoint /bulk

[POST] https://api.taapi.io/bulk

Query

The query is a simple JSON object, and at the top level you will need to supply your secret token, and below that you define the “construct”. This is also an object defining the basis for the query, specifically, which candle data is needed for the calculations.

Using this method means that TAAPI.IO is fetching candle data from the exchanges. The exchanges unfortunately have a habit of suddenly changing their rate-limits based on their load / terms of service etc…, this means that TAAPI.IO will in no way guarantee that there won’t be a problem in our data synchronization, and TAAPI.IO will in no way be held responsible for any result due to miss-calculation of indicator values based on incorrect / or incomplete candle data. Please check out our complete Terms of service. To validate and verify exchange data your-self, please use our Client or Manual integration methods. This being said, we of course do our absolute best to adapt to any changes that the exchanges may have, but we simply cannot legally guarantee 100% error free candles 100% of the time!

{
    "secret": "MY_SECRET",
    "construct": {
        "exchange": "binance",
        "symbol": "BTC/USDT",
        "interval": "1h",
        "indicators": [
	    {
                // Relative Strength Index
	        "indicator": "rsi"
	    },
            {
                // Chaikin Money Flow
	        "indicator": "cmf",
	        "period": 20 // Override the default 14
	    },
	    {
                // MACD Backtracked 1
                "id": "My custom id",
	        "indicator": "macd",
	        "backtrack": 1
	    }
        ]
    }
}

The construct object takes 4 parameters:

  • exchange: For now we support only one exchange for this direct method “binance”.
  • symbol: For instance “BTC/USDT”.
  • interval: Timeframe or candle size. Examples might be ’15m’, ‘1h’, ‘1d’. More info above.
  • indicators: This is an array containing the individual queries.

Indicators

Each element in the above ‘indicators’ array, must be an object containing at least one paramter: ‘indicator‘. This is the name (or endpoint name) of the indicator.

For each indicator object, you may specify the same parameters as you would with the single queries, simply add them to the indicator object.

Custom ID’s are useful so that you can keep track of which indicator call returns which result. By default, the response will show an ID comprised of:

<exchange>_<symbol>_<timeframe>_<indicator>_<[parameters]>

However if you’d explicitly like to name the ID, simply add an ‘id’ parameter to the query.

Response

{
  "data": [
    {
      "id": "binance_BTC/USDT_1h_rsi_0",
      "result": {
        "value": 54.32482848167602
      },
      "errors": []
    },
    {
      "id": "binance_BTC/USDT_1h_cmf_20_0",
      "result": {
        "value": -0.08128034485998774
      },
      "errors": []
    },
    {
      "id": "My custom id",
      "result": {
        "valueMACD": 21.057252245545897,
        "valueMACDSignal": 13.564391223138724,
        "valueMACDHist": 7.4928610224071726
      },
      "errors": []
    }
  ]
}

Examples

NodeJS

// Require axios (npm i axios --save)
const axios = require("axios");

await axios.post("https://api.taapi.io/bulk", {
    "secret": "MY_SECRET",
    "construct": {
        "exchange": "binance",
        "symbol": "BTC/USDT",
        "interval": "1h",
        "indicators": [
            {
                // Relative Strength Index
                "indicator": "rsi"
            },
            {
                // Chaikin Money Flow
                "indicator": "cmf",
                "period": 20 // Override the default 14
            },
            {
                // MACD Backtracked 1
                "id": "My custom id",
                "indicator": "macd",
                "backtrack": 1
            }
        ]
    }            
})
.then( response => {
    console.log(response);
})
.catch( error => {
    console.error(error)
});

PHP

<?php

// Define endpoint
$url = "https://api.taapi.io/bulk";

// Create curl resource 
$ch = curl_init( $url );

// Setup query with JSON payload to be sent via POST.
$query = json_encode( (object) array(

    "secret" => "MY_SECRET",
    "construct" => (object) array(
        "exchange" => "binance",
        "symbol" => "BTC/USDT",
        "interval" => "1h",
        "indicators" => array(
            (object) array(
                // Relative Strength Index
	        "indicator" => "rsi"
            ),
            (object) array(
                // Chaikin Money Flow
	        "indicator" => "cmf",
	        "period" => 20,
            ),
            (object) array(
                // MACD Backtracked 1
                "id" => "My custom id",
                "indicator" => "macd",
                "backtrack" => 1
            ),
        )
    )

));

// Add query to CURL
curl_setopt( $ch, CURLOPT_POSTFIELDS, $query );

// Define the content-type to JSON
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));

// Return response instead of printing.
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );

// Send request.
$result = curl_exec($ch);

// Close curl resource to free up system resources 
curl_close($ch);

// View result
print_r(json_decode($result)->data);

Rate limits

Rate limits work the same way as with single calls. Each indicator in a bulk call will count as one call. As an example, if you call 7 indicators in bulk, this will count as 7 indicator calls.

That’s it!

As always, feedback, comments are greatly appreciated!