API docs

Parse a bank statement

One endpoint: send a PDF, get JSON back. This page covers everything you need; the interactive reference lets you try calls from the browser.

Authentication

Send your API key in the X-API-Key header. Create and revoke keys on your dashboard. Keep keys on your server; never put them in a web or mobile app.

Request

POST https://lekhaapi.com/v1/statements as multipart/form-data:

FieldRequiredDescription
fileYesThe statement PDF, up to 20 MB and 500 pages.
passwordNoThe PDF's password, if it has one. Used once to open the file, never stored.

Using Postman? Import the Lekha API collection and set its apiKey variable.

curl https://lekhaapi.com/v1/statements \
  -H "X-API-Key: $LEKHA_KEY" \
  -F file=@statement.pdf \
  -F password=OPTIONAL

Response

On success you get 200 and the statement. Amounts are strings (for example "1250.50") so no paise are lost to floating point; parse them as decimals. Fields the statement doesn't print are null.

{
  "bank": "kotak",
  "parser": "bank",
  "pages": 3,
  "ifsc": "KKBK0000123",
  "account_holder": "A Customer",
  "account_number": "1234567890",
  "period_start": "2024-04-01",
  "period_end": "2024-04-30",
  "opening_balance": "1000.00",
  "closing_balance": "2899.50",
  "transactions": [
    {"date": "2024-04-02", "value_date": "2024-04-02", "description": "UPI/SHOP/111/UPI",
     "debit": "100.50", "credit": "0", "balance": "899.50", "reference": "UPI-111"}
  ],
  "balance_check": {"passed": true, "checked_rows": 2, "first_mismatch_index": null, "expected": null, "found": null}
}
FieldDescription
bankDetected bank: kotak, indian_bank or sbi. For other banks, the name we recognise from the IFSC code (for example hdfc, icici, axis) or unknown.
parserbank: read by a parser built for this bank's layout. generic: read by our fallback for other banks (see below).
pagesPDF pages, which is also the number of credits charged.
transactions[]In date order, oldest first. date is the posting date; value_date when the statement prints one. debit and credit are positive amounts, "0" on the side that doesn't apply. balance is negative when the account is overdrawn.
balance_checkEach row's balance must equal the previous balance minus debit plus credit, and the last balance must match closing_balance when printed. If not, passed is false and first_mismatch_index points at the first row that doesn't add up, with the expected and found balances.

Response headers X-Credits-Charged and X-Credits-Remaining show the cost of the call and your balance after it.

Checking your credits

GET https://lekhaapi.com/v1/account with the same X-API-Key header returns {"credits_remaining": 450}. It's free, so check before sending a large statement.

When the balance check fails

It usually means the PDF itself is incomplete (pages removed, or a partial download), not that a row was misread. Show the result to a person rather than trusting it automatically, and if you think we got it wrong, send the error details to support@lekhaapi.com.

Errors

Errors return a non-2xx status and a body like {"error": {"code": "wrong_password", "message": "..."}}. Match on code; the message is for people and may change. Failed calls never use credits.

StatusCodeMeaning
400invalid_pdfThe file isn't a readable PDF.
400password_requiredThe PDF is encrypted; send password.
400wrong_passwordThe password didn't open the PDF.
401invalid_api_keyMissing, unknown or revoked key.
402insufficient_creditsThe document has more pages than your balance. Buy credits on the dashboard.
403account_on_holdA payment on the account is disputed; the API resumes when the dispute is resolved.
413file_too_largeOver 20 MB.
413too_many_pagesOver 500 pages.
422scanned_pdfNo text layer (a scan or photo). Use the statement downloaded from net banking or emailed by the bank.
422unsupported_bankWe don't support this bank's format yet.

Supported banks

Other banks

Statements from other banks go through a generic reader. It answers only when every row's change in balance matches an amount on that row, so a result always passes the balance check; otherwise you get unsupported_bank and no credits are used. It reads dates, amounts and balances; descriptions and account details are best effort, and it takes the first date on a row as date.

Need another bank? Write to support@lekhaapi.com.

Using an AI coding agent

Point Claude Code, Cursor, Copilot or any other agent at https://lekhaapi.com/llms.txt: the whole API on one plain-text page, written for LLMs. Tools that read schemas can use the OpenAPI spec. For example:

Read https://lekhaapi.com/llms.txt, then add a function that sends a bank statement PDF
to Lekha API and returns the transactions. Read the key from the LEKHA_KEY
environment variable and handle the error codes it lists.

MCP server

To let Claude, Cursor, VS Code or another MCP client parse statements on your computer directly, add the lekha-mcp server. It reads the PDF from disk, can save CSV or JSON, and checks your credits. With uv installed, for Claude Code:

claude mcp add lekha --env LEKHA_KEY=your-key -- uvx lekha-mcp

Other clients take "command": "uvx", "args": ["lekha-mcp"] with LEKHA_KEY in env; the setup page has the config for each one and a one-click extension for Claude Desktop.

Statements are personal financial data: if an agent works with real ones, keep them out of logs, commits and chats.

Privacy

Statements are processed in memory and discarded when the response is sent. We don't store files, passwords or extracted data. Your API key is stored only as a hash. See the privacy policy.