Skip to content

feat: add transactions export command#74

Open
johann-taberlet wants to merge 2 commits intoazerpas:mainfrom
johann-taberlet:feat/transactions
Open

feat: add transactions export command#74
johann-taberlet wants to merge 2 commits intoazerpas:mainfrom
johann-taberlet:feat/transactions

Conversation

@johann-taberlet
Copy link
Copy Markdown

Summary

Adds a new transactions subcommand to export account transactions over a date range, using BoursoBank's CSV export endpoint (/budget/exporter-mouvements).

# CSV output (default)
bourso transactions -a <account_id> -f "01/01/2026" -t "31/01/2026"

# JSON output
bourso transactions -a <account_id> -f "01/01/2026" -t "31/01/2026" -o json

Changes

  • bourso_api::account: Add Transaction struct with all fields from BoursoBank CSV export
  • bourso_api::client::transaction: Add get_transactions() method on BoursoWebClient
    • Hits the /budget/exporter-mouvements endpoint with date range and account filter
    • Handles the 302 redirect to api.boursobank.com for file download (since the client uses Policy::none())
    • Parses BoursoBank CSV format (semicolon-separated, French number format with comma decimals and space thousands separators)
    • Returns empty Vec gracefully when an HTML error page is returned
  • CLI: Add transactions subcommand with --account, --from, --to, --output args
  • New dependency: csv crate for robust CSV parsing

Test plan

  • cargo build --release compiles without errors
  • cargo test -p bourso_api — 11 tests pass (3 new: test_parse_amount, test_extract_transactions, test_extract_transactions_empty_html)
  • Manual test: successfully exported 8 transactions from a live BoursoBank account with CSV output
  • Manual test: JSON output (-o json) works correctly

@azerpas
Copy link
Copy Markdown
Owner

azerpas commented Feb 11, 2026

Thank you very much for the contribution @johann-taberlet

A few things top of my head:

  • I feel like the command should be something like bourse-cli export transactions [...] so that we can have something similar for export orders or export transfers
  • -f is often used to used for --format args, which I feel could be a good replacement to the current --ouput/-o
  • same for -o/--ouput which often designate a file output. I feel like that would suit well an export to a json or csv file
  • to replace -f/--from I would use --start-date and --end-date to make it really explicit
  • With all these we'll have something like bourso export transactions -a <account_id> --start-date "01/01/2026" --end-date "31/01/2026" -f json -o /Users/johndoe/transactions.json. Wdyt?

@johann-taberlet
Copy link
Copy Markdown
Author

Thanks for the feedback @azerpas! All changes implemented in the latest commit:

  • bourso export transactions — moved under a new export subcommand, ready for future export orders, export transfers, etc.
  • --start-date / --end-date — replaced --from/-f and --to/-t
  • --format / -f — replaced --output/-o for format selection (csv/json)
  • --output / -o — new optional arg for file output path (defaults to stdout)

Final usage:

bourso export transactions -a <account_id> --start-date "01/01/2026" --end-date "31/01/2026" -f json -o /path/to/transactions.json

All 11 tests still passing, build OK. Tested manually with both CSV (stdout) and JSON (stdout) output.

@yann120
Copy link
Copy Markdown

yann120 commented Mar 21, 2026

@azerpas Any blocker to merge this PR ? 🙏🏻
This feature would be awesome for business automations

@Adriengue
Copy link
Copy Markdown

Adriengue commented Mar 24, 2026

Hello, boursobank user here

I worked on a personal solution in python by reverse-engineering the API (and this repository for the virtual-pad horror) and it happens that this will not work for every accounts. Indeed, this will only work for classical accounts (livret-a, bourso+, main, ...). Indeed for PEA accounts, the endpoint URL is /compte/pea/{self._account.id}/mouvements/telecharger and its payload :

  • startDate (%Y-%m-%d")
  • endDate (%Y-%m-%d)
  • operationType ("ESP" | "TIT" | "")

The output file will be a CSV with following fields : ("Date opération","Date valeur","Opération","Valeur","Code ISIN","Montant","Quantité","Cours")

This is the only information I can give you as I do now own any other accounts (no CTO for instance)

Maybe worth documenting this may not work for every account type !

@gogaz
Copy link
Copy Markdown

gogaz commented Apr 4, 2026

+1 on this, would love to see it merged when you have a chance @azerpas. Transaction export is the feature I’m missing most right now.

@azerpas
Copy link
Copy Markdown
Owner

azerpas commented Apr 4, 2026

Sorry for the lack of responsiveness, I was away for a few weeks. Approved 👍

EDIT: @johann-taberlet could you please sign your commits for the PR to be merged? Thanks in advance

Add a new `transactions` subcommand to export account transactions
over a date range using BoursoBank's CSV export endpoint.

- Add `Transaction` struct to `bourso_api::account`
- Add `get_transactions()` method on `BoursoWebClient`
- Handle redirect to `api.boursobank.com` for file download
- Parse BoursoBank CSV (semicolon-separated, French number format)
- Support CSV (default) and JSON output formats
- Add unit tests for CSV parsing and amount conversion
- Move `transactions` under new `export` subcommand (`bourso export transactions`)
- Rename `--from`/`--to` to `--start-date`/`--end-date`
- Rename `--output` (format) to `--format`/`-f`
- Add `--output`/`-o` for file output path (defaults to stdout)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants