---
title: "Compile and run Python indicator source against real bars (nothing is saved)"
method: POST
path: "/v1/indicators/py/preview"
---

# Compile and run Python indicator source against real bars (nothing is saved)

`POST /v1/indicators/py/preview`

## Request

- Base URL: `https://app.texttoquant.com/api`
- URL: `https://app.texttoquant.com/api/v1/indicators/py/preview`
- Auth: one of:
  - API key in header `x-api-key`
  - HTTP bearer

## Request body

- object
  - `py_code` string, required
  - `symbol` string
  - `timeframe` string
  - `bars` integer
  - `params` object

## Response `200`

Answers {success, ok, diagnostics, warnings, contract, series, ...} at the top level (no data wrapper)

- object
  - `success` true, required
  - `ok` boolean, required: False when the source failed to compile or run; see diagnostics.
  - `diagnostics` object[], required
  - `warnings` object[]
  - `contract` object: The declared inputs, plots and visuals.
  - `series` object, nullable: One array of {t, v} per plot, the same shape POST /v1/indicators/compute answers; null when ok is false.
  - `colorSeries` object, nullable
  - `candles` object[], nullable
  - `stats` object
  - `cost` object, nullable
  - `window` object: The bars the preview compiled against: requested, loaded, used, first and last bar time.

## Other responses

- `400`: validation_error
- `404`: No data for the symbol and timeframe in the window
- `502`: The bars to test against could not be loaded

---

[API](https://skmtc.dev/texttoquant/apis/texttoquant-api.md) · [All operations](https://skmtc.dev/texttoquant/apis/texttoquant-api/llms.txt) · [OpenAPI document](https://skmtc.dev/texttoquant/apis/texttoquant-api/revisions/d417fc3f4a7d?raw)
