What to look for in an API for a chart-reading trading bot
People ask for an API that can “read charts” for a trading bot. A bot never looks at a chart. It reads the numbers the chart is drawn from: the candles, and indicators such as RSI, moving averages and SuperTrend. So the real question is which API gives a bot those numbers in a form it can act on, quickly and without surprises.
This post gives you a short checklist, then puts it to work. You’ll send one request for RSI, EMA and SuperTrend on three timeframes of BTCUSDT, and build a small Python decision loop that turns the answer into BUY, SELL or WAIT, with the reasons printed next to it.
Every request and output below is from a live run on 1 December 2026.
The short answer: what to look for
- Calculated indicators, not only candles. Candle APIs leave you to write, test and maintain every formula yourself. An indicator API returns the RSI or SuperTrend value directly, calculated the same way every time.
- Several timeframes in one request. Almost every chart-reading rule looks at more than one timeframe: a higher one for the trend, a lower one for timing. If each timeframe costs a separate request, your rate limit goes three times as fast and the values can come from slightly different moments.
- Values from closed candles. An indicator on the candle that’s still forming changes until it closes. A bot that acts on it can enter on a signal that’s gone a minute later. You want a way to ask for the last closed candle.
- The markets you trade, under one API. Crypto exchanges and US stocks each have their own symbols and quirks. One API that covers both saves you a connector per market.
- Clear errors and limits. A bot runs unattended. It needs to know the difference between “wait two seconds and retry” and “this request will never work”.
- History, for testing rules. Before a rule trades, run it over past values. The API should give you a series, not only the latest number.
- Streaming, for later. Polling every few minutes is fine to start. When it isn’t, you want the same indicators pushed to you over a WebSocket, without rewriting the bot.
The rest of this post shows what that looks like with TAAPI.IO, which calculates 263 indicators for crypto pairs and US stocks.
One request for three timeframes
The example bot uses a classic multi-timeframe setup:
| Timeframe | Role | Indicators |
|---|---|---|
| 4h | Trend: which way are we allowed to trade? | EMA 50 and EMA 200, SuperTrend |
| 1h | Direction: does the middle timeframe agree? | SuperTrend, RSI 14 |
| 15m | Timing: is there a pullback to enter on? | RSI 14, close price |
The bulk endpoint, POST https://v2.taapi.io/bulk, takes a list of constructs. A construct is one exchange, symbol and timeframe, with as many indicators as you like. So three timeframes are three constructs in one request. You choose an id for each construct and each indicator, and the response uses those ids as keys.
Every indicator here has "backtrack": 1. That skips the candle that’s still forming and returns the value of the last closed candle (item 3 on the checklist).
curl -X POST https://v2.taapi.io/bulk \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"constructs": [
{ "id": "tf_4h", "exchange": "binance", "symbol": "BTCUSDT", "timeframe": "4h",
"indicators": [
{ "id": "ema50", "indicator": "ema", "period": 50, "backtrack": 1 },
{ "id": "ema200", "indicator": "ema", "period": 200, "backtrack": 1 },
{ "id": "supertrend", "indicator": "supertrend", "backtrack": 1 }
] },
{ "id": "tf_1h", "exchange": "binance", "symbol": "BTCUSDT", "timeframe": "1h",
"indicators": [
{ "id": "rsi", "indicator": "rsi", "period": 14, "backtrack": 1 },
{ "id": "supertrend", "indicator": "supertrend", "backtrack": 1 }
] },
{ "id": "tf_15m", "exchange": "binance", "symbol": "BTCUSDT", "timeframe": "15m",
"indicators": [
{ "id": "rsi", "indicator": "rsi", "period": 14, "backtrack": 1 },
{ "id": "price", "indicator": "price", "backtrack": 1 }
] }
]
}'
This is the real response, sent at 20:31 UTC and formatted for reading (the values are unchanged):
{
"tf_4h": {
"ema50": { "value": [60441.44270850574], "timestamp": [1796140800] },
"ema200": { "value": [66824.80656489369], "timestamp": [1796140800] },
"supertrend": { "value": [57728.32603997679], "valueAdvice": ["long"], "timestamp": [1796140800] }
},
"tf_1h": {
"rsi": { "value": [54.10872188626686], "timestamp": [1796151600] },
"supertrend": { "value": [60027.2912187682], "valueAdvice": ["long"], "timestamp": [1796151600] }
},
"tf_15m": {
"rsi": { "value": [44.87910039011], "timestamp": [1796156100] },
"price": { "value": [60576.01], "timestamp": [1796156100] }
}
}
How to read it:
- Timestamps are candle open times, in Unix seconds.
1796140800is the 4h candle that opened at 16:00 UTC and closed at 20:00; the 1h value is the 19:00 candle, and the 15m values are the 20:15 candle. All three are the latest closed candle on their timeframe. - SuperTrend returns two things: the line itself (
value) and its direction (valueAdvice,longorshort). The bot only needs the direction. The line is useful later as a trailing stop. - The 4h picture is mixed. SuperTrend says
long, but EMA 50 (60,441) is still well below EMA 200 (66,825). Price has bounced, but the longer trend hasn’t turned. Keep that in mind for the next step.
The same request works for US stocks: use "exchange": "stocks" and a ticker such as "symbol": "AAPL".
Which plan does this need?
The number of constructs per bulk request depends on your plan: 1 on Basic, 3 on Pro, 10 on Expert. There’s no limit on indicators inside a construct. This three-timeframe request needs Pro or higher. On Basic, send one request per timeframe instead; the decision code below doesn’t change. See pricing for the full comparison.
The decision loop
Now turn the numbers into a decision. The rules below are an example only, not trading advice and not a strategy to trade as it is. They’re here to show the structure most chart-reading bots share: filter by trend, confirm the direction, then time the entry.
- Trend (4h):
upwhen SuperTrend islongand EMA 50 is above EMA 200.downwhen SuperTrend isshortand EMA 50 is below EMA 200. Anything else ismixed, and a mixed trend means no trade. - BUY in an uptrend, when the 1h SuperTrend is also
long, the 1h RSI is below 70 (not overbought) and the 15m RSI has dipped below 40 (a pullback). - SELL is the mirror: downtrend, 1h SuperTrend
short, 1h RSI above 30, 15m RSI above 60. - Otherwise WAIT.
You need Python 3.9 or newer and the requests package (pip install requests). Put your API key in an environment variable so it never ends up in your code:
export TAAPI_API_KEY="your-api-key"
Save this as bot.py:
import os
import sys
import time
from datetime import datetime, timezone
import requests
API_KEY = os.environ["TAAPI_API_KEY"]
SYMBOL = "BTCUSDT"
# One construct per timeframe. backtrack=1 means "the last closed candle",
# so a value can't change after the bot has acted on it.
def construct(tf, indicators):
return {"id": f"tf_{tf}", "exchange": "binance", "symbol": SYMBOL,
"timeframe": tf, "indicators": indicators}
BULK = {"constructs": [
construct("4h", [
{"id": "ema50", "indicator": "ema", "period": 50, "backtrack": 1},
{"id": "ema200", "indicator": "ema", "period": 200, "backtrack": 1},
{"id": "supertrend", "indicator": "supertrend", "backtrack": 1},
]),
construct("1h", [
{"id": "rsi", "indicator": "rsi", "period": 14, "backtrack": 1},
{"id": "supertrend", "indicator": "supertrend", "backtrack": 1},
]),
construct("15m", [
{"id": "rsi", "indicator": "rsi", "period": 14, "backtrack": 1},
{"id": "price", "indicator": "price", "backtrack": 1},
]),
]}
def fetch(session):
"""POST /bulk, retrying only the answers that can succeed on a retry."""
for attempt in range(4):
r = session.post("https://v2.taapi.io/bulk", json=BULK, timeout=15)
if r.status_code == 200:
return r.json()
retry_after = r.json().get("retryAfter") if r.status_code == 429 else None
if r.status_code == 202: # candles being fetched for the first time
wait = 2
elif retry_after is not None: # request-rate limit: wait as told
wait = retry_after
elif r.status_code >= 500: # server hiccup: back off
wait = 2 ** attempt
else: # 400, 401, construct limit: fix the request
sys.exit(f"{r.status_code}: {r.text}")
time.sleep(wait)
sys.exit("Gave up after 4 attempts")
def decide(d):
"""Example rules only, not trading advice. Returns (action, reasons)."""
h4, h1, m15 = d["tf_4h"], d["tf_1h"], d["tf_15m"]
ema50, ema200 = h4["ema50"]["value"][0], h4["ema200"]["value"][0]
st_4h = h4["supertrend"]["valueAdvice"][0]
st_1h = h1["supertrend"]["valueAdvice"][0]
rsi_1h, rsi_15m = h1["rsi"]["value"][0], m15["rsi"]["value"][0]
if st_4h == "long" and ema50 > ema200:
trend = "up"
elif st_4h == "short" and ema50 < ema200:
trend = "down"
else:
trend = "mixed"
reasons = [
f"4h trend: {trend} (SuperTrend {st_4h}, EMA50 {ema50:,.0f} vs EMA200 {ema200:,.0f})",
f"1h SuperTrend: {st_1h}, RSI {rsi_1h:.1f}",
f"15m RSI: {rsi_15m:.1f}, close {m15['price']['value'][0]:,.2f}",
]
if trend == "up" and st_1h == "long" and rsi_1h < 70 and rsi_15m < 40:
return "BUY", reasons
if trend == "down" and st_1h == "short" and rsi_1h > 30 and rsi_15m > 60:
return "SELL", reasons
return "WAIT", reasons
def seconds_to_next_15m_close():
now = time.time()
return 900 - now % 900 + 5 # 5 s after the candle closes
def main():
session = requests.Session()
session.headers["Authorization"] = f"Bearer {API_KEY}"
while True:
data = fetch(session)
errors = [f"{k}: {v['_error']}" for k, v in data.items() if v.get("_error")]
if errors: # e.g. a typo in the symbol
action, reasons = "SKIP", errors
else:
action, reasons = decide(data)
stamp = datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M UTC")
print(f"{stamp} {SYMBOL} -> {action}")
for reason in reasons:
print(f" {reason}")
if "--once" in sys.argv:
break
time.sleep(seconds_to_next_15m_close())
if __name__ == "__main__":
main()
What each part does:
BULKis the request from the previous section, built from a small helper so you can change the symbol in one place.fetchsends it and retries only what can succeed on a retry: a202(the API is loading candles for that market for the first time), a429withretryAfter(the request-rate limit) and server errors. A bad key, a bad request or too many constructs stops the bot with the API’s message, because retrying won’t fix them. The full list is in errors.decideis the rule set. It returns the action and the reasons, so the log shows why the bot did nothing, which is what it does most of the time.mainruns once, then wakes up 5 seconds after each 15-minute candle closes. That’s when the 15m values change, so polling more often would only repeat the same answer.
Run it once to check everything works:
python bot.py --once
This is the real output from the run above:
2026-12-01 20:31 UTC BTCUSDT -> WAIT
4h trend: mixed (SuperTrend long, EMA50 60,441 vs EMA200 66,825)
1h SuperTrend: long, RSI 54.1
15m RSI: 44.9, close 60,576.01
WAIT, and the first line says why: the 4h SuperTrend has turned long, but EMA 50 is still under EMA 200, so the trend filter calls it mixed. Even if the 15m RSI had dropped below 40, this rule set would stay out. That’s the trend filter doing its job: no entries on a bounce until the longer trend agrees.
Then run it without --once and leave it going. It prints the same kind of block 5 seconds after every 15-minute candle closes, one request per cycle, so a full day costs 96 requests.
When one market fails
If a construct fails, for example because of a typo in the symbol, the bulk request still returns 200. The failed construct comes back with an _error message instead of values, and the bot skips that cycle rather than crashing. This is the real output with BTCUSDTX as the symbol:
2026-12-01 20:30 UTC BTCUSDTX -> SKIP
tf_4h: Failed to fetch candles: 404 Not Found — check exchange, symbol and timeframe parameters
tf_1h: Failed to fetch candles: 404 Not Found — check exchange, symbol and timeframe parameters
tf_15m: Failed to fetch candles: 404 Not Found — check exchange, symbol and timeframe parameters
Taking it further
The script prints decisions and places no orders, which is where every bot should start. Before you connect it to an exchange account:
- Test the rules on history. Add
"results": 300to an indicator and you get the last 300 values instead of one, oldest first. Rundecideover them and count how often each action fired and what happened next. How far back you can go depends on your plan: 50 candles on Basic, 300 on Pro and 2,000 on Expert. See historical values. - Watch more markets. Add constructs for more symbols, up to your plan’s limit. Note that two constructs can’t use the same exchange, symbol and timeframe.
- Use SuperTrend’s line as a stop. The
valuefield is a price below the market in an uptrend; many traders use it as a trailing stop. - Stop polling. When 15 minutes is too slow, stream the same indicators over WebSocket and run
decideon every update. The WebSocket tutorial walks through it in Python and Node.js.
Building it with an AI agent
If you’d rather have Claude Code, Cursor or another coding agent write this for you, point it at taapi.io/llms.txt. It describes the endpoints, the bulk format and the errors in a form agents read well, so the agent can wire in the indicators without guessing. A prompt as short as this is enough:
Using the TAAPI.IO API (read https://taapi.io/llms.txt first, API key in the
TAAPI_API_KEY environment variable), write a Python bot that every 15 minutes
fetches EMA 50/200 and SuperTrend on 4h, SuperTrend and RSI on 1h, and RSI on
15m for BTCUSDT in one bulk request, using closed candles only, and prints
BUY, SELL or WAIT with the reasons.
There’s also an agent offer: Expert limits, with 10 constructs per bulk call and 2,000 candles of history, at a reduced price for people building with agents.
FAQ
What is the best API for a chart-reading trading bot?
Look for one that returns calculated indicators rather than only candles, lets you ask for several timeframes in one request, can give you values from closed candles only, covers the markets you trade, and has a streaming option for when polling gets too slow. TAAPI.IO does all of these for crypto pairs and US stocks, with 263 indicators.
Can a trading bot read a chart image?
It can send a screenshot to a vision model, but the model has to estimate values from pixels, and it costs far more per check than reading a number. A bot that reads RSI, EMA and SuperTrend as JSON gets exact values for the candle it asked about, in a few hundred bytes.
Which indicators work best for a crypto trading bot?
No indicator works on its own, and none is reliably best. A common, testable structure is a trend filter on a higher timeframe (SuperTrend, or EMA 50 against EMA 200), a direction check on the middle timeframe, and a timing indicator such as RSI on the lowest one. Test any rule on historical values before it trades.
Do I need a paid plan to request several timeframes at once?
One bulk request can hold one construct (one symbol and timeframe) on Basic, 3 on Pro and 10 on Expert. The three-timeframe request in this tutorial needs Pro or higher. On Basic you can send one request per timeframe instead.