[GET] REST – 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 and Bitstamp supported

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 the indicator from: binance or bitstamp. More exchanges supported natively are coming soon. For other crypto / stock exchanges, please refer to our Client or Manual integration methods.
symbolStringSymbol names are always uppercase, with the coin separated by a forward slash and the market: COIN/MARKET. For example: BTC/USDT Bitcoin to Tether, or LTC/BTC Litecoin to Bitcoin…
intervalStringInterval or time frame: We support the following time frames: 1m5m15m30m1h2h4h12h1d1w. So if you’re interested in values on hourly candles, use interval=1h, for daily values use interval=1d, etc.

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:

ParameterTypeDescription
backtrackIntegerThe backtrack parameter removes candles from the data set and calculates the indicator value X amount of candles back. So, if you’re fetching an indicator on the hourly and you want to know what the indicator value was 5 hours ago, set backtrack=5. The default is 0 and a maximum is 50.
chartStringThe chart parameter accepts one of two values: candles or heikinashicandles is the 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.

{
    "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: binance or bitstamp
  • 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 IDs 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);

Python

# Import the requests library 
import requests 
  
# Define endpoint 
endpoint = "https://api.taapi.io/bulk"
  
# Define a JSON body with parameters to be sent to the API 
parameters = {
    "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
	    }
        ]
    }
}
  
# Send POST request and save the response as response object 
response = requests.post(url = endpoint, json = parameters)
  
# Extract data in json format 
result = response.json() 

# Print result
print(result)

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!