Get Started
The best way to get started with Wealthica API is via the Wealthica JS SDKs (Frontend and Backend). You can take a look at the Wealthica Example project or follow the steps below:
1. Import the SDK
You can import the distribution build directly in your webpage:
<!-- Import the specific version -->
<script src="https://unpkg.com/wealthica-sdk-js@0.0.14/dist/wealthica.js"></script>
<!-- Or import the latest version (may contain breaking changes) -->
<script src="https://unpkg.com/wealthica-sdk-js/dist/wealthica.js"></script>
Or install and import it in a JS build system / NodeJS.
The same package is used for both frontend (web, mobile or desktop app) and backend (NodeJS).
npm install --save wealthica-sdk-js
// commonjs
const Wealthica = require('wealthica-sdk-js');
// esX
import Wealthica from 'wealthica-sdk-js';
2. Initialize the wealthica
instance
A wealthica
instance is initialized using your Client ID and Client Secret in the backend, or only Client ID in the frontend.
Backend
const wealthica = Wealthica.init({
clientId: 'YOUR_CLIENT_ID',
secret: 'YOUR_CLIENT_SECRET',
});
Frontend
const wealthica = Wealthica.init({
clientId: 'YOUR_CLIENT_ID',
// optional parameters for authenticating the Wealthica frontend instance with your server.
// See Authentication section for a more detailed explanation.
authEndpoint: '/wealthica/auth', // default value, need to accept POST
auth: {
params: { userId: 'LOGGED_IN_USER_ID' }, // custom params for authEndpoint
headers: {}, // custom headers for authEndpoint
},
});
Log in a user
to create a user instance if you want to request user data.
Backend
const user = wealthica.login('USERNAME');
Frontend
// No need to pass username because it's assumed that the `authEndpoint`
// implementation on your backend server should already know that from
// your authenticated user.
const user = wealthica.login();
3. Connect a user, or request for data
Start the Connect process for users to connect their financial institution accounts, or call the SDK helper methods to request data.
Backend
// Get general Wealthica data
const providers = await wealthica.providers.getList();
// Get user data via the `user` instance
const institution = await user.institutions.getOne('INSTITUTION_ID');
Frontend
// Get general Wealthica data
const providers = await wealthica.providers.getList();
// Start the Connect process when user clicks the Connect button
document.getElementById('#connect').addEventListener('click', () => {
user.connect().onConnection(async (institutionId, data) => {
console.log('provider', data.provider);
const institution = await user.institutions.getOne(institutionId);
displayAccount(institution);
});
}, false);