Skip to main content

Xfina Logo

Xfina (Python Bindings)

Crates.io PyPI npm

Xfina is a blazingly fast library for parsing Indian financial statements (Bank Accounts, Credit Cards, Mutual Funds) and international brokers (IBKR), written in Rust and exposed to Python via PyO3.

It converts raw PDFs, Excel files, and CSVs into structured, ReBIT-compliant JSON dictionaries in milliseconds.

Installation

pip install xfina

Quick Start

The Python bindings expose the exact same parsing functions as the Rust core. To keep the core parsing logic as pure functions without side-effects (like file I/O), the library requires raw bytes to be passed in rather than file paths.

Parsing a Credit Card Statement

import xfina
import os

filename = "icici_cc_statement.xls"

with open(filename, "rb") as f:
    file_bytes = f.read()

result = xfina.parse_icici_cc(
    file_bytes, 
    filename=filename,
    modified_timestamp=int(os.path.getmtime(filename))
)

print(f"Validation Status: {result['validation']['overall']}")

Parsing a Bank Statement (Excel)

import xfina
import os

filename = "hdfc_statement.xls"
modified_ts = int(os.path.getmtime(filename))

# Read the file as raw bytes
with open(filename, "rb") as f:
    file_bytes = f.read()

# Parse it! Providing the filename and modified timestamp helps improve parsing accuracy
result = xfina.parse_hdfc_ba(
    file_bytes, 
    password=None, 
    filename=filename,
    modified_timestamp=modified_ts,
    format="xfina"
)

# The returned dictionary contains both the validation report and the financial data
print(f"Validation Status: {result['validation']['overall']}")
print(f"Account Name: {result['data']['profile']['holders']['holder'][0]['name']}")

Parsing a CAMS Mutual Fund Statement (PDF)

import xfina
import json

with open("cams_cas.pdf", "rb") as f:
    file_bytes = f.read()

# Pass the password to decrypt the PDF
mf_data = xfina.parse_cams(file_bytes, password="PAN1234567")

# It returns a standard Python dictionary. You can easily dump it to JSON:
with open("output.json", "w") as f:
    json.dump(mf_data, f, indent=2)

Parsing an IBKR Statement (CSV)

import xfina

# All parsers now uniformly expect raw bytes, even for CSVs
with open("ibkr_activity.csv", "rb") as f:
    file_bytes = f.read()

result = xfina.parse_ibkr(file_bytes, format="rebit")

Available Parsers

All parsers return a structured Python dictionary that mirrors the ReBIT JSON schema. Each parser accepts an optional format parameter which defaults to "xfina", but can be "rebit" for strict AA schema compliance without our extended data fields.

Category Institution Format Python Function Input Type
Bank Account HDFC .xls parse_hdfc_ba(bytes, **kwargs) bytes
Bank Account ICICI .xls parse_icici_ba(bytes, **kwargs) bytes
Bank Account SBI PDF parse_sbi_ba(bytes, **kwargs) bytes
Bank Account BOB .xls parse_bob_ba(bytes, **kwargs) bytes
Bank Account Axis .xls parse_axis_ba(bytes, **kwargs) bytes
Credit Card HDFC CSV parse_hdfc_cc(bytes, **kwargs) bytes
Credit Card ICICI .xls parse_icici_cc(bytes, **kwargs) bytes
Mutual Funds CAMS PDF parse_cams(bytes, **kwargs) bytes
Intl Stocks IBKR CSV parse_ibkr(bytes, **kwargs) bytes

Note: All Python functions accept the following optional keyword arguments: password, filename, modified_timestamp, and format.

Release files for xfina 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xfina 0.4.1
File Size Uploaded
xfina-0.4.1.tar.gz 181.6 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for xfina 0.4.1
File
xfina-0.4.1-cp38-abi3-win_amd64.whl CPython 3.8 abi3 Windows x86-64 Details
xfina-0.4.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.8 abi3 Linux glibc 2.17+ x86-64 Details
xfina-0.4.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.8 abi3 Linux glibc 2.17+ ARM64 Details
xfina-0.4.1-cp38-abi3-macosx_11_0_arm64.whl CPython 3.8 abi3 macOS 11.0+ ARM64 Details
xfina-0.4.1-cp38-abi3-macosx_10_12_x86_64.whl CPython 3.8 abi3 macOS 10.12+ x86-64 Details

Total release size: 12.6 MB

Release files / xfina-0.4.1.tar.gz

Download URL xfina-0.4.1.tar.gz
Size 181.6 kB
Tags Source
SHA-256 checksum
How to use checksums
a6f618cc3c548beefc531935ea031aa0feaad671485217ea2fd94591e4c2dc93
BLAKE2b-256 checksum
How to use checksums
27d2f27cb360c244e1f91b6d49f99bd4eafdaf6f89ec729aefa321cc7f2d55b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 2, 2026.

Transparency log

Release files / xfina-0.4.1-cp38-abi3-win_amd64.whl

Download URL xfina-0.4.1-cp38-abi3-win_amd64.whl
Size 2.3 MB
Tags CPython 3.8 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
fdc905b478a768ba8ce1544f2dd1ce44f9090bb3c46c2e4150fb2b45de7295a5
BLAKE2b-256 checksum
How to use checksums
182b67fdd00d81a48642b67623e70fc1deba6fdf5263a0c18958524d72639f7c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 2, 2026.

Transparency log

Release files / xfina-0.4.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL xfina-0.4.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 2.7 MB
Tags CPython 3.8 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
d64128b3262c77e2f1775bfc9f8702525cfedb800769d7f606cdfa1f85e1df11
BLAKE2b-256 checksum
How to use checksums
1b3094b8dbaf0ccbf2bf572eb3ff43d6abaa4aa7d4982ba34542c7df880af659
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 2, 2026.

Transparency log

Release files / xfina-0.4.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL xfina-0.4.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 2.7 MB
Tags CPython 3.8 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
4ae0fc0b8b72a575546896864652721c12715b6083873359df30a5ab22e4eee5
BLAKE2b-256 checksum
How to use checksums
d61b0ec784cfde5c416852864ba3d278747b9f4cee4710a1edd4823d6544da6c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 2, 2026.

Transparency log

Release files / xfina-0.4.1-cp38-abi3-macosx_11_0_arm64.whl

Download URL xfina-0.4.1-cp38-abi3-macosx_11_0_arm64.whl
Size 2.4 MB
Tags CPython 3.8 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
12a48064054a927af37d20acc4f657e0df4ea744e31ad72d70a5fc156ac4a6fb
BLAKE2b-256 checksum
How to use checksums
ed72219c813e641db0a0256b8331899ae20f1854acb99f7b6eabf4db822db74c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 2, 2026.

Transparency log

Release files / xfina-0.4.1-cp38-abi3-macosx_10_12_x86_64.whl

Download URL xfina-0.4.1-cp38-abi3-macosx_10_12_x86_64.whl
Size 2.4 MB
Tags CPython 3.8 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
1bbc4100c6faa07b02a5c5a4857a9e866156118f8369a79c1112469e6e9f7324
BLAKE2b-256 checksum
How to use checksums
dcdef9e4a8444a1de3ed4ed027404cb596bba1a24aa489c4fad33d30a987a113
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 2, 2026.

Transparency log

Release history Release notifications | RSS feed

0.7.0

6 release files

0.6.1

6 release files

0.6.0

6 release files

0.5.0

6 release files

This release

0.4.1 This release

6 release files

0.4.0

5 release files

0.3.0

1 release file

0.2.4

1 release file

0.2.3

1 release file

0.2.2

1 release file

0.2.1

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page