Switch from casparser

casparser is a free, MIT-licensed Python library for reading CAS PDFs. Our reader returns its JSON shape, so code written for casparser keeps working.

Credit

casparser is the reference we check against. Its detection markers and several parsing ideas informed our reader, which is our own code in TypeScript. casparser is MIT-licensed; its licence and copyright stay with its authors. We compared against casparser 1.4.1.

What maps one to one

casparserSachfolio
CAMS and KFintech CASData JSONtoCasparser(cas): same keys, same transaction types, amounts as exact decimal strings
NSDL and CDSL NSDLCASData JSONtoCasparserDemat(cas) (mutual funds only)
read_cas_pdf(path, password)readCas(bytes, { password }), or read_cas_pdf from examples/python/read_cas.py, which calls our command line
casparser file.pdf -p …npx sachfolio-cas file.pdf --format casparser, with the password on stdin
The same shape over HTTPPOST /v1/parse?format=casparser, or GET /v1/samples/{name}.casparser without a key

Documented differences

  • amfi and type are null. casparser fills them from its own ISIN database.
  • Transaction types casparser has no name for are folded in: systematic withdrawals and pledge invocations become REDEMPTION; bonus units, transfers, pledges and unit adjustments become MISC.
  • parse_warnings lists every check that failed, not only unit-balance breaks.
  • For NSDL and CDSL, equities, bonds and owners are empty, and an account's balance is the mutual fund value read, not the statement's account total.
  • Page references and checks are not in casparser's shape. Keep the CasDocument if you want them.

What Sachfolio adds

  • Page tags: every number carries the page and line it was printed on.
  • Checks: units, running balance, units × NAV, ISIN and the printed total, each pass, fail or unavailable. A holding that doesn't add up is skipped and counted in coverage, never guessed.
  • Exact decimals: amounts are decimal strings, never floats.
  • Runs in the browser: the PDF and its password stay on your user's device, with no server of yours in the path.
  • Extras: XIRR, capital gains lot by lot, redactCas(), CSV export and a JSON Schema for the output.

What casparser does that we don't

  • It is a Python package: pip install and call it in-process. Ours is JavaScript and TypeScript; from Python you call our command line.
  • It fills amfi and scheme type from its ISIN data.
  • For NSDL and CDSL it reads more than mutual funds, such as equities and bonds. We read mutual fund units and ETFs and name the rest in warnings.
  • It is free for any use under MIT. Our package is under BUSL-1.1: personal use and evaluation are free; a product needs a commercial licence.

Try it

curl https://api.sachfolio.com/v1/samples/dev-sample.casparser

No key and no sign-up. The full steps are on the developers page, and the API is described in the OpenAPI file.