Tally Prime HTTP Client

tally-to-xml-tdl

Pull clean, structured JSON from Tally Prime — no plugins, no configuration overhead, just Node.js.

Tally exposes a local HTTP port. This library speaks to it directly via TDL-based XML requests and returns plain JavaScript objects ready to query, inspect, and use.

Zero Tally Plugins
Native Node.js 18+ Fetch
Pure ESM Module

How it works #

1
Your Code
Invoke query with company name & date range
2
buildXml()
Fills standard XML envelope with TDL payload
3
HTTP POST
Dispatches to Tally on port :9000
4
xmlToJson()
Parses response envelope into plain JS object
Your Code → buildXml() → HTTP POST → Tally :9000 → XML Response → xmlToJson() → JSON Object

Three operations happen seamlessly inside every function call:

  1. Build — a shared body.xml template is populated with your active company name, date filters, and TDL collection message.
  2. Send — the formulated XML request is POSTed to Tally's local HTTP listener (http://localhost:9000 by default).
  3. Parse — Tally's raw XML response envelope is converted into a standard JavaScript object graph.

You receive the raw envelope, exactly as Tally produced it. There is no lossy data manipulation, no stripping of attributes, and no hidden transformation.

Install #

bash
npm install tally-to-xml-tdl
Prerequisite: Ensure Tally Prime is running locally with HTTP enabled at:
Gateway of Tally → F12 → Advanced Configuration → Enable HTTP: Yes (Port: 9000)

Quick start #

javascript
import { company, masters, vouchers } from "tally-to-xml-tdl";

// 1. List all open companies in Tally
const companies = await company();

// 2. Get stock items for an active company
const stock = await masters.get("My Company", "stockItems");

// 3. Get purchase vouchers for a specified date range
const purchases = await vouchers.purchases.period(
  "My Company",
  "1-Apr-2026",
  "30-Apr-2026"
);

API Reference #

company()

Lists all companies currently opened in the running Tally Prime instance.

javascript
import { company } from "tally-to-xml-tdl";

const result = await company();
// result.ENVELOPE.BODY.DATA.COLLECTION.COMPANY → [ { NAME: "..." }, ... ]

masters.get(company, queryId)

Fetches master catalogs (stock items, ledgers, units, groups) for a given company.

javascript
import { masters } from "tally-to-xml-tdl";

const result = await masters.get("My Company", "stockItems");

Supported queryId parameters:

queryId Returned Data Structure
uom Units of Measure definitions
stockItems Stock item names list
stockItemsWithBaseUnits Stock items paired with their base units
ledgerNames Ledger account names
ledgerNamesWithDetails Ledgers with GST registration type and GSTIN
ledgerNamesMoreDetails Ledgers with extended GST registration details table
stockGroups Stock group names hierarchy
stockGroupsAndParent Stock groups along with parent group relationships

vouchers.purchases.period(company, fromDate, toDate)

Fetches purchase vouchers within a date window including inventory details.

javascript
import { vouchers } from "tally-to-xml-tdl";

const result = await vouchers.purchases.period(
  "My Company",
  "1-Apr-2026",
  "30-Apr-2026"
);

const voucherList = result.ENVELOPE.BODY.DATA.COLLECTION.VOUCHER;
console.log(voucherList.length); // e.g. 46

vouchers.purchases.all(company)

Fetches all purchase vouchers across all available financial dates.

javascript
const result = await vouchers.purchases.all("My Company");

vouchers.sales.get(company, fromDate, toDate, "period")

Fetches sales vouchers for a date range.

javascript
const result = await vouchers.sales.get(
  "My Company",
  "1-Apr-2026",
  "30-Apr-2026",
  "period"
);

Response shape #

Every function call returns the raw Tally XML envelope directly translated into JSON:

json
{
  "ENVELOPE": {
    "HEADER": { /* Tally export metadata */ },
    "BODY": {
      "DATA": {
        "COLLECTION": {
          "VOUCHER": [
            {
              "DATE": "20260401",
              "GUID": "...",
              "VOUCHERTYPENAME": "Purchase"
            }
          ]
          // Or STOCKITEM, LEDGER, UNIT depending on query
        }
      }
    }
  }
}

To extract the actual record array in your application:

javascript
const records = result.ENVELOPE.BODY.DATA.COLLECTION.VOUCHER;

Date format #

Tally Prime requires dates formatted as day, month abbreviation, and year. For example:

Format pattern: "D-MMM-YYYY" (e.g. "1-Apr-2026", "30-Apr-2026")

Requirements #

Requirement Specification
Node.js >=18 (leverages native global fetch)
Tally Prime Any modern release with HTTP port export enabled
HTTP Listener Port 9000 active by default in Tally
Module System Pure ECMAScript Module ("type": "module")