SDKs & Libraries

The official Python SDK provides a Stripe-style interface for the Banklyze API with auto-pagination, typed errors, and built-in retry logic. For TypeScript/JavaScript, we provide fetch-based patterns below.

Installation

Install the Python SDK from PyPI:

Install
pip install banklyze
Requires Python 3.10+. The SDK uses httpx under the hood and supports both sync and async usage.

Client Initialization

Create a client with your API key and organization ID. Use BanklyzeClient for synchronous code or AsyncBanklyzeClient for async frameworks like FastAPI.

Client initialization
from banklyze import BanklyzeClient, AsyncBanklyzeClient

# Synchronous client
client = BanklyzeClient(
    api_key="sk_live_...",
    org_id=1,
    # base_url="https://api.banklyze.com",  # default
)

# Async client (for asyncio / FastAPI)
async_client = AsyncBanklyzeClient(
    api_key="sk_live_...",
    org_id=1,
)

Resource Methods

The SDK organizes API operations into resource namespaces. Each resource provides methods for CRUD operations and domain-specific actions.

Deals

Deals resource
# Create a deal
deal = client.deals.create(
    business_name="Acme Trucking LLC",
    entity_type="llc",
    ein="123456789",
    funding_amount_requested=50000,
)
print(deal.id)  # 42

# Get a deal
deal = client.deals.get(42)

# List deals (returns PageIterator)
for deal in client.deals.list(status="ready", per_page=50):
    print(deal.business_name, deal.health_score)

# Update a deal
deal = client.deals.update(42, status="under_review")

# Record a decision
client.deals.decide(42, decision="approved", notes="Strong financials")

Documents

Documents resource
# Upload a document
doc = client.documents.upload(
    deal_id=42,
    file=open("statement.pdf", "rb"),
    filename="statement.pdf",
)
print(doc.id, doc.status)  # "uploaded"

# List documents for a deal
docs = client.documents.list(deal_id=42)

# Check processing status
doc = client.documents.get(doc.id)
print(doc.status)  # "completed"

# Reprocess a document
client.documents.reprocess(doc.id)

Transactions

Transactions resource
# List transactions for a deal
for txn in client.transactions.list(deal_id=42, per_page=100):
    print(txn.date, txn.description, txn.amount)

# Flag a transaction
client.transactions.flag(txn_id=1001, reason="Suspected NSF")

More Resources

Exports, Events, Ingest, Rulesets, Webhooks
# Exports
export = client.exports.create(deal_id=42, format="pdf")
client.exports.download(export.id, path="./report.pdf")

# Events
for event in client.events.list(deal_id=42):
    print(event.type, event.created_at)

# Bulk Ingest
batch = client.ingest.create(
    deal_id=42,
    files=[open("jan.pdf", "rb"), open("feb.pdf", "rb")],
)
print(batch.batch_id)

# Rulesets
rulesets = client.rulesets.list()
ruleset = client.rulesets.create(
    name="Conservative",
    weights={"balance_trend": 25, "nsf_rate": 20, ...},
)

# Webhooks
config = client.webhooks.configure(
    url="https://your-app.com/hooks",
    secret="whsec_...",
    events=["deal.ready", "document.completed"],
)
ResourceMethods
client.dealslist, get, create, update, decide, notes
client.documentslist, get, upload, reprocess, download
client.transactionslist, get, flag
client.exportscreate, get, download, list
client.eventslist, get
client.ingestcreate, get_batch, list_batches
client.rulesetslist, get, create, update, delete
client.webhooksconfigure, get_config, test, list_deliveries

Auto-Pagination

All list() methods return a PageIterator that transparently fetches subsequent pages as you iterate. You never need to manage page counters manually.

Auto-pagination with PageIterator
from banklyze import BanklyzeClient

client = BanklyzeClient(api_key="sk_live_...", org_id=1)

# Auto-pagination: iterates through ALL pages transparently
all_deals = []
for deal in client.deals.list(per_page=100):
    all_deals.append(deal)

# Manual page access
page = client.deals.list(page=1, per_page=25)
print(f"Page {page.meta.page} of {page.meta.total_pages}")
print(f"{page.meta.total} total results")

# Access raw page data
for deal in page.data:
    print(deal.business_name)
Set per_page=100 for bulk operations to minimize HTTP round-trips. See the Pagination guide for more tips.

Error Handling

The SDK raises typed exceptions that map to API error codes. All exceptions inherit from BanklyzeError.

Error handling
from banklyze import BanklyzeClient
from banklyze.errors import (
    BanklyzeError,
    AuthenticationError,
    NotFoundError,
    ValidationError,
    RateLimitError,
)

client = BanklyzeClient(api_key="sk_live_...", org_id=1)

try:
    deal = client.deals.get(99999)
except NotFoundError:
    print("Deal does not exist")
except AuthenticationError:
    print("Invalid API key")
except ValidationError as e:
    print(f"Validation failed: {e.errors}")
    # e.errors = [{"field": "business_name", "message": "Field required"}]
except RateLimitError as e:
    print(f"Rate limited. Retry after {e.retry_after} seconds")
except BanklyzeError as e:
    # Catch-all for any API error
    print(f"API error {e.status_code}: {e.detail} (code={e.code})")
NameTypeRequiredDescription
BanklyzeErrorbase classRequiredBase exception for all SDK errors. Has status_code, detail, and code attributes.
AuthenticationError401OptionalRaised when the API key is missing, invalid, or revoked.
NotFoundError404OptionalRaised when the requested resource does not exist.
ValidationError422OptionalRaised on validation failures. Access .errors for field-level details.
RateLimitError429OptionalRaised when rate limited. Access .retry_after for the wait duration.

Webhook Verification

The SDK includes a helper to verify webhook signatures in your handler:

Webhook signature verification
from banklyze.webhooks import verify_signature

# In your webhook handler
is_valid = verify_signature(
    payload=request.body,           # raw bytes
    signature=request.headers["X-Banklyze-Signature"],
    secret="whsec_your_signing_secret",
)

if not is_valid:
    return Response(status_code=403)

TypeScript / JavaScript

A dedicated TypeScript SDK is not yet available. In the meantime, use the typed fetch-based patterns below as a starting point for your integration.

// TypeScript — fetch-based pattern (no SDK required)

const BANKLYZE_API = "https://api.banklyze.com/v1";
const API_KEY = process.env.BANKLYZE_API_KEY!;
const ORG_ID = process.env.BANKLYZE_ORG_ID!;

interface Deal {
  id: number;
  business_name: string;
  status: string;
  health_score: number | null;
  created_at: string;
}

interface PaginatedResponse<T> {
  data: T[];
  meta: {
    page: number;
    per_page: number;
    total: number;
    total_pages: number;
  };
}

async function banklyzeRequest<T>(
  path: string,
  options: RequestInit = {},
): Promise<T> {
  const response = await fetch(`${BANKLYZE_API}${path}`, {
    ...options,
    headers: {
      "Authorization": `Bearer ${API_KEY}`,
      "X-Org-Id": ORG_ID,
      "Content-Type": "application/json",
      ...options.headers,
    },
  });

  if (!response.ok) {
    const error = await response.json();
    throw new Error(`Banklyze API error: ${error.detail} (${error.code})`);
  }

  return response.json();
}

// Usage
const deals = await banklyzeRequest<PaginatedResponse<Deal>>(
  "/deals?page=1&per_page=25",
);

const newDeal = await banklyzeRequest<Deal>("/deals", {
  method: "POST",
  body: JSON.stringify({
    business_name: "Acme Trucking LLC",
    entity_type: "llc",
  }),
});
A first-party TypeScript SDK is on our roadmap. In the meantime, you can generate a typed client from our OpenAPI spec using tools like openapi-typescript.