npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@lekha-dev/sdk

v0.1.0

Published

Official SDK for Lekha — financial document intelligence API for AI agents

Downloads

16

Readme

lekha

Official SDK for Lekha -- financial document intelligence API for AI agents.

Send any Indian financial document (bank statement, CAS report, salary slip) and get back clean, structured JSON.

Installation

npm install @lekha-dev/sdk

Quick Start

import { Lekha } from "@lekha-dev/sdk";
import { readFileSync } from "fs";

const lekha = new Lekha("lk_live_your_api_key");

// Extract data from a bank statement
const result = await lekha.extract({
  document: readFileSync("statement.pdf").toString("base64"),
  type: "bank_statement",
});

console.log(result.data); // Structured JSON with account, transactions, summary

API Reference

new Lekha(apiKey)

Create a client with an API key string:

const lekha = new Lekha("lk_live_your_api_key");

Or with a config object:

const lekha = new Lekha({
  apiKey: "lk_live_your_api_key",
  baseUrl: "https://custom-endpoint.example.com", // optional
});

lekha.extract(options)

Extract structured data from a financial document.

const result = await lekha.extract({
  document: base64String, // base64-encoded PDF, PNG, or JPEG
  type: "auto", // "auto" | "bank_statement" | "cas" | "salary_slip" | "itr" | "cibil" | "gst_invoice"
  options: {
    categorize_transactions: true, // default: true
    include_confidence_scores: true, // default: true
    include_raw_text: false, // default: false
  },
});

Returns: ExtractResponse with document_type, institution, confidence, data, validation, and metadata.

lekha.supported()

List supported document types and institutions.

const supported = await lekha.supported();
// { document_types: { bank_statement: { supported_institutions: [...], extracted_fields: [...] } } }

lekha.usage()

Check your API usage for the current billing period.

const usage = await lekha.usage();
// { plan: "free", usage: { extractions_used: 42, extractions_limit: 100, extractions_remaining: 58 } }

Agent Framework Integrations

Claude Tool Use (Anthropic SDK)

import Anthropic from "@anthropic-ai/sdk";
import { lekhaToolDefinition } from "@lekha-dev/sdk/tool-definition";
import { Lekha } from "@lekha-dev/sdk";

const anthropic = new Anthropic();
const lekha = new Lekha("lk_live_your_api_key");

// Register as a tool
const response = await anthropic.messages.create({
  model: "claude-sonnet-4-20250514",
  tools: [lekhaToolDefinition],
  messages: [{ role: "user", content: "Analyze my bank statement" }],
});

// Handle tool calls
for (const block of response.content) {
  if (block.type === "tool_use" && block.name === "extract_financial_document") {
    const input = block.input as { document: string; type?: string };
    const result = await lekha.extract({
      document: input.document,
      type: (input.type as "auto" | "bank_statement") ?? "auto",
    });
    // Return result to Claude...
  }
}

LangChain

import { createLekhaLangChainTool } from "@lekha-dev/sdk/integrations/langchain";

const tool = createLekhaLangChainTool({ apiKey: "lk_live_your_api_key" });
// Use `tool` with LangChain's agent executor

Vercel AI SDK

import { createLekhaVercelTool } from "@lekha-dev/sdk/integrations/vercel-ai";

const tool = createLekhaVercelTool({ apiKey: "lk_live_your_api_key" });
// Use with Vercel AI SDK's `tools` parameter

Error Handling

All API errors throw a LekhaError with structured information:

import { Lekha, LekhaError } from "@lekha-dev/sdk";

try {
  await lekha.extract({ document: "..." });
} catch (err) {
  if (err instanceof LekhaError) {
    console.error(err.code);       // "INVALID_API_KEY"
    console.error(err.message);    // "Invalid key"
    console.error(err.status);     // 401
    console.error(err.suggestion); // "Check your API key in the dashboard"
  }
}

License

MIT