SDKs
Belvo provides ready-to-go SDKs in Node, Python, and Ruby to make your integration go as smoothly as possible.
Throughout all our DevPortal and API reference documentation, we provide code examples for all our SDKS.
However, if you would like to read the generated reference documentation for an SDK, or peruse the code in the GitHub repository, just click on the relevant link below:
Installation
To use our SDKs, you first need to install them locally:
$ npm install belvo --save
$ pip install belvo-python
$ gem install belvo
Usage
Link created via the widget
When your user successfully links their account using the Connect Widget, your implemented callback function will return the link_id
required to make further API to retrieve information.
Recommended
We highly recommend that you use the Connect Widget to create your links, and use our SDKs for all further calls.
var belvo = require("belvo").default;
var client = new belvo(
'YOUR-KEY-ID',
'YOUR-SECRET',
'sandbox'
);
// Get the link_id from the result of your widget callback function
const linkId = resultFromCallbackFunction.id
function retrieveAccounts (linkId) {
return client.connect().then(function () {
return client.accounts.retrieve(linkId)
.then(function (response) {
return(response);
})
.catch(function (error) {
console.error(error)
});
})
}
// Or if you prefer ES6 Async/Await
import Client from 'belvo';
const client = new Client(
'YOUR-KEY-ID',
'YOUR-SECRET',
'sandbox'
);
// Get the link_id from the result of your widget callback function
const linkId = result_from_callback_function.id
async function retrieveAccounts(linkId) {
try {
await client.connect()
return await client.accounts.retrieve(linkId);
} catch (error) {
console.log(error);
}
}
from pprint import pprint
from belvo.client import Client
from belvo.enums import AccessMode
# Login to Belvo API
client = Client("your-secret-key-id", "your-secret-key", "sandbox")
# Get the link_id from the result of your widget callback function
link_id = result_from_callback_function.id
# Get all accounts
client.Accounts.create(link=link_id)
# Pretty print all checking accounts
for account in client.Accounts.list(type="checking"):
pprint(account)
require 'belvo'
belvo = Belvo::Client.new(
'your-secret-id',
'your-secret-password',
'sandbox'
)
begin
# Get the link_id from the result of your widget callback function
link_id = result_from_callback_function.id
belvo.accounts.retrieve(link: link_id)
puts belvo.accounts.list
rescue Belvo::RequestError => e
puts e.status_code
puts e.detail
end
Link created using an SDK
You can also manually create the link using the SDK. However, for security purposes, we highly recommend that you use the Connect Widget to create the link and follow the Link created via widget example.
var belvo = require("belvo").default;
var client = new belvo(
'YOUR-KEY-ID',
'YOUR-SECRET',
'sandbox'
);
function registerLinkAndRetrieveAccounts () {
return client.connect().then(function () {
return client.links.register('erebor_mx_retail', 'bnk1002', 'full')
.then(function (response) {
return client.accounts.retrieve(response.id);
})
.then(function (response) {
return response;
})
.catch(function (error) {
console.error(error)
});
})
}
// Or if you prefer ES6 Async/Await
import Client from 'belvo';
const client = new Client(
'YOUR-KEY-ID',
'YOUR-SECRET',
'sandbox'
);
async function registerLinkAndRetrieveAccounts () {
try {
await client.connect()
const link = await client.links.register('erebor_mx_retail', 'bnk1006', 'supersecret');
console.log(link)
return await client.accounts.retrieve(link.id);
} catch (error) {
console.log(error);
}
}
from pprint import pprint
from belvo.client import Client
from belvo.enums import AccessMode
# Login to Belvo API
client = Client("your-secret-key-id", "your-secret-key", "sandbox")
# Register a link
link = client.Links.create(
institution="banamex",
username="johndoe",
password="supersecret",
access_mode=AccessMode.SINGLE
)
# Get all accounts
client.Accounts.create(link=link["id"])
# Pretty print all checking accounts
for account in client.Accounts.list(type="checking"):
pprint(account)
require 'belvo'
belvo = Belvo::Client.new(
'your-secret-id',
'your-secret-password',
'sandbox'
)
begin
new_link = belvo.links.register( # Creating the link
institution: 'banamex_mx_retail',
username: 'janedoe',
password: 'super-secret',
options: { access_mode: Belvo::Link::AccessMode::SINGLE }
)
belvo.accounts.retrieve(link: new_link['id'])
puts belvo.accounts.list
rescue Belvo::RequestError => e
puts e.status_code
puts e.detail
end
Updated about 1 year ago