Python SDK
pip install mca2-sdkRequires Python ≥3.9. Only runtime dependency is requests.
Quickstart
from mca2_sdk import MCA2Client
client = MCA2Client(
client_id="YOUR_CLIENT_ID",
client_secret="YOUR_CLIENT_SECRET",
audience="YOUR_AUDIENCE",
# base_url defaults to the sandbox host: https://testapi.mcasuite.co
)Leads
lead = client.leads.add(
company_name="Acme Inc",
company_dba="Acme",
first_name="Jane",
last_name="Doe",
email="jane@acme.com",
)Deals
deal = client.deals.add(
amount_requested=50000,
stage="Application",
company={"name": "Acme Inc", "dba": "Acme"},
owner1={"firstName": "Jane", "lastName": "Doe", "ownership": "100"},
tags=["Offer", "New"],
)
client.deals.add_note(deal_id=deal.id, status="Paying On Time", note="CEO approval received.")
fetched_deal = client.deals.get(deal.id)
with open("statement.pdf", "rb") as fh:
client.deals.add_attachment(deal_id=deal.id, file=fh)Companies
company = client.companies.add(name="Acme Inc", dba="Acme", contact_types=["Merchant"])
fetched_company = client.companies.get(company.id)
client.companies.update(company.id, website="https://acme.example.com")Submissions and submission loans
submission = client.submissions.add(
deal_id=deal.id, funder="Acme Funding", advance_amount=50000.25, frequency="1x/week"
)
submission_loan = client.submission_loans.add(
deal_id=deal.id, funder="Acme Funding", loan_amount=50000.25, frequency="monthly"
)Bulk transactions
result = client.transactions.add_bulk([
{"dealId": deal.id, "type": "payment", "amount": 10.25, "date": "2024-01-15"},
])Loan balances
balances = client.loans.get_balances(limit=100)
for loan in balances.data:
print(loan.dealId, loan.loanBalance)
# Page through further results
if balances.nextId:
next_page = client.loans.get_balances(limit=100, next_id=balances.nextId)Error handling
All API errors raise a subclass of MCA2APIError (itself a subclass of MCA2Error), with .status_code, .response_body, and .request_url:
from mca2_sdk import MCA2Client, MCA2NotFoundError
try:
client.deals.get("does-not-exist")
except MCA2NotFoundError as exc:
print(exc.status_code, exc.response_body)See the full error reference for the exception-to-status-code mapping.
A complete runnable example lives at sdks/python/examples/quickstart.py in the repository.