ChartnautDocs

Run a script on one instrument and window

POST/runs
Base URL
https://api.chartnaut.com/v1
Auth
Bearer key
Operation ID
createRun

One verb for all three kinds. Pass script (a saved ref) or source (inline, saves nothing). A study over several instruments is several runs; the CLI fans out.

Limits:

  • Inline source supports indicators and definitions. Save a study first, then run it by ref.
  • Studies run only from your own scripts. Indicators and definitions can also run by author/slug, without their source, once they are in your library (addToLibrary). Otherwise 409 not_in_library, with details {ref, add, needs, cannot_add, confirm}. Your own scripts and chartnaut/ built-ins never need adding.
  • A study whose declared definitions are not all yours, built-in or in your library is refused before anything runs: 409 not_in_library with details.definitions (one entry per definition to add), or 409 not_shared with details.cannot_add when one is not shared with you.
  • One run's window holds at most 50,000 bars at the run's timeframe.
  • Runs execute in the account's run slots (plan: Free 1, Pro 3, plus 1 per compute concurrency add-on), shared with the account's own app sessions. Queued+running API runs are capped at slots + 4 (429 busy).
  • Indicator and definition results are kept for 7 days.
  • A definition run keeps at most 10,000 events; summary.events_total counts all of them.
  • The window is clamped to your plan's history and ends on a closed bar.

With wait > 0 the call blocks until the run finishes or wait elapses, then returns the run in whatever state it is in. 202 means still running: poll getRun or use a webhook.

Headers#

Idempotency-Keystring

Any unique string. A retry with the same key within 24h returns the first response instead of creating a second script, version or run.

At most 128 characters

Request bodyapplication/json#

scriptstring · ScriptRef

slug or slug@N for your own scripts; author/slug or author/slug@N for library scripts; chartnaut/slug for built-ins (which always run their latest version).

Examples vwap-reclaim vwap-reclaim@3 jane/orb-breakout@7 chartnaut/rsi
sourceobject · ScriptSource
Show fields
kindstring · ScriptKindRequired
One of indicator definition study
filesarray of object · ScriptFileRequired
At least 1 items
Show item fields
pathstringRequired
Example main.ts
codestringRequired
entryboolean

Exactly one file is the entry. Indicators have one file, always the entry.

instrumentstringRequired

Canonical or short symbol.

Example BTC
timeframestring · TimeframeRequired
One of 1m 5m 15m 30m 1h 2h 4h 1d 1w 1mo
windowobject · WindowRequired

Exactly one of {from,to}, last or bars. Warmup is fetched before the window automatically and never counted in results. Clamped to the plan's historical depth.

Show fields
fromstring (date-time)
tostring (date-time)

Defaults to now.

laststring
Pattern ^[0-9]+[dwmy]$Example 90d
barsinteger
At least 1Example 2000
settingsobject

Overrides; anything omitted uses the script's default.

studyobject

Study only.

Show fields
event_filterobject

Restrict to events matching these payload values.

waitinteger

Seconds to block for completion.

Default 00 to 30
labelstring

Free text, shown in the app.

One of

Option 1any
Option 2any

Responses#

200OKapplication/json

Finished within wait (succeeded, failed or cancelled).

object · Run
idstring
kindstring · ScriptKind
One of indicator definition study
scriptstring

The resolved ref that ran (vwap-reclaim@3), or inline.

instrumentstring

The instrument's display symbol (short in /instruments).

Example NAS100
timeframestring · Timeframe
One of 1m 5m 15m 30m 1h 2h 4h 1d 1w 1mo
windowobject

The resolved window after clamping.

Show fields
fromstring (date-time)
tostring (date-time)
settingsobject
statusstring · RunStatus
One of queued running succeeded failed cancelled
progressobject
Show fields
pctnumber
0 to 100
phasestring
Example collecting
failureobjectNullable
Show fields
kindstring · FailureKind

Why a run failed. retryable on the run says whether trying again can help.

One of script plan_limit out_of_coverage data_not_ready timeout cancelled internal
messagestring
retryableboolean
diagnosticsarray of object · Diagnostic
Show item fields
severitystringRequired
One of error warning
codestring
Example link.unresolved_import
messagestringRequired
pathstring
lineinteger
settingstring

The setting a finding is about, if any.

summaryobjectNullable

Small, always inline once finished. indicator: {bars, outputs:{id:{last, min, max, count}}, warnings?, errors?} definition: {bars, events_total, events_kept?, by_event:{id:count}, warnings?, errors?} study: {events_processed} errors are runtime errors on some bars; the run still produced results.

consolearray of objectNullable

The first 50 console lines the script printed. null until the run has finished, or when it printed nothing.

Show item fields
levelstring
messagestring
timestring (date-time)
usageobject
Show fields
barsinteger

Bars evaluated, warmup and dependencies included.

compute_unitsnumber
app_urlstring (uri)Nullable

Study runs only; indicator and definition runs are not stored in the app.

results_expire_atstring (date-time)
created_atstring (date-time)
started_atstring (date-time)Nullable
finished_atstring (date-time)Nullable
202Acceptedapplication/json

Accepted, still queued or running.

object · Run
idstring
kindstring · ScriptKind
One of indicator definition study
scriptstring

The resolved ref that ran (vwap-reclaim@3), or inline.

instrumentstring

The instrument's display symbol (short in /instruments).

Example NAS100
timeframestring · Timeframe
One of 1m 5m 15m 30m 1h 2h 4h 1d 1w 1mo
windowobject

The resolved window after clamping.

Show fields
fromstring (date-time)
tostring (date-time)
settingsobject
statusstring · RunStatus
One of queued running succeeded failed cancelled
progressobject
Show fields
pctnumber
0 to 100
phasestring
Example collecting
failureobjectNullable
Show fields
kindstring · FailureKind

Why a run failed. retryable on the run says whether trying again can help.

One of script plan_limit out_of_coverage data_not_ready timeout cancelled internal
messagestring
retryableboolean
diagnosticsarray of object · Diagnostic
Show item fields
severitystringRequired
One of error warning
codestring
Example link.unresolved_import
messagestringRequired
pathstring
lineinteger
settingstring

The setting a finding is about, if any.

summaryobjectNullable

Small, always inline once finished. indicator: {bars, outputs:{id:{last, min, max, count}}, warnings?, errors?} definition: {bars, events_total, events_kept?, by_event:{id:count}, warnings?, errors?} study: {events_processed} errors are runtime errors on some bars; the run still produced results.

consolearray of objectNullable

The first 50 console lines the script printed. null until the run has finished, or when it printed nothing.

Show item fields
levelstring
messagestring
timestring (date-time)
usageobject
Show fields
barsinteger

Bars evaluated, warmup and dependencies included.

compute_unitsnumber
app_urlstring (uri)Nullable

Study runs only; indicator and definition runs are not stored in the app.

results_expire_atstring (date-time)
created_atstring (date-time)
started_atstring (date-time)Nullable
finished_atstring (date-time)Nullable
409Conflictapplication/json

not_in_library: another author's script, or a definition your study declares, is not in your library. not_shared: your study declares a definition that is not shared with you. conflict: one of your studies shares the slug with an indicator or definition.

object · Error
errorobjectRequired
Show fields
codestringRequired

Stable. Branch on this, never on message.

One of unauthorized forbidden_scope plan_limit not_found version_conflict script_invalid in_use out_of_coverage unknown_instrument ambiguous_instrument unsupported_timeframe run_not_finished rate_limited busy invalid_request forbidden conflict not_in_library confirmation_required not_shared not_installable not_implemented authorization_pending slow_down access_denied expired_token internal
messagestringRequired
detailsobject
docs_urlstring (uri)
request_idstring
422Unprocessableapplication/json

The script does not lint, link or derive. Nothing was saved or run.

object

Includes Error

errorobjectRequired
Show fields
codestringRequired

Stable. Branch on this, never on message.

One of unauthorized forbidden_scope plan_limit not_found version_conflict script_invalid in_use out_of_coverage unknown_instrument ambiguous_instrument unsupported_timeframe run_not_finished rate_limited busy invalid_request forbidden conflict not_in_library confirmation_required not_shared not_installable not_implemented authorization_pending slow_down access_denied expired_token internal
messagestringRequired
detailsobject
docs_urlstring (uri)
request_idstring
diagnosticsarray of object · Diagnostic
Show item fields
severitystringRequired
One of error warning
codestring
Example link.unresolved_import
messagestringRequired
pathstring
lineinteger
settingstring

The setting a finding is about, if any.

ErrorAny other statusapplication/json

Error.

object · Error
errorobjectRequired
Show fields
codestringRequired

Stable. Branch on this, never on message.

One of unauthorized forbidden_scope plan_limit not_found version_conflict script_invalid in_use out_of_coverage unknown_instrument ambiguous_instrument unsupported_timeframe run_not_finished rate_limited busy invalid_request forbidden conflict not_in_library confirmation_required not_shared not_installable not_implemented authorization_pending slow_down access_denied expired_token internal
messagestringRequired
detailsobject
docs_urlstring (uri)
request_idstring