Lag
Category: Math · Updated November 2026
The TAAPI.IO Lag API returns real-time and historical values for the Lag math function as JSON, for crypto pairs and US stocks. Send an exchange, symbol and timeframe to get real-time or historical data, with no candles to download and no calculations to maintain.
| Spec | Value |
|---|---|
| Endpoint | GET https://v2.taapi.io/indicator/lag |
| Outputs | value |
| Markets | Binance, Binance Futures, Bybit, Gate.io, Kraken and US stocks |
| Timeframes | 1m to 1w |
| Delivery | REST, bulk and WebSocket |
Get Lag with one API call
This request returns Lag for BTCUSDT on 1-hour Binance candles. Add your API key to run it here.
curl -G https://v2.taapi.io/indicator/lag \ -H "Authorization: Bearer YOUR_API_KEY" \ --data-urlencode "exchange=binance" \ --data-urlencode "symbol=BTCUSDT" \ --data-urlencode "timeframe=1h"
import requests
resp = requests.get(
'https://v2.taapi.io/indicator/lag',
headers={'Authorization': 'Bearer YOUR_API_KEY'},
params={'exchange': 'binance', 'symbol': 'BTCUSDT', 'timeframe': '1h'},
)
print(resp.json())const params = new URLSearchParams({"exchange": "binance", "symbol": "BTCUSDT", "timeframe": "1h"});
const res = await fetch(`https://v2.taapi.io/indicator/lag?${params}`, {
headers: { Authorization: 'Bearer YOUR_API_KEY' },
});
console.log(await res.json());Lag API response
This response came from the live API on 9 November 2026. Long lists are shortened here.
{
"value": [75743.84],
"timestamp": [1794218400]
}| Field | Type | Description |
|---|---|---|
value | number[] | Lag result |
timestamp | integer[] | Unix time of each candle, in seconds |
Lag API parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
exchange | string | Yes | — | binance, binancefutures, bybit, gateio, kraken or stocks |
symbol | string | Yes | — | Pair or ticker, e.g. BTCUSDT or AAPL |
timeframe | string | Yes | — | 1m 5m 15m 1h 4h 1d 1w |
period | number | No | — | Period |
results | integer | No | 1 | Number of values to return, or max |
backtrack | integer | No | 0 | Candles to skip from the most recent |
What is Lag?
Lag is a math function that shifts a series backwards by n candles, which is a basic building block for comparisons. On TAAPI.IO it runs on the candles you request, so you can get the result without doing the calculation on your side.
Lag formula
| Output | Calculation |
|---|---|
| Output | x from n candles ago |
How to read Lag in your code
| Signal | Meaning | Condition |
|---|---|---|
| Result | Function output for the candle | value |
Limitations: Set period to choose the number of candles. Nothing on this page is financial advice.
Compare the last two closed Lag values
Use backtrack=1 to skip the candle still forming, and results=2 to compare the last two closed candles. Arrays run oldest first.
curl -G https://v2.taapi.io/indicator/lag \ -H "Authorization: Bearer YOUR_API_KEY" \ --data-urlencode "exchange=binance" \ --data-urlencode "symbol=BTCUSDT" \ --data-urlencode "timeframe=1h" \ --data-urlencode "results=2" \ --data-urlencode "backtrack=1"
import requests
resp = requests.get(
'https://v2.taapi.io/indicator/lag',
headers={'Authorization': 'Bearer YOUR_API_KEY'},
params={'exchange': 'binance', 'symbol': 'BTCUSDT', 'timeframe': '1h', 'results': 2, 'backtrack': 1},
)
data = resp.json()
prev, last = data['value']
print('value', prev, '->', last)
print('rising' if last > prev else 'falling or flat')Get historical Lag values
Add results to return a series for backtesting or charting. The last element is the most recent candle.
curl -G https://v2.taapi.io/indicator/lag \ -H "Authorization: Bearer YOUR_API_KEY" \ --data-urlencode "exchange=binance" \ --data-urlencode "symbol=BTCUSDT" \ --data-urlencode "timeframe=1h" \ --data-urlencode "results=100"
Get Lag for multiple symbols
Combine Lag with other indicators in one request. Each exchange, symbol and timeframe combination is one construct: Basic allows 1 per request, Pro 3 and Expert 10.
curl -X POST https://v2.taapi.io/bulk \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"constructs": [
{
"id": "btc_1h",
"exchange": "binance",
"symbol": "BTCUSDT",
"timeframe": "1h",
"indicators": [
{
"id": "lag",
"indicator": "lag"
},
{
"id": "rsi",
"indicator": "rsi"
}
]
}
]
}'Stream Lag in real time
Subscribe over WebSocket to receive new values every 5 seconds while the candle is forming. Streaming supports 1m, 5m, 15m and 1h, and uses interval where REST uses timeframe.
{
"type": "subscribe",
"id": "lag",
"exchange": "binance",
"symbol": "BTCUSDT",
"interval": "1m",
"indicator": "lag"
}Lag API FAQ
What does the Lag API return?
It returns value, plus a timestamp for the request. Results are JSON.
Is the latest Lag value final?
No. The newest value belongs to the candle still forming and can change until it closes. Add backtrack=1 to read the last closed candle.
Which Lag settings can I change?
You can set period. See the parameters table above for defaults.
Can I get Lag for US stocks?
Yes. Use exchange=stocks with a ticker such as AAPL. US stocks are included on the Pro plan and above.
Related indicators
See the full list of indicators, or start for free.