Stochastic Oscillator
Category: Momentum · Updated November 2026
The TAAPI.IO Stochastic API returns k, d values for the Stochastic indicator 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/stoch |
| Outputs | valueK, valueD |
| Markets | Binance, Binance Futures, Bybit, Gate.io, Kraken and US stocks |
| Timeframes | 1m to 1w |
| Delivery | REST, bulk and WebSocket |
Get Stochastic with one API call
This request returns Stochastic for BTCUSDT on 1-hour Binance candles. Add your API key to run it here.
curl -G https://v2.taapi.io/indicator/stoch \ -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/stoch',
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/stoch?${params}`, {
headers: { Authorization: 'Bearer YOUR_API_KEY' },
});
console.log(await res.json());Stochastic API response
This response came from the live API on 9 November 2026. Long lists are shortened here.
{
"valueK": [50.175444100724434],
"valueD": [39.460480439559056],
"timestamp": [1794218400]
}| Field | Type | Description |
|---|---|---|
valueK | number[] | K |
valueD | number[] | D |
timestamp | integer[] | Unix time of each candle, in seconds |
Stochastic 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 |
kPeriod | integer | No | 5 | K period |
dPeriod | integer | No | 3 | D period |
kSmooth | integer | No | 3 | K smooth |
results | integer | No | 1 | Number of values to return, or max |
backtrack | integer | No | 0 | Candles to skip from the most recent |
What is Stochastic?
The Stochastic Oscillator, popularised by George Lane, shows where the close sits within the recent high-low range on a scale of 0 to 100. The idea is that closes cluster near the highs in uptrends and near the lows in downtrends.
Stochastic formula
| Output | Calculation |
|---|---|
| Raw %K | (close − lowest low) ÷ (highest high − lowest low) × 100 |
| %K | Raw %K smoothed by kSmooth |
| %D | Moving average of %K over dPeriod |
How to read Stochastic in your code
| Signal | Meaning | Condition |
|---|---|---|
| Overbought | Close near top of range | valueK above 80 |
| Oversold | Close near bottom of range | valueK below 20 |
| Bullish cross | Momentum turning up | valueK crosses above valueD |
| Bearish cross | Momentum turning down | valueK crosses below valueD |
Limitations: It stays pinned near the extremes during strong trends. Note the defaults: this endpoint uses a 5-period %K, while stochtv follows TradingView's 14. Nothing on this page is financial advice.
Fast, slow and full stochastic
The names describe how much smoothing is applied. The fast stochastic uses raw %K, the slow version smooths %K once, and a full stochastic lets you set every length. On this endpoint, kSmooth controls that smoothing, which makes it a full stochastic.
Three related endpoints are available. stochf returns the unsmoothed fast form, stochtv defaults to 14, 3, 3, and stochrsi applies the same maths to RSI rather than price.
Using the Stochastic in trends
In a rally the close keeps landing near the top of the range, so %K can remain above 80 for a long time. That is the indicator working as designed, and not a reason to sell. Crossovers are generally more useful when taken in the direction of the larger trend: buying oversold crossovers in an uptrend, for instance.
The API default for kPeriod is 5, which is much faster than the 14 most charts use. Set it explicitly if you're comparing values with a chart.
Detect a Stochastic crossover in oversold with Python
This looks for %K crossing above %D while %K is below 20, using the common 14, 3, 3 settings on the last two closed candles.
curl -G https://v2.taapi.io/indicator/stoch \ -H "Authorization: Bearer YOUR_API_KEY" \ --data-urlencode "exchange=binance" \ --data-urlencode "symbol=BTCUSDT" \ --data-urlencode "timeframe=1h" \ --data-urlencode "kPeriod=14" \ --data-urlencode "dPeriod=3" \ --data-urlencode "kSmooth=3" \ --data-urlencode "results=2" \ --data-urlencode "backtrack=1"
import requests
resp = requests.get(
'https://v2.taapi.io/indicator/stoch',
headers={'Authorization': 'Bearer YOUR_API_KEY'},
params={'exchange': 'binance', 'symbol': 'BTCUSDT', 'timeframe': '1h', 'kPeriod': 14, 'dPeriod': 3, 'kSmooth': 3, 'results': 2, 'backtrack': 1},
)
data = resp.json()
k_prev, k = data['valueK']
d_prev, d = data['valueD']
if k_prev <= d_prev and k > d and k < 20:
print('Bullish crossover in oversold')
elif k_prev >= d_prev and k < d and k > 80:
print('Bearish crossover in overbought')
else:
print(f'No signal, %K is {k:.2f}')Get historical Stochastic 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/stoch \ -H "Authorization: Bearer YOUR_API_KEY" \ --data-urlencode "exchange=binance" \ --data-urlencode "symbol=BTCUSDT" \ --data-urlencode "timeframe=1h" \ --data-urlencode "results=100"
Get Stochastic for multiple symbols
Combine Stochastic 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": "stoch",
"indicator": "stoch"
},
{
"id": "rsi",
"indicator": "rsi"
}
]
}
]
}'Stream Stochastic 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": "stoch",
"exchange": "binance",
"symbol": "BTCUSDT",
"interval": "1m",
"indicator": "stoch"
}Why Stochastic values can differ between platforms
- Default length: This endpoint defaults to a
kPeriodof 5, while most charts default to 14. - Smoothing: Check
kSmoothanddPeriodagainst your chart settings. - Exchange data: Highs and lows vary between exchanges, and the stochastic depends directly on them.
- Open candle: Compare closed candles with
backtrack=1.
Stochastic API FAQ
What does the Stochastic API return?
It returns valueK, valueD, plus a timestamp for the request. Results are JSON.
Is the latest Stochastic 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 Stochastic settings can I change?
You can set kPeriod, dPeriod, kSmooth. See the parameters table above for defaults.
Can I get Stochastic for US stocks?
Yes. Use exchange=stocks with a ticker such as AAPL. US stocks are included on the Pro plan and above.
Why does the Stochastic API not match my chart?
The most likely reason is the default kPeriod of 5. Request kPeriod=14, or use the stochtv endpoint.
Related indicators
See the full list of indicators, or start for free.