# Lekha API > Indian bank statement PDFs to JSON in one API call. Every transaction with dates, amounts and balances, checked > against the running balance. Pay per page; failed calls are free. Statements are processed in memory, never stored. ## Quick start - Get an API key: sign in at https://lekhaapi.com/login (email link; new accounts get 50 free pages). Keys are on https://lekhaapi.com/dashboard. - Call: `POST https://lekhaapi.com/v1/statements`, `multipart/form-data`, header `X-API-Key: `. - `file` (required): the statement PDF, up to 20 MB and 500 pages. - `password` (optional): the PDF's password, if it is encrypted. ``` curl https://lekhaapi.com/v1/statements -H "X-API-Key: $LEKHA_KEY" -F file=@statement.pdf -F password=OPTIONAL ``` ## Response (200) JSON with `bank`, `parser` (`bank` or `generic`), `pages` (= credits charged), `ifsc`, `account_holder`, `account_number`, `period_start`, `period_end`, `opening_balance`, `closing_balance`, `transactions[]` and `balance_check`. - Amounts are decimal strings such as `"1250.50"`. Parse them as decimals, never floats. - Each transaction: `date`, `value_date`, `description`, `debit`, `credit` (positive; `"0"` on the side that doesn't apply), `balance` (negative when overdrawn), `reference`. Oldest first. - `balance_check.passed` false means the rows don't add up (usually an incomplete PDF): show the result to a person instead of trusting it. `first_mismatch_index`, `expected` and `found` locate the problem. - Headers `X-Credits-Charged` and `X-Credits-Remaining` show the cost and the balance left. ## Credits `GET https://lekhaapi.com/v1/account` (same `X-API-Key` header) returns `{"credits_remaining": 450}`. Free to call; one credit is one PDF page. ## Errors Non-2xx with `{"error": {"code": "...", "message": "..."}}`. Match on `code`; the message may change. Failed calls use no credits. - 400 `invalid_pdf`, `password_required`, `wrong_password` - 401 `invalid_api_key` - 402 `insufficient_credits` (buy credits on the dashboard) - 403 `account_on_hold` (a payment is disputed) - 413 `file_too_large`, `too_many_pages` - 422 `scanned_pdf` (no text layer; use the PDF from net banking or the bank's email), `unsupported_bank` ## Banks Dedicated parsers: Kotak Mahindra Bank, Indian Bank, State Bank of India. Other banks go through a generic reader that answers only when every row's balance change matches an amount on the row; otherwise `unsupported_bank`. ## MCP server `uvx lekha-mcp` (PyPI `lekha-mcp`, MCP Registry `io.github.backstab319/lekha-mcp`): local stdio server with `parse_statement(pdf_path, password?, save_to?)` and `get_credits()`. Needs `LEKHA_KEY` in its environment. Claude Code: `claude mcp add lekha --env LEKHA_KEY=your-key -- uvx lekha-mcp`. Claude Desktop one-click extension and setup for other clients: https://lekhaapi.com/mcp ## Rules for agents - Keep the API key on the server or in an environment variable (`LEKHA_KEY`); never put it in browser or mobile code or commit it. - Don't log or store statement contents; they are personal financial data. - Use a timeout of at least 120 seconds for large statements. ## Docs - [API docs](https://lekhaapi.com/api-docs): full reference with examples - [OpenAPI spec](https://lekhaapi.com/openapi.json): machine-readable schema - [Interactive reference](https://lekhaapi.com/docs) - [Postman collection](https://lekhaapi.com/static/lekha-api.postman_collection.json) - [Privacy policy](https://lekhaapi.com/legal/privacy) - Support: support@lekhaapi.com