CLI Scripting & Piping
Use the Bkper CLI as a scripting tool — pipe JSON between commands for batch creates and updates, output CSV for data pipelines and AI agents, and chain operations to migrate, transform, or sync book data without writing code.
The Bkper CLI is designed for scripting. Every command supports multiple output formats, and write commands accept piped JSON input — making it easy to build data pipelines, batch operations, and automated workflows.
Output formats
All commands support three output formats via the --format global flag:
| Format | Flag | Best for |
|---|---|---|
| Table | --format table (default) | Human reading in the terminal |
| JSON | --format json | Programmatic access, single-item detail |
| CSV | --format csv | Spreadsheets, AI agents, data pipelines |
# Table output (default)bkper account list -b abc123
# JSON outputbkper account list -b abc123 --format json
# CSV output -- raw data, no truncation, RFC 4180bkper account list -b abc123 --format csvCSV output details:
- RFC 4180 compliant — proper quoting, CRLF line endings, no truncation
- All metadata included — IDs, properties, hidden properties, URLs, and timestamps
- Raw values — dates in ISO format, numbers unformatted
Batch operations
Write commands (account create, group create, transaction create, transaction update) accept JSON piped via stdin. The input format follows the Bkper API Types — a single JSON object or an array of objects.
Creating in batch
# Create transactions from JSONecho '[{ "date": "2025-01-15", "amount": "100.50", "creditAccount": {"name": "Bank Account"}, "debitAccount": {"name": "Office Supplies"}, "description": "Printer paper", "properties": {"invoice": "INV-001"}}]' | bkper transaction create -b abc123
# Create accountsecho '[{"name":"Cash","type":"ASSET"},{"name":"Revenue","type":"INCOMING"}]' | \ bkper account create -b abc123
# Create groupsecho '[{"name":"Fixed Costs","hidden":true}]' | \ bkper group create -b abc123
# Pipe from any script that outputs JSONpython export_bank.py | bkper transaction create -b abc123Batch results are output as a flat JSON array:
bkper account create -b abc123 < accounts.json# [{"id":"acc-abc","name":"Cash",...}, {"id":"acc-def","name":"Revenue",...}]Adding properties via CLI flag
The --property flag can add or override properties from the stdin payload:
echo '[{"name":"Cash","type":"ASSET"}]' | \ bkper account create -b abc123 -p "region=LATAM"Piping between commands
All JSON output is designed to feed directly into other commands. This is the most powerful pattern — combining commands into pipelines:
Copy data between books
# Copy all accounts from one book to anotherbkper account list -b $BOOK_A --format json | bkper account create -b $BOOK_B
# Copy all groupsbkper group list -b $BOOK_A --format json | bkper group create -b $BOOK_B
# Copy transactions matching a querybkper transaction list -b $BOOK_A -q "after:2025-01-01" --format json | \ bkper transaction create -b $BOOK_BClone a full chart of accounts
# Groups first, then accounts, then transactionsbkper group list -b $SOURCE --format json | bkper group create -b $DESTbkper account list -b $SOURCE --format json | bkper account create -b $DESTbkper transaction list -b $SOURCE -q "after:2025-01-01" --format json | \ bkper transaction create -b $DESTBatch updates with jq
Use jq to transform data between commands:
# List transactions, modify descriptions, pipe back to updatebkper transaction list -b $BOOK -q "after:2025-01-01" --format json | \ jq '[.[] | .description = "Updated: " + .description]' | \ bkper transaction update -b $BOOK
# Add a property to all matching transactionsbkper transaction list -b $BOOK -q "account:Expenses" --format json | \ bkper transaction update -b $BOOK -p "reviewed=true"
# Batch update checked transactionsbkper transaction list -b $BOOK -q "is:checked after:2025-01-01" --format json | \ bkper transaction update -b $BOOK --update-checked -p "migrated=true"Shell script examples
Daily export
#!/bin/bash# Export yesterday's transactions to CSVDATE=$(date -d "yesterday" +%Y-%m-%d)bkper transaction list -b $BOOK_ID \ -q "after:$DATE before:$DATE" \ --format csv > "export-$DATE.csv"Bulk categorization
#!/bin/bash# Add a property to all uncategorized transactionsbkper transaction list -b $BOOK_ID \ -q "account:Uncategorized" \ --format json | \ bkper transaction update -b $BOOK_ID -p "needs_review=true"Combining with other tools
The CLI works with standard Unix tools:
# Count transactions matching a querybkper transaction list -b $BOOK_ID -q "after:2025-01-01" --format csv | wc -l
# Extract specific fields with jqbkper account list -b $BOOK_ID --format json | \ jq '[.[] | {name, balance}]'
# Sort by amountbkper transaction list -b $BOOK_ID --format json | \ jq 'sort_by(.amount | tonumber) | reverse'Full CLI reference
For the complete command reference including all options, see the bkper-cli app page or run bkper --help.