tallyprime-sdk
Rust SDK for integrating with TallyPrime over XML/HTTP.
This crate provides a blocking client for:
- reading masters such as ledgers, groups, stock items, and currencies
- reading vouchers and day-book style voucher ranges
- reading built-in reports such as trial balance, balance sheet, and profit and loss
- creating masters such as ledgers, groups, and stock items
The SDK is built around Tally's XML interface and uses typed Rust models for both inputs and outputs.
Status
This project is working against a live Tally instance and has integration tests for:
- group creation
- ledger creation
- stock item creation
- voucher fetching
- purchase voucher creation using the lower-level XML builder
The high-level client is stable for read flows and master creation. Advanced voucher import flows exist, but some of them are still exposed through lower-level XML builder utilities rather than a dedicated top-level client method.
Requirements
- Rust 1.75+ recommended
- TallyPrime running with XML over HTTP enabled
- Default endpoint:
http://localhost:9000
If you use a specific company, set it explicitly with TALLY_COMPANY or TallyConfig.current_company. If you do not, the SDK will try to discover the active company loaded in Tally.
Installation
Add the crate from crates.io:
[]
= "0.1"
If you are using this crate from another local workspace:
[]
= { = "../tally-sdk-rs" }
If you want to reference it from Git:
[]
= { = "https://github.com/labs-infinitum/tally-sdk-rs" }
Quick Start
use TallyConfig;
use TallyClient;
Configuration
The client is configured through TallyConfig:
Defaults:
host = "localhost"port = 9000timeout_secs = 30retry_attempts = 3
Public API
Main entry point: TallyClient
Connection and session:
TallyClient::newTallyClient::test_connectionTallyClient::active_company_name
Master reads:
get_ledgers() -> Vec<LedgerSummary>get_groups() -> Vec<GroupSummary>get_stock_items() -> Vec<StockItemSummary>get_currencies() -> Vec<CurrencySummary>
Master writes:
create_ledger(&Ledger) -> ImportResultcreate_group(&Group) -> ImportResultcreate_stock_item(&StockItem) -> ImportResult
Debug variants are also available and print the raw XML request/response:
create_ledger_debugcreate_group_debugcreate_stock_item_debug
Voucher reads:
get_vouchers(from, to) -> Vec<Voucher>get_vouchers_in_range(from, to) -> Vec<Voucher>
Reports:
get_trial_balance(from, to, explode_flag) -> Vec<TrialBalanceEntry>get_balance_sheet(from, to, explode_flag) -> Vec<BalanceSheetEntry>get_profit_and_loss(from, to, explode_flag) -> Vec<ProfitAndLossEntry>
Typed Results
Collection reads return typed summaries rather than tuples:
Create/import calls return ImportResult, which includes:
createdaltereddeletedcombinedignorederrorscancelledexceptionslast_voucher_idlast_master_idline_errors
Example:
use TallyConfig;
use ;
Examples
The crate includes runnable examples under examples/:
fetch_all_accounts.rsfetch_all_groups.rsfetch_all_currencies.rsfetch_day_book.rsfetch_trial_balance.rsfetch_balance_sheet.rsfetch_profit_and_loss.rscreate_ledger.rscreate_ledger_entry.rs
Run them with:
Supported example flags:
--fy YYYY-YYYY--from YYYYMMDD--to YYYYMMDD--verbosefor day book voucher ledger-line output--flatfor report exports withoutEXPLODEFLAG--name,--parent,--opening-balance, and--debugfor ledger creation--party,--account,--amount,--date,--bill-ref,--voucher-number,--voucher-type,--narration, and--debugfor ledger entries
Environment variables used by the examples:
TALLY_HOSTTALLY_PORTTALLY_COMPANY
Date Handling
The SDK expects date inputs in YYYYMMDD format for most public methods.
Example:
2025040120260331
For voucher reads, get_vouchers_in_range applies an exact client-side range filter after parsing the XML response. This exists because Tally's voucher/day book exports are not always consistent about honoring date filters across environments.
Lower-Level XML Access
For advanced or not-yet-wrapped flows, the crate also exposes the lower-level XML pieces:
That is how the current purchase item-invoice integration test is implemented.
Development
Useful commands:
Unit tests under src/ run with cargo test / cargo test --lib and do not need Tally.
Integration tests under tests/ require a reachable TallyPrime instance and are marked #[ignore]:
Set TALLY_HOST, TALLY_PORT, and optionally TALLY_COMPANY when running ignored tests. If no company is active and TALLY_COMPANY is not set, some flows will skip.
Releases
Publishing to crates.io is automated by GitHub Actions:
- Add a
CARGO_REGISTRY_TOKENsecret to the repository (from crates.io). - Ensure
versioninCargo.tomlmatches the release. - Tag and push, for example
git tag v0.1.0 && git push origin v0.1.0.
The release workflow also supports manual workflow_dispatch. The tag must be vX.Y.Z and must match the Cargo.toml version.
Limitations
- The client is blocking today and uses
reqwest::blocking. - Voucher creation is not yet exposed as a single high-level
create_voucher(...)client API. - Some advanced Tally/TDL workflows still require the lower-level XML builder layer.
License
This repository is licensed under the Apache License 2.0.