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:
pip install banklyzehttpx 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.
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
# 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
# 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
# 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
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"],
)| Resource | Methods |
|---|---|
| client.deals | list, get, create, update, decide, notes |
| client.documents | list, get, upload, reprocess, download |
| client.transactions | list, get, flag |
| client.exports | create, get, download, list |
| client.events | list, get |
| client.ingest | create, get_batch, list_batches |
| client.rulesets | list, get, create, update, delete |
| client.webhooks | configure, 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.
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)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.
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})")| Name | Type | Required | Description |
|---|---|---|---|
| BanklyzeError | base class | Required | Base exception for all SDK errors. Has status_code, detail, and code attributes. |
| AuthenticationError | 401 | Optional | Raised when the API key is missing, invalid, or revoked. |
| NotFoundError | 404 | Optional | Raised when the requested resource does not exist. |
| ValidationError | 422 | Optional | Raised on validation failures. Access .errors for field-level details. |
| RateLimitError | 429 | Optional | Raised when rate limited. Access .retry_after for the wait duration. |
Webhook Verification
The SDK includes a helper to verify webhook signatures in your handler:
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",
}),
});openapi-typescript.