# tally-to-xml-tdl

> Simple, clean TDL and XML extraction and manipulation tools for Tally

Latest version **1.7.1** (published 2026-09-24) · 0 weekly downloads

## Install

```sh
npm install tally-to-xml-tdl
pnpm add tally-to-xml-tdl
yarn add tally-to-xml-tdl
bun add tally-to-xml-tdl
```

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.7.1 |
| Published | 2026-09-24 |
| First published | 2026-09-24 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 35.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | keshavsoft |

## Links

- npm: https://www.npmjs.com/package/tally-to-xml-tdl
- Repository: https://github.com/keshavsoft/tally-to-xml-tdl
- Homepage: https://keshavsoft.com
- Issues: https://github.com/keshavsoft/tally-to-xml-tdl/issues
- npm.io page: https://npm.io/package/tally-to-xml-tdl

## Dependencies (1)

- [fast-xml-parser](https://npm.io/package/fast-xml-parser.md) ^5.11.1

## Recent versions

- 1.7.1 (latest) — 2026-09-24
- 1.6.2 — 2026-09-24
- 1.6.1 — 2026-09-24

## README

# tally-to-xml-tdl

> Pull clean, structured JSON from **Tally Prime** — no plugins, no config, just Node.js.

Tally exposes a local HTTP port. This library speaks to it directly via TDL-based XML requests and gives you back plain JavaScript objects ready to use.

🌐 **[Live Documentation](https://keshavsoft.github.io/tally-to-xml-tdl/)** &bull; 📖 **[Full Architecture Guide](https://keshavsoft.github.io/tally-to-xml-tdl/guide.html)** (or [offline markdown](docs/guide.md)) &bull; 📦 **[npm package](https://www.npmjs.com/package/tally-to-xml-tdl)**

---

## How it works

```
Your Code  →  buildXml()  →  HTTP POST  →  Tally :9000
                                               |
Your Code  ←  JSON object  ←  xmlToJson()  ←  XML response
```

Three steps happen inside every call:

1. **Build** — a `body.xml` template is filled with your company name, date range, and TDL query
2. **Send** — the XML is `POST`ed to Tally's local HTTP port (`9000` by default)
3. **Parse** — Tally's XML response is converted to a plain JavaScript object

You get back the raw envelope, exactly as Tally sent it. No magic cleaning, no data loss.

---

## Install

```bash
npm install tally-to-xml-tdl
```

Requires Tally Prime running locally with HTTP port enabled (`Gateway of Tally → F12 → Advanced Config → Enable HTTP`).

---

## Quick start

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

// List all open companies
const companies = await company();

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

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

---

## API

### `company()`

Lists all companies currently open in Tally.

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

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

---

### `masters.get(company, queryId)`

Fetches master data (stock items, ledgers, units etc.) for a company.

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

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

**Available `queryId` values:**

| `queryId` | What you get |
|---|---|
| `uom` | Units of Measure |
| `stockItems` | Stock item names |
| `stockItemsWithBaseUnits` | Stock items + base units |
| `ledgerNames` | Ledger names |
| `ledgerNamesWithDetails` | Ledgers + GST registration + GSTIN |
| `ledgerNamesMoreDetails` | Ledgers + GST reg details list |
| `stockGroups` | Stock group names |
| `stockGroupsAndParent` | Stock groups + parent group |

---

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

Fetches purchase vouchers in a date range.

```js
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 dates.

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

---

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

Fetches sales vouchers in a date range.

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

---

## Response shape

Every call returns the raw Tally XML envelope parsed into JSON:

```js
{
  ENVELOPE: {
    HEADER: { ... },
    BODY: {
      DATA: {
        COLLECTION: {
          VOUCHER: [ { DATE, GUID, VOUCHERTYPENAME, ... }, ... ]
          // or STOCKITEM, LEDGER, UNIT etc. depending on query
        }
      }
    }
  }
}
```

To work with just the records:

```js
const records = result.ENVELOPE.BODY.DATA.COLLECTION.VOUCHER;
```

---

## Date format

Tally accepts dates in this format: `"1-Apr-2026"`, `"30-Apr-2026"`

---

## Requirements

| Requirement | Detail |
|---|---|
| Node.js | `>=18` (uses native `fetch`) |
| Tally Prime | Any version with HTTP port support |
| HTTP port | Enabled in Tally (`9000` by default) |
| ESM | Package is `"type": "module"` |

---

## License

MIT — [keshavsoft.com](https://keshavsoft.com)

---
_Source: https://npm.io/package/tally-to-xml-tdl · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
