> ## Documentation Index
> Fetch the complete documentation index at: https://takeprofit.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Indicators API

> Compute technical indicators on TakeProfit market data: query the built-in catalog and historical values over REST, or stream live values over WebSocket - all using the same Platform API key.

The Indicators API runs TakeProfit's built-in indicators, and the indicators you wrote or bought, on our market data and returns the values, so you get a moving average, RSI, or volume profile without reimplementing them yourself. History comes over REST, live values over WebSocket, and the same `x-api-key` header works for both. Your API key requires the `INDICATOR:ALL:READ` scope. Enable it alongside `MARKETDATA:ALL:READ` when [creating your token](https://takeprofit.com/docs/platform-api/authentication.md) so a single key serves both market data and indicators.

```bash theme={null}
curl -G "https://public-api.takeprofit.com/api/v1/indicators/sma/values" \
  -H "x-api-key: $TAKEPROFIT_API_KEY" \
  --data-urlencode "exchange=CXBNCE" \
  --data-urlencode "symbol=BTC/USDT" \
  --data-urlencode "timeframe=5m" \
  --data-urlencode "param.length=20" \
  --data-urlencode "limit=100"
```

Base URLs: `https://public-api.takeprofit.com/api/v1/indicators` for REST and `wss://public-api.takeprofit.com/api/v1/indicators` for the stream. Securities and candles remain on the [market data endpoints](https://takeprofit.com/docs/platform-api/rest/overview); the indicator endpoints handle only indicator computation.

## Endpoints

| Endpoint | Returns |
| - | - |
| `GET /` | The built-in indicators with their latest published version. |
| `GET /{uid}` | One indicator: parameter IDs, types, defaults and ranges, output IDs. |
| `GET /{uid}/values` | The indicator computed over a window of bars. |
| `GET /timeframes` | Timeframe IDs the values endpoint and the stream accept. |
| `/{uid}/stream` over WebSocket | A snapshot of the latest bars, then an update on every change. See [Live indicator stream](https://takeprofit.com/docs/platform-api/indicators/stream.md). |

Paths are relative to the base URLs above. Each endpoint page in the sidebar lists its parameters and response fields and has a **Try it** playground. Every endpoint answers `GET` only, and unknown query parameters are rejected with `400`.

## How a request is put together

* **Identify a security using `exchange` and `symbol`** — the same pair returned by the market data [Securities endpoints](https://takeprofit.com/docs/platform-api/rest/overview). Internal IDs are not accepted.
* **The indicator is its `uid`**, such as `sma`, `ema` or `rsi` for built-in indicators. The longer `slug`, `simple_moving_average` for SMA, works in its place. Both come from the catalog, `GET /`.
* **Pin `version` in production.** Without it the latest published version runs, and a new version can change the outputs. A client that pins a version is never affected by a release.
* **Parameters go in `param.<id>`**, for example `param.length=20`. The IDs, accepted types, ranges and options are listed by `GET /{uid}`. Omitted parameters take the indicator's defaults, and the response echoes the resolved values in `meta.params`.
* **Outputs are keyed by ID.** Every bar carries a `values` object keyed by the output IDs from the indicator details. Pass the `outputs` parameter to filter the response down to specific IDs.

## Your own and purchased indicators

The same endpoints run indicators you wrote in TakeProfit and indicators you bought in the Marketplace, computed under the account that owns the API key.

* **Use the indicator's `uid` from TakeProfit.** The catalog, `GET /`, lists only built-in indicators, and these indicators have no slug.
* **`version` is required.** Without it the request is rejected with `400` and code `invalid_argument`.
* **Another account's indicator, one you have not bought, and one that does not exist all return the same `404`.**
* **Prices are the same** as for built-in indicators.
* **The first request after publishing a version can take a few seconds** while the script is compiled.
* **Strategies and indicators that use external data are not served** and return `404`.

```bash theme={null}
curl -G "https://public-api.takeprofit.com/api/v1/indicators/$INDICATOR_UID/values" \
  -H "x-api-key: $TAKEPROFIT_API_KEY" \
  --data-urlencode "version=1" \
  --data-urlencode "exchange=CXBNCE" \
  --data-urlencode "symbol=BTC/USDT" \
  --data-urlencode "timeframe=5m"
```

## The computed window

A bar is one computed point of the indicator, one per candle of the chosen timeframe. `GET /{uid}/values` needs only `exchange`, `symbol`, and `timeframe`. Left alone, it computes the indicator over the last 1,000 bars using default parameters.

| Parameter | Notes |
| - | - |
| `from` | Unix seconds or an RFC3339 timestamp. The window starts there and runs forward. |
| `to` | Greater than `from`. Without `from` the window ends here, now by default, and runs backwards. |
| `period` | Window length in seconds, counted forward from `from` or backwards from `to`. Not accepted together with `limit`. |
| `limit` | Bar count counted from whichever end you pinned, 1,000 by default. Not accepted together with `period`. |
| `sessionType` | `MAINSESSION`, `PRE_MARKET`, `POST_MARKET`; repeat it or pass comma-separated values. All sessions by default. |

Window parameters work just like they do on the [candles endpoint](https://takeprofit.com/docs/platform-api/rest/overview): combining `from` and `to` defines a complete window, so neither `period` nor `limit` can be added.

A time window holds at most 10,000 bars; a wider one is rejected with `400` and code `too_much_data`. The count is estimated as if the security traded around the clock, so for a long stretch of a security with trading sessions use `limit` instead. The indicator is computed over the 10,000 most recent bars: a window that starts before them is answered from what was computed, with `"historyComplete": false`, and `hasMoreBefore` tells whether the security has bars before the window. Tick timeframes such as `1t` or `50t` take only `limit`: tick bars have no fixed duration, so `from`, `to` and `period` are rejected with `400`.

## Reading the bars

* **The last bar is usually still forming.** Every bar carries `closed`; the forming bar has `"closed": false` and its values change until the bar closes. Use bars with `"closed": true` for signals.
* **Missing values are absent, not null.** During an indicator's warm-up, or on a bar where an output has no value, the output ID is simply missing from `values`.
* **Shifted values stay on their bar.** An indicator that draws a value on another bar, as Alligator does with its lines, keeps it on the bar it was computed for and reports the shift in the bar's `offsets`.
* **Values are JSON numbers**, unlike the decimal strings of the market data endpoints.

## Credits

The indicator endpoints draw from the same quotas as the market data endpoints: 100,000 REST credits per 60 seconds and 1,000 stream credits per 300 seconds, shared across all API keys on your account. The windows, headers and the `429` behavior are described in [Credits and limits](https://takeprofit.com/docs/platform-api/limits.md).

| Request | Price |
| - | - |
| `GET /`, `GET /{uid}`, `GET /timeframes` | 1,000 credits |
| `GET /{uid}/values`, up to 5,000 bars | 2,000 credits, or 2 credits per returned bar if that is more |
| `GET /{uid}/values`, 5,001 to 10,000 bars | 4,000 credits, or 2 credits per returned bar if that is more |
| Stream subscription | 25 credits when the computation is accepted, and again in every 300-second window the connection remains open |

Only a successful response is billed: rejected requests, script failures (`422`), timeouts (`504`) and an unavailable upstream (`503`) cost nothing.

## Errors

Every failure returns an HTTP status code and a JSON body: `{"error": {"code": "...", "message": "..."}}`. Branch on `code` — it is stable, whereas `message` is intended for human readability.

| Status | Code | Meaning |
| - | - | - |
| `400` | `invalid_argument` | A malformed or unknown query parameter, an unknown `param.<id>` or a value out of its range |
| `400` | `too_much_data` | The time window holds more than 10,000 bars; narrow it or use a longer timeframe. It is never a rate limit |
| `401` | `unauthenticated` | The API key is missing or invalid |
| `403` | `permission_denied` | The key lacks the `INDICATOR:ALL:READ` scope, or the account's plan does not include the requested history depth |
| `404` | `not_found` | The exchange or security is not served, or the indicator is not available |
| `422` | `script_error` | The indicator script failed to compile, raised an error or ran over its computation time limit |
| `429` | `rate_limited` | Not enough credits left in the window; retry after `Retry-After` seconds |
| `502`, `503`, `504` | `bad_gateway`, `unavailable`, `deadline_exceeded` | A temporary upstream problem; retry with exponential backoff |

New here? [Quickstart](https://takeprofit.com/docs/platform-api/indicators/quickstart.md) walks through the catalog, a computed window and the live stream, and [Authentication](https://takeprofit.com/docs/platform-api/authentication.md) covers creating a key.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.