Lending
Lending helps you make smarter credit decisions on small businesses by enabling you to pull your customers' latest data from the operating systems they are already using. You can use that data for automating decisioning and surfacing new insights on the customer, all via one API.
SDK Installation
NPM
npm add @codat/lending
Yarn
yarn add @codat/lending
Example Usage
SDK Example Usage
Example
import { CodatLending } from "@codat/lending";
async function run() {
const sdk = new CodatLending({
security: {
authHeader: "Basic BASE_64_ENCODED(API_KEY)",
},
});
const res = await sdk.companies.create({
description: "Requested early access to the new financing scheme.",
groups: [
{
id: "60d2fa12-8a04-11ee-b9d1-0242ac120002",
},
],
name: "Bank of Dave",
});
if (res.statusCode == 200) {
// handle response
}
}
run();
Available Resources and Operations
companies
- create - Create company
- delete - Delete a company
- get - Get company
- list - List companies
- update - Update company
connections
- create - Create connection
- delete - Delete connection
- get - Get connection
- list - List connections
- unlink - Unlink connection
transactions.accountTransactions
transactions.directCosts
- downloadAttachment - Download direct cost attachment
- get - Get direct cost
- getAttachment - Get direct cost attachment
- list - List direct costs
- listAttachments - List direct cost attachments
transactions.transfers
transactions.journalEntries
transactions.journals
accountingBankData
- listTransactions - List bank account transactions
accountingBankData.accounts
banking.accountBalances
- list - List account balances
banking.accounts
banking.transactionCategories
banking.transactions
banking.categorizedStatement
- get - Get categorized bank statement
accountsPayable.bills
- downloadAttachment - Download bill attachment
- get - Get bill
- getAttachment - Get bill attachment
- list - List bills
- listAttachments - List bill attachments
accountsPayable.suppliers
- downloadAttachment - Download supplier attachment
- get - Get supplier
- getAttachment - Get supplier attachment
- list - List suppliers
- listAttachments - List supplier attachments
accountsPayable.billCreditNotes
accountsPayable.billPayments
sales.customers
sales.disputes
sales.locations
sales.orders
sales.paymentMethods
sales.payments
sales.productCategories
sales.products
sales.transactions
sales.metrics
- getCustomerRetention - Get customer retention metrics
- getLifetimeValue - Get lifetime value metrics
- getRevenue - Get commerce revenue metrics
sales.reports
- getOrders - Get orders report
- getRefunds - Get refunds report
companyInfo
- getAccountingProfile - Get company accounting profile
- getCommerceProfile - Get company commerce profile
accountsReceivable.customers
- downloadAttachment - Download customer attachment
- get - Get customer
- getAttachment - Get customer attachment
- list - List customers
- listAttachments - List customer attachments
accountsReceivable.directIncomes
- downloadAttachment - Download direct income attachment
- get - Get direct income
- getAttachment - Get direct income attachment
- list - List direct incomes
- listAttachments - List direct income attachments
accountsReceivable.invoices
- downloadAttachment - Download invoice attachment
- downloadPdf - Get invoice as PDF
- get - Get invoice
- getAttachment - Get invoice attachment
- list - List invoices
- listAttachments - List invoice attachments
- listReconciled - List reconciled invoices
accountsReceivable.creditNotes
accountsReceivable.payments
accountsReceivable.reports
- getAgedCreditors - Aged creditors report
- getAgedDebtors - Aged debtors report
- isAgedCreditorsAvailable - Aged creditors report available
- isAgedDebtorsAvailable - Aged debtors report available
fileUpload
- download - Download all files for a company
- listUploaded - List all files uploaded by a company
- upload - Upload files for a company
loanWriteback.bankAccounts
- create - Create bank account
- getCreateUpdateModel - Get create/update bank account model
loanWriteback.bankTransactions
- create - Create bank account transactions
- getCreateModel - Get create bank account transactions model
loanWriteback.accounts
- create - Create account
- getCreateModel - Get create account model
loanWriteback.directCosts
- create - Create direct cost
- getCreateModel - Get create direct cost model
loanWriteback.payments
- create - Create payment
- getCreateModel - Get create payment model
loanWriteback.suppliers
- create - Create supplier
- getCreateUpdateModel - Get create/update supplier model
loanWriteback.transfers
- create - Create transfer
- getCreateModel - Get create transfer model
loanWriteback.createOperations
financialStatements.accounts
financialStatements.balanceSheet
- get - Get balance sheet
- getCategorizedAccounts - Get categorized balance sheet statement
financialStatements.cashFlow
- get - Get cash flow statement
financialStatements.profitAndLoss
- get - Get profit and loss
- getCategorizedAccounts - Get categorized profit and loss statement
manageData
- getStatus - Get data status
manageData.refresh
- allDataTypes - Refresh all data
- dataType - Refresh data type
manageData.pullOperations
liabilities
- generateLoanSummary - Generate loan summaries report
- generateLoanTransactions - Generate loan transactions report
- getLoanSummary - Get loan summaries
- listLoanTransactions - List loan transactions
dataIntegrity
- details - List data integrity details
- status - Get data integrity status
- summaries - Get data integrity summaries
excelReports
- download - Download Excel report
- generate - Generate Excel report
- getStatus - Get Excel report status
Retries
Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.
To change the default retry strategy for a single API call, simply provide a retryConfig object to the call:
import { CodatLending } from "@codat/lending";
async function run() {
const sdk = new CodatLending({
security: {
authHeader: "Basic BASE_64_ENCODED(API_KEY)",
},
});
const res = await sdk.companies.create(
{
description: "Requested early access to the new financing scheme.",
groups: [
{
id: "60d2fa12-8a04-11ee-b9d1-0242ac120002",
},
],
name: "Bank of Dave",
},
{
strategy: "backoff",
backoff: {
initialInterval: 1,
maxInterval: 50,
exponent: 1.1,
maxElapsedTime: 100,
},
retryConnectionErrors: false,
}
);
if (res.statusCode == 200) {
// handle response
}
}
run();
If you'd like to override the default retry strategy for all operations that support retries, you can provide a retryConfig at SDK initialization:
import { CodatLending } from "@codat/lending";
async function run() {
const sdk = new CodatLending({
retry_config: {
strategy: "backoff",
backoff: {
initialInterval: 1,
maxInterval: 50,
exponent: 1.1,
maxElapsedTime: 100,
},
retryConnectionErrors: false,
},
security: {
authHeader: "Basic BASE_64_ENCODED(API_KEY)",
},
});
const res = await sdk.companies.create({
description: "Requested early access to the new financing scheme.",
groups: [
{
id: "60d2fa12-8a04-11ee-b9d1-0242ac120002",
},
],
name: "Bank of Dave",
});
if (res.statusCode == 200) {
// handle response
}
}
run();
Error Handling
Handling errors in this SDK should largely match your expectations. All operations return a response object or throw an error. If Error objects are specified in your OpenAPI Spec, the SDK will throw the appropriate Error type.
Error Object | Status Code | Content Type |
---|---|---|
errors.SDKError | 4xx-5xx | / |
Example
import { CodatLending } from "@codat/lending";
async function run() {
const sdk = new CodatLending({
security: {
authHeader: "Basic BASE_64_ENCODED(API_KEY)",
},
});
let res;
try {
res = await sdk.companies.create({
description: "Requested early access to the new financing scheme.",
groups: [
{
id: "60d2fa12-8a04-11ee-b9d1-0242ac120002",
},
],
name: "Bank of Dave",
});
} catch (err) {
if (err instanceof errors.SDKError) {
console.error(err); // handle exception
throw err;
}
}
if (res.statusCode == 200) {
// handle response
}
}
run();
Server Selection
Select Server by Index
You can override the default server globally by passing a server index to the serverIdx: number
optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the indexes associated with the available servers:
# | Server | Variables |
---|---|---|
0 | https://api.codat.io |
None |
Example
import { CodatLending } from "@codat/lending";
async function run() {
const sdk = new CodatLending({
serverIdx: 0,
security: {
authHeader: "Basic BASE_64_ENCODED(API_KEY)",
},
});
const res = await sdk.companies.create({
description: "Requested early access to the new financing scheme.",
groups: [
{
id: "60d2fa12-8a04-11ee-b9d1-0242ac120002",
},
],
name: "Bank of Dave",
});
if (res.statusCode == 200) {
// handle response
}
}
run();
Override Server URL Per-Client
The default server can also be overridden globally by passing a URL to the serverURL: str
optional parameter when initializing the SDK client instance. For example:
import { CodatLending } from "@codat/lending";
async function run() {
const sdk = new CodatLending({
serverURL: "https://api.codat.io",
security: {
authHeader: "Basic BASE_64_ENCODED(API_KEY)",
},
});
const res = await sdk.companies.create({
description: "Requested early access to the new financing scheme.",
groups: [
{
id: "60d2fa12-8a04-11ee-b9d1-0242ac120002",
},
],
name: "Bank of Dave",
});
if (res.statusCode == 200) {
// handle response
}
}
run();
Custom HTTP Client
The Typescript SDK makes API calls using the axios HTTP library. In order to provide a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration, you can initialize the SDK client with a custom AxiosInstance
object.
For example, you could specify a header for every request that your sdk makes as follows:
import { @codat/lending } from "CodatLending";
import axios from "axios";
const httpClient = axios.create({
headers: {'x-custom-header': 'someValue'}
})
const sdk = new CodatLending({defaultClient: httpClient});
Authentication
Per-Client Security Schemes
This SDK supports the following security scheme globally:
Name | Type | Scheme |
---|---|---|
authHeader |
apiKey | API key |
You can set the security parameters through the security
optional parameter when initializing the SDK client instance. For example:
import { CodatLending } from "@codat/lending";
async function run() {
const sdk = new CodatLending({
security: {
authHeader: "Basic BASE_64_ENCODED(API_KEY)",
},
});
const res = await sdk.companies.create({
description: "Requested early access to the new financing scheme.",
groups: [
{
id: "60d2fa12-8a04-11ee-b9d1-0242ac120002",
},
],
name: "Bank of Dave",
});
if (res.statusCode == 200) {
// handle response
}
}
run();
Support
If you encounter any challenges while utilizing our SDKs, please don't hesitate to reach out for assistance. You can raise any issues by contacting your dedicated Codat representative or reaching out to our support team. We're here to help ensure a smooth experience for you.