ChartnautDocs

Create a script and its first version

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

Validates, resolves and pins dependencies, then saves the first version. Counts against the plan's custom-indicator, definition or study cap. Nothing is created when validation fails (422). A study's first version can be numbered 2: the app seeds a starter version when a study is created.

Request bodyapplication/json#

Includes ScriptSource

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.

slugstringRequired
Pattern ^[a-z0-9][a-z0-9-]{1,62}$
namestring
descriptionstring
visibilitystring · Visibility

Studies are always private; setting visibility on a study is refused with 400.

One of private public
change_summarystring

Responses#

201Createdapplication/json

Created.

object · Script

Includes ScriptSummary

idstring

The script's id for the Terminal SDK and partner API: ind_<n> for an indicator, flw_<n> for a definition. Pass it to cn.scripts.publish({ script }) or chart.scripts.add. Absent for a study.

Example ind_1298
slugstring
kindstring · ScriptKind
One of indicator definition study
namestring
descriptionstring
visibilitystring · Visibility

Studies are always private; setting visibility on a study is refused with 400.

One of private public
latest_versioninteger
updated_atstring (date-time)
app_urlstring (uri)

Opens this script in the Chartnaut app.

versioninteger

The version this response describes.

interfaceobject · ScriptInterface

What a caller needs to run the script and read its results. Derived from the code.

Show fields
settingsmap of object · SettingDef
Show value fields
typestring

An indicator's settings take their type, bounds and options from its settings dialog.

One of number string boolean color select multi_select timeframe range array
defaultany
minnumber
maxnumber
stepnumber
optionsarray of any

Choices for a select. From an indicator's settings dialog each is {label, value}.

outputsarray of object · OutputDef

Indicator only.

Show item fields
idstring
namestring
kindstring

The output's declared kind (line, area, baseline, histogram, fill, markers, labels, hline, range, …).

panestring
One of price own
eventsarray of object · EventDef

Definition only. The events it can emit.

Show item fields
idstring
Example reclaim_long
intentstring
payload_keysarray of string
resultsarray of object

Study only. The result blocks it produces.

Show item fields
keystring
kindstring · StudyResultKind
One of metric series distribution boxplot heatmap scatter bar table vega annotation prose popover_layout
titlestring
timeframesarray of string · Timeframe

Extra timeframes the script reads besides the run's own.

warmup_barsinteger
dependenciesarray of object · PinnedDependency
Show item fields
refstring · 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
asstring

The alias the script uses.

versioninteger
filesarray of object · ScriptFile

Present with include=source on your own scripts.

Show item fields
pathstringRequired
Example main.ts
codestringRequired
entryboolean

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

409Conflictapplication/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
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