[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

Getting started

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

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

A JSON Response is returned:

{
  "value": 69.8259211745199
}

Mandatory Parameters

Our Direct method requires these 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, binancefutures or one of our supported exchanges. 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.
adjustedBoolean[true,false] – defaults to true. By default, we show indicators or candles adjusted for splits. Set this to false if you want your data unadjusted. This is relevant only when querying stocks.
addResultTimestampBoolean[true,false] – defaults to false. By setting to true the API will return a timestamp with every result (real-time and backtracked) to which candle the value corresponds. This is helpful when requesting multiple backtracks.

Headers

Some REST clients may need to be told explicitly which headers to use. Add these headers to the requests if the responses doesn’t match the expected output.

KeyValueDescription
Content-Typeapplication/jsonThe Content-Type representation header is used to indicate the original media type of the resource (prior to any content encoding applied for sending).
Accept-Encodingapplication/jsonThe Accept-Encoding request HTTP header indicates the content encoding (usually a compression algorithm) that the client can understand. The server uses content negotiation to select one of the proposals and informs the client of that choice with the Content-Encoding response header.

Tools, Stocks, Forex & Wrappers

TAAPI.IO comes with a variety of 3rd party integrations and wrappers. Please take a moment to go through this list Utilities / 3rd party integrations.

Here, among others you will find:

Examples

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

NodeJS

Javascript is a great language for coding bots, and using the NodeJS package makes it even simpler. Please refer to the NPM | NodeJS | TypeScript guide for detailed guidelines on this. Or simply call taapi directly using Axios.

// Require taapi (using the NPM client: npm i taapi --save)
const Taapi = require("taapi");
 
// Setup client with authentication
const taapi = new Taapi.default("TAAPI_SECRET");
 
taapi.getIndicator("rsi", "BTC/USDT", "1h").then( rsi => {
    console.log(rsi);
});
// Import
import Taapi from 'taapi';

// Init taapi
const taapi = new Taapi("TAAPI_SECRET");

taapi.getIndicator("rsi", "BTC/USDT", "1h").then( rsi => {
    console.log(rsi);
});
// Require axios: npm i axios
var axios = require('axios');

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

PHP

Use the built in tools in PHP and make CURL request, or use Packagist.org | PHP Composer to make life easier.

<?php

// Require taapi single
require 'vendor/taapi/php-client/single.php';

// Init taapi
$taapi = new TaapiSingle("TAAPI_SECRET");

// Calculate indicator
$result = $taapi->execute("rsi", "binance", "BTC/USDT", "1h", array(
    "period" => 200,
    "backtrack" => 1
));

// Print result
echo "RSI: $result->value";
<?php

$endpoint = 'rsi';

$query = http_build_query(array(
  'secret' => 'TAAPI_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': 'TAAPI_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=TAAPI_SECRET&exchange=binance&symbol=BTC/USDT&interval=1h")
puts Net::HTTP.get(uri)

Curl

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

Bulk Queries

Bulk queries provide a convenient way of fetching more than one indicator calculation in just one request. A maximum of 20 calculations is allowed for every plan, including the free plan.

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": "TAAPI_SECRET",
    "construct": {
        "exchange": "binance",
        "symbol": "BTC/USDT",
        "interval": "1h",
        "indicators": [
	    {
	        "indicator": "rsi"
	    },
            {
	        "indicator": "cmf",
	        "period": 20
	    },
	    {
                "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 parameter: 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

Call taapi using your favourite REST client, or use NPM to do the heavier lifting. Please refer to the NPM | NodeJS | TypeScript guide for detailed guidelines on this.

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

await axios.post("https://api.taapi.io/bulk", {
    "secret": "TAAPI_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

Use the built in tools in PHP and make CURL request, or use Packagist.org | PHP Composer to make life easier.

<?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" => "TAAPI_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 requests

url = "https://api.taapi.io/bulk"

payload = {
    "secret": "TAAPI_SECRET",
    "construct": {
        "exchange": "binance",
        "symbol": "BTC/USDT",
        "interval": "1h",
        "indicators": [{"indicator": "rsi"}, {
                "indicator": "ema",
                "period": 20
            },
{"indicator": "macd"}, {"indicator": "kdj"}]
    }
}
headers = {"Content-Type": "application/json"}

response = requests.request("POST", url, json=payload, headers=headers)

print(response.text)

Rate limits

Bulk queries help you get the most out of your plan. 1 bulk query = 1 API request, even if you include 20 different indicators inside. So you can get up to 20 calculations in a response by only spending 1 API request.

That’s it!

As always, feedback, comments are greatly appreciated!