TallyPrime API Integration: XML, JSON and Your Apps
How TallyPrime exposes data to other software, XML vs the new JSON support, a working request, what can sync, and the errors that trip up Tally integrations.
Tally API integration works differently from most modern APIs. TallyPrime doesn't offer a hosted cloud API. Instead, the TallyPrime application on your computer acts as a small HTTP server on a port you choose (commonly 9000), and other software sends it requests, traditionally in XML and, from TallyPrime Release 7.0, also in JSON. TallyPrime must be running, with the right company loaded, for any request to work. So connecting Tally to a website, e-commerce store or your own apps almost always needs a piece of middleware on the same network as Tally that talks to Tally locally and to your app over the internet. This guide explains each part.
How TallyPrime exposes its data
TallyPrime's integration features are documented on TallyHelp. In practice you'll meet four routes:
| Route | What it is | Typical use |
|---|---|---|
| XML over HTTP | Send an XML "envelope" to TallyPrime's port; it replies in XML | The classic route for exporting reports and importing masters and vouchers |
| JSON over HTTP | Native JSON requests and responses, added in TallyPrime Release 7.0 | Newer integrations; easier to work with from web stacks |
| ODBC | Read Tally data from tools that speak ODBC | Reporting and Excel-style pulls |
| TDL | Tally Definition Language, Tally's own customisation language | Custom reports, custom import formats, or Tally pushing data out itself |
For a web app integration you'll mostly use XML or JSON over HTTP, sometimes with a small TDL customisation when the data you need isn't available in a standard report or collection.
Turning on the HTTP interface
TallyPrime listens for requests only if it's configured to act as a server. In TallyPrime this sits under the connectivity settings (Help → Settings → Connectivity, client/server configuration). Set TallyPrime to act as Server or Both, and choose a port. 9000 is the common default.
TallyHelp lists the prerequisites for integrations, and they're worth repeating because they cause most "it doesn't respond" tickets:
- TallyPrime must be running, not just installed.
- The company you want to read or write must be loaded, and requests should name it explicitly.
- The port must be free and allowed through the Windows firewall on that machine.
A first request: export the list of ledgers
The simplest useful request asks TallyPrime for a collection, such as all ledgers. An XML export request has a header (what you want) and a body (parameters such as the company and output format):
<ENVELOPE>
<HEADER>
<VERSION>1</VERSION>
<TALLYREQUEST>Export</TALLYREQUEST>
<TYPE>Collection</TYPE>
<ID>List of Ledgers</ID>
</HEADER>
<BODY>
<DESC>
<STATICVARIABLES>
<SVCURRENTCOMPANY>Your Company Name</SVCURRENTCOMPANY>
<SVEXPORTFORMAT>$$SysName:XML</SVEXPORTFORMAT>
</STATICVARIABLES>
</DESC>
</BODY>
</ENVELOPE>
Save it as ledgers.xml and send it from the same machine with curl:
curl -X POST http://localhost:9000 -H "Content-Type: text/xml" --data-binary @ledgers.xml
TYPE selects what you're asking for: Object for one item (a single ledger or stock item), Collection for a list, and Data for a report such as a trial balance. Writing data uses TALLYREQUEST set to Import, with the masters or vouchers in the body. TallyPrime replies with counts of what was created, altered or rejected, so always read the response.
XML or JSON?
From Release 7.0, TallyHelp documents native JSON integration: requests carry headers such as the request type and ID, and the body must include the company name. Data already in TallyPrime's own object structure can be imported or pushed over HTTP without extra TDL, while JSON in some other shape still needs TDL to map it. Release 7.0 also introduced a more structured variant called JSONEx.
Which to use:
- Use JSON if every Tally installation you connect to is on Release 7.0 or later and your team works mainly in JavaScript, Python or similar.
- Use XML if you must support older TallyPrime or Tally.ERP 9 installations, or you're extending an integration that already uses XML.
Either way, the request model is the same: a local HTTP call to a running TallyPrime.
Where middleware fits
Most businesses run TallyPrime on a desktop or local server in the office, while their website, store or app runs in the cloud. Don't expose Tally's port directly to the internet. It wasn't designed to be a public API.
The usual architecture is:
- A small connector runs on the office network next to TallyPrime.
- It calls TallyPrime locally over HTTP (XML or JSON).
- It talks to your cloud app over HTTPS, pushing changes out (new invoices, stock levels) and pulling changes in (orders, receipts) to import into Tally.
- It keeps track of what has already synced, so nothing is posted twice.
Decide early whether sync runs on a schedule (every few minutes or hourly, simpler and fine for stock levels and reports) or in real time (needed when an order on your site must appear in Tally immediately).
What data is worth syncing
Most integrations move a handful of things:
- Masters: ledgers (customers, suppliers), stock items, units, godowns.
- Vouchers: sales, purchase and journal vouchers, and sometimes receipts and payments.
- Stock levels: so a storefront doesn't sell what isn't there.
- Reports: outstanding balances or a trial balance for dashboards.
Start with one direction and one voucher type, prove it reconciles with the books for a month, then add more. That's also how our Tally Sync API is rolled out: sales, purchase and journal vouchers, ledgers and stock, kept in sync both ways, on a schedule or as changes happen.
Common errors and how to avoid them
- No response or connection refused: TallyPrime isn't running, isn't set to act as a server, or the firewall is blocking the port.
- Data goes to the wrong company: the request didn't name the company, so TallyPrime used whichever one was active. Always send the company name.
- Voucher rejected: a ledger, stock item or voucher type in the voucher doesn't exist in Tally with exactly that name. Create or map masters first, then post vouchers.
- Totals don't match: rounding, GST ledgers or inclusive vs exclusive prices are handled differently in your app and in Tally. Agree the posting rules with your accountant before writing code.
- Duplicates: a retried request posted the same voucher twice. Keep your own record of which source documents have been posted.
Frequently asked questions
Does Tally have a REST API?
Not a hosted cloud one. TallyPrime itself acts as a local HTTP server that accepts XML requests, and from Release 7.0 native JSON requests too. To reach it from a cloud app, you run a connector on the same network as Tally that calls it locally.
Which port does TallyPrime use for integration?
You choose it in TallyPrime's connectivity settings when you set TallyPrime to act as a server. 9000 is the common default. If another program already uses that port, pick a different one and use the same number in your requests.
Can TallyPrime accept JSON?
Yes, from TallyPrime Release 7.0. TallyHelp documents native JSON import and HTTP requests for masters, transactions and reports. Older releases and Tally.ERP 9 need XML, so check the release on every machine you integrate with.
Does TallyPrime need to be open for the integration to work?
Yes. TallyPrime answers integration requests only while it's running with the company loaded, and with its server setting turned on. Integrations that need to run around the clock usually keep TallyPrime running on an always-on machine in the office.
Can data sync both ways between Tally and a website?
Yes. A connector can export vouchers, ledgers and stock from Tally and import orders or receipts back as vouchers. Two-way sync needs clear rules about which system owns which data, and a record of what has been posted, to avoid duplicates.
Sources
- TallyHelp, Integration with TallyPrime
- TallyHelp, Pre-requisites for integrations
- TallyHelp, Sample XML
- TallyHelp, How to integrate with TallyPrime using JSON
- TallyHelp, Release notes for TallyPrime Release 7.0