An NPM module to interact with Investec's Open API
(This module has types, so intellisense is your friend).
import { Client } from "investec-api";
const client = await Client.create(id, secret, apiKey, baseUrl?);| Param | Required | Description |
|---|---|---|
id |
true |
Your API key ID issued by Investec. |
secret |
true |
The corresponding API key secret. |
apiKey |
true |
The corresponding API key. |
baseUrl |
false |
Optional base URL that will be used when interacting with the Investec Open API. If none is passed, then "https://openapi.investec.com" is used. |
This creates an access token that the client will use to interact with the API.
If you start to get errors about the token no longer being valid, simply call:
await client.authenticate();const accounts = await client.getAccounts("private" | "business" = "private");This returns an array of Account objects.
On an Account object, you can:
const balance = await account.getBalance();const transactions = await account.getTransactions({
fromDate: string;
toDate: string;
transactionType: string;
});const transfer = await account.transfer([
{
account: Account;
amount: number;
myReference: string;
theirReference: string;
}
]);const payment = await account.pay([
{
beneficiary: InvestecBeneficiary;
myReference: string;
theirReference: string;
amount: number;
}
]);const beneficiaries = await client.getBeneficiaries();const beneficiaryCategories = await client.getBeneficiaryCategories();const cards = await client.getCards();const countries = await Card.getCountries();const countries = await Card.getCurrencies();const countries = await Card.getMerchants();On a Card object, you can:
const savedCode = await card.getSavedCode();const publishedCode = await card.getPublishedCode();const updatedCode = await card.updateSavedCode(code: string);const publishedCode = await card.publishSavedCode(codeId: string);const execution = await card.simulateFunctionExecution({
code: string;
centsAmount: string;
currencyCode: string;
merchantCode: number;
merchantCity: string;
countryCode: string;
});const executions = await card.getExecutions();const variables = await card.getEnvironmentVariables();const variables = await card.updateEnvironmentVariables({...});You can read more about Investec's Programmable Banking here.
This library is merely an interface to the above.