Overview
The CoinPaprika CLI supports two output formats: Table (human-readable) and JSON (machine-readable). You can control the output format globally using the--output flag.
Output Modes
- Table (Default)
- JSON
- Raw JSON
The default output format displays data in formatted, human-readable tables with automatic column width adjustment and styling.Output:
Example
Features
- Rounded table borders for better readability
- Automatic text wrapping for long values
- Smart number formatting (K, M, B, T suffixes)
- Attribution footer included
Best For
- Interactive terminal usage
- Quick data inspection
- Human consumption
- Screenshots and documentation
Usage Examples
Basic Output Control
Scripting with jq
Extract specific fields usingjq:
Save to File
Compare With and Without Metadata
How It Works
The output format is controlled by two global CLI flags defined insrc/main.rs:29-39:
OutputFormat enum is defined in src/output/mod.rs:8-12:
JSON Output Implementation
JSON output is handled by theprint_json_wrapped function in src/output/mod.rs:111-119:
Metadata Structure
The metadata wrapper includes attribution and timestamp information:Formatting Details
Table Formatting
The CLI uses smart formatting for different data types in table output:Currency Values
Large numbers use suffixes (K, M, B, T) for readability.
$1,500,000,000→$1.5B$42,000,000→$42.0M$5,200→$5.2K
Prices
Precision adjusts based on value size.
≥ $1.00→ 2 decimals ($97234.56)≥ $0.01→ 4 decimals ($0.1234)< $0.01→ 8 decimals ($0.00012340)
src/output/mod.rs:61-103.
Error Handling
Errors are formatted according to the output mode:Table Mode
Errors are printed to stderr:JSON Mode
Errors are returned as JSON objects:src/main.rs:418-430:
Best Practices
Use Table for Interactive Sessions
When running commands manually in a terminal, stick with the default table output for better readability.
Use JSON + Raw for Scripting
Always use
--output json --raw in scripts to avoid parsing the metadata wrapper.Include Metadata for Logging
Use JSON without
--raw when you want to preserve attribution and timestamps in logs.Related Commands
All commands support the--output and --raw flags:
coinpaprika-cli global- Market overviewcoinpaprika-cli tickers- All tickerscoinpaprika-cli ticker <id>- Single tickercoinpaprika-cli search <query>- Search resultscoinpaprika-cli ohlcv <id>- Historical OHLCV data