Investec Programmable Banking Open API Wrapper
A JavaScript/TypeScript wrapper to get up and running fast with Investec's Open API for programmable banking.
![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=round-square)
Installation
Using npm:
npm install investec-openapi
Using yarn:
yarn add investec-openapi
Usage
Setup:
import api from 'investec-openapi'
api.configure({
proxyUrl: 'ProxyUrl_see_docs_below',
clientId: 'YourClientId_do_not_share'
secret: 'YourSecret_do_not_share'
})
Get Data:
const fetchData = async () => {
const accounts = await api.getAccounts()
console.log(accounts) // prints accounts linked to account
const accountBalance = await api.getAccountBalance('accountId')
console.log(accountBalance) // prints account balance
const accountTransactions = await api.getAccountTransactions('accountId')
console.log(accountTransactions) // prints account transactions
}
OR:
const fetchData = async () => {
api.getAccounts().then(accounts => console.log(accounts))
api.getAccountBalance('accountId')
.then(accountBalance => console.log(accountBalance))
api.getAccountTransactions('accountId')
.then(accountTransactions => console.log(accountTransactions))
}
Documentation
api
is a class that once configured
will generate an access_token
behind the scenes and replace it with a new one once it's within a minute of expiring with no work required on your end.
This wrapper supports getAccounts
, getAccountBalance
and getAccountTransactions
as documented in the Investec Developer Documentation with TypeScript definitions included.
api.configure(config)
Sets up api
class with credentials to acquire and refresh access_token
. Can be called again to change credentials and refresh access_token
for new credentials. Other API calls will wait until access_token
is set (by calling this function) before running.
config
parameters:
proxyUrl
- optional
default: 'https://young-thicket-56542.herokuapp.com/'
Note: Without a proxyUrl
, you'll experience CORS issues. If anyone has an ideas on how to bypass this more cleanly, let me know! For now the default value should work. Sometimes the Heroko app needs to spin up initially so the first load may take longer than usual. Default url is a clone of https://cors-anywhere.herokuapp.com/ from this SO post: https://stackoverflow.com/a/43268098/2111515
clientId
- required
Get this from https://login.secure.investec.com/io/programmable-banking/cards/overview
secret
- required
Get this from Get this from https://login.secure.investec.com/io/programmable-banking/cards/overview
api.getAccounts()
Returns list of accounts with details for configured credentials.
Response:
{
data: {
accounts: {
accountId: string
accountNumber: string
accountName: string
referenceName: string
productName: string
}[]
}
links: {
self: string
}
meta: {
totalPages: number
}
}
api.getAccountBalance(accountId)
Returns account balance details for selected account.
accountId
- required
Response:
{
data: {
accountId: string
currentBalance: number
availableBalance: number
currency: string
}
links: {
self: string
}
meta: {
totalPages: number
}
}
api.getAccountBalance(accountId)
Returns list of transaction details for selected account.
accountId
- required
Response:
{
data: {
transactions: {
accountId: string
type: string
status: string
description: string
cardNumber: string
postingData: string
valueDate: string
actionDate: string
amount: number
}[]
}
links: {
self: string
}
meta: {
totalPages: number
}
}
Hope you find this useful! Please give a star and feel free to contribute or log issues and feature requests!
And if you want to say thanks, then please:
![Buy Me A Coffee](https://cdn.buymeacoffee.com/buttons/default-orange.png)