Skip to content

Output and exit codes

Markdown
-o Prints
auto (default) a table when stdout is a terminal, compact JSON otherwise
table a table
json one JSON document
jsonl one JSON value per line (one per array item)

Set the default with IDX_OUTPUT or general.output. Colour is off whenever stdout is not a terminal, and with --no-color.

  • stdout carries only data; warnings, progress and errors go to stderr.

  • On failure stdout is empty.

  • In JSON modes an error is one JSON object on stderr:

    {"error":true,"code":"INVALIDINPUT","message":"invalid input: invalid ticker symbol '../x'"}
Exit Meaning What to do
0 success
2 invalid input or config fix the command
3 not found, no data, or no cached data offline check the ticker or name; go online
4 upstream unavailable retry later
5 unsupported use another command or provider
1 anything else read the message
Terminal window
# names and prices
idx stocks quote BBCA BBRI | jq -r '.[] | "\(.symbol) \(.price)"'
# the last five daily closes
idx -o jsonl stocks history BBCA --period 1y | tail -5
# symbols from stdin
idx stocks screen --filter high-dividend | jq -r '.[].symbol' | idx stocks compare -

stocks quote and stocks compare read symbols from stdin when given -, separated by whitespace or commas.