[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. Additionally, this is the endpoint you need for fetching historical data.

Pros

  • Easy to get started
  • Works with NodeJS, PHP, Python, Ruby, Curl or via browser
  • Historical data

Getting started

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

https://api.taapi.io/rsi?secret=API_KEY&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. Mandatory for type=crypto only.
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.
typeString[crypto, stocks] – defaults to ‘crypto’. This tells which asset class you’re querying.
resultsInt/’max’The number of indicator results to be returned. Ex. 20 will return the last 20 RSI results for instance. Setting ‘max’ as a string will return either every historical data point available or the max allowed by your plan.
addResultTimestampBoolean[true,false] – defaults to false. By setting to true the API will return a timestamp with every result (real-time and historical) to which candle the value corresponds. This is helpful when requesting historical data.
gapsBoolean[true, false] – defaults to true. By setting to false, the API will ensure that there are no candles missing. This often happens on lower timeframes in thin markets. Gaps will be filled by a new candle with 0 volume, and OHLC set the the close price of the latest candle with volume.

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 & Wrappers

TAAPI.IO comes with a variety of 3rd party integrations and wrappers, some of which includes NPM, PHP and ‘no-code’ integrations such as Make.com. Please take a moment to go through this list Utilities / 3rd party integrations.

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);
});
// Import
import Taapi from 'taapi';

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

taapi.getIndicator("rsi", "AAPL", "1h", {
    type: "stocks",
}).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"

That’s it!

As always, feedback, comments are greatly appreciated!