Skip to content

y2labs/wealthsimple-node

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Wealthsimple-node

Node.js client for Wealthsimple API: https://developers.wealthsimple.com

This is still under development and therefore currently only supports sandbox.

Installation

npm install --save https://github.com/anthfran/wealthsimple-node

Example of Usage

const credentials = {
  "client_id": "XXXXXXXXX",
  "client_secret": "XXXXXXXXX",
  "redirect_uri": "https://localhost:3000/auth"
};
const Wealthsimple = require('wealthsimple-node').appId(credentials);

wealthsimple.tokenExchange(authCode)
.then(tokens => {
  return Wealthsimple.listAccounts(tokens.access_token)
})
.then(accountResponse => {
  console.log(accountResponse);
  // do something with response
})
.catch(error => {
  // do something with error
});

Table of Contents

tokenExchange

Exchanges an auth code for OAuth2 tokens

Parameters

  • code String Auth string from Wealthsimple redirect

Examples

wealthsimple.tokenExchange(authCode).then(response=>console.log(response));

Returns Promise Fetch promise which will resolve containing OAuth2 Tokens

tokenRefresh

Refreshes OAuth2 tokens

Parameters

  • refreshToken String Refresh Token

Examples

wealthsimple.tokenRefresh(refreshToken).then(response=>console.log(response));

Returns Promise Fetch promise which will resolve containing OAuth2 Tokens

createUser

Create a User https://developers.wealthsimple.com/#operation/Create%20User

Parameters

Examples

wealthsimple.createUser(body).then(response=>console.log(response));

Returns Promise Fetch promise which will resolve with newly created user

listUsers

List Users https://developers.wealthsimple.com/#operation/List%20Users This API will return a list of Users scoped by the authorization credentials.

Parameters

  • token String OAuth token for a user
  • params Object? See Wealthsimple website for an example of the request parameters

Examples

wealthsimple.listUsers(token).then(response=>console.log(response));
let params = { limit: 25, offset: 50, created_before: "2017-06-21"};
wealthsimple.listUsers(token, params).then(response=>console.log(response));

Returns Promise Fetch promise which will resolve with newly created user

getUser

Get User https://developers.wealthsimple.com/#operation/Get%20User

Parameters

  • token String OAuth token for a user
  • userId String Example "user-12398ud"

Examples

wealthsimple.getUser(token, userId).then(response=>console.log(response));

Returns Promise Fetch promise which will resolve with user info

createPerson

Create Person https://developers.wealthsimple.com/#operation/Create%20Person

Parameters

  • token String OAuth token for a user
  • body Object See Wealthsimple website for an example of the request body

Examples

wealthsimple.createPerson(token, body).then(response=>console.log(response));

Returns Promise Fetch promise which will resolve with the created Person

listPeople

List People https://developers.wealthsimple.com/#operation/List%20People This API will return a list of People scoped by the authorization credentials.

Parameters

  • token String OAuth token for a user
  • params Object See Wealthsimple website for an example of the request parameters

Examples

wealthsimple.createPerson(token, body).then(response=>console.log(response));

Returns Promise Fetch promise which will resolve with the list of people

getPerson

Get Person https://developers.wealthsimple.com/#operation/Get%20Person Get a Person entity if you know the person_id and the current credentials have access to the Person.

Parameters

  • token String OAuth token for a user
  • personId String Example "person-12398ud"

Examples

wealthsimple.getPerson(token, "person-12398ud").then(response=>console.log(response));

Returns Promise Fetch promise which will resolve with the Person details

updatePerson

Update Person https://developers.wealthsimple.com/#operation/Update%20Person You can add/remove information to the Person entity as the information becomes available using this API. To remove a previously set attribute, set the value to null. Attributes that are not mentioned in the request payload will leave the attribute unchanged in the Person entity.

Parameters

  • token String OAuth token for a user
  • personId String Example "person-12398ud"
  • body Object See Wealthsimple website for an example of the body

Examples

wealthsimple.updatePerson(token, "person-12398ud", body).then(response=>console.log(response));

Returns Promise Fetch promise which will resolve with the updated Person

createAccount

Create Account https://developers.wealthsimple.com/#operation/Create%20Account You can add/remove information to the Person entity as the information becomes available using this API. To remove a previously set attribute, set the value to null. Attributes that are not mentioned in the request payload will leave the attribute unchanged in the Person entity.

Parameters

  • token String OAuth token for a user
  • personId String Example "person-12398ud"
  • body Object See Wealthsimple website for an example of the body

Examples

wealthsimple.createAccount(token, body).then(response=>console.log(response));

Returns Promise Fetch promise which will resolve with the created Account

listAccounts

List Accounts https://developers.wealthsimple.com/#operation/List%20Accounts

Parameters

  • token String OAuth token for a user
  • params Object? Optional filter params, See Wealthsimple website for an example of the request parameters

Examples

wealthsimple.listAccounts(token).then(response=>console.log(response));
wealthsimple.listAccounts(token,params).then(response=>console.log(response));

Returns Promise Fetch promise which will resolve with the list of accounts

getAccount

Get Account https://developers.wealthsimple.com/#operation/Get%20Account

Parameters

  • token String OAuth token for a user
  • accountId String Account ID String

Examples

wealthsimple.listAccounts(token).then(response=>console.log(response));
wealthsimple.getAccount(token,accountId).then(response=>console.log(response));

Returns Promise Fetch promise which will resolve with the account details

getAccountTypes

Get Account Types https://developers.wealthsimple.com/#operation/Get%20Account%20Types Returns openable account types. If a client_id is provided it will scope the types to the client in question, otherwise it will default to the requestor

Parameters

  • token String OAuth token for a user
  • params Object? Optional filter params, See Wealthsimple website for an example of the request parameters

Examples

wealthsimple.getAccountTypes(token).then(response=>console.log(response));
wealthsimple.getAccountTypes(token,params).then(response=>console.log(response));

Returns Promise Fetch promise which will resolve with the account details

getDailyValues

Get Daily Values https://developers.wealthsimple.com/#operation/List%20Daily%20Values Returns historical daily values for a given account. This API will only return a maximum of 365 days worth of daily values from a given start date. By default, it will return historical values for the last 30-days. The start date must occur before the end date if provided. If the difference between the start date and the end date exceeds 365 days, an error will be thrown. The number of Daily Values can be potentially prohibitively large, the results are paginated.

Parameters

  • token String OAuth token for a user
  • params Object? Optional filter params, See Wealthsimple website for an example of the request parameters
    • params.accound_id Object Required account_id param

Examples

wealthsimple.getDailyValues(token,{ params.accound_id: "rrsp-r3e9c1w" }).then(response=>console.log(response));

Returns Promise Fetch promise which will resolve with the account daily values

listPositions

List Positions https://developers.wealthsimple.com/#tag/Positions Returns positions for a given account. This API will also allow you to retrieve historical Positions held on a given date.

Parameters

  • token String OAuth token for a user
  • params Object? Optional filter params, See Wealthsimple website for an example of the request parameters
    • params.accound_id Object Required account_id param

Examples

wealthsimple.listPositions(token,{ params.accound_id: "rrsp-r3e9c1w" }).then(response=>console.log(response));

Returns Promise Fetch promise which will resolve with the account positions

listTransactions

List Transactions https://developers.wealthsimple.com/#operation/List%20Transactions Lists all Transactions. The number of Transactions can be potentially prohibitively large, the results are paginated. By default, the API will return the 250 latest transactions in the last 30 days.

Parameters

  • token String OAuth token for a user
  • params Object? Optional filter params, See Wealthsimple website for an example of the request parameters
    • params.accound_id Object Required account_id param

Examples

wealthsimple.listTransactions(token,{ params.accound_id: "rrsp-r3e9c1w" }).then(response=>console.log(response));

Returns Promise Fetch promise which will resolve with the account transactions

getProjection

Get Projection https://developers.wealthsimple.com/#operation/Get%20Projection Retrieves a projections of returns for an account based on deposits and frequency.

Parameters

  • token String OAuth token for a user
  • params Object Projection params
    • params.accound_id Object Required account_id param
    • params.amount Object Required deposit amount
    • params.frequency Object Required deposit frequency
    • params.start_date Object Required deposit start date

Examples

wealthsimple.getProjection(token, params).then(response=>console.log(response));

Returns Promise Fetch promise which will resolve with the projection

listBankAccounts

List Bank Accounts https://developers.wealthsimple.com/#operation/List%20Bank%20Accounts

Parameters

  • token String OAuth token for a user
  • params Object? See website for optional query params

Examples

wealthsimple.listBankAccounts(token, params).then(response=>console.log(response));

Returns Promise Fetch promise which will resolve with list of bank accounts

createDeposit

Create Deposit https://developers.wealthsimple.com/#operation/Create%20Deposit Initiates an electronic funds transfer to deposit funds to an Account from a Bank Account

Parameters

  • token String OAuth token for a user
  • body Object Required deposit details
    • body.bank_account_id Object The unique id of the Bank Account
    • body.account_id Object The unique id of the Account
    • body.amount Object Dollar amount
    • body.currency Object Currency

Examples

wealthsimple.createDeposit(token, body).then(response=>console.log(response));

Returns Promise Fetch promise which will resolve with deposit info

listDeposits

List Deposits https://developers.wealthsimple.com/#operation/List%20Deposits

Parameters

  • token String OAuth token for a user
  • params Object? See website for optional query params

Examples

wealthsimple.listDeposits(token, body).then(response=>console.log(response));

Returns Promise Fetch promise which will resolve with deposit list

getDeposit

Get Deposit https://developers.wealthsimple.com/#operation/List%20Deposits

Parameters

  • token String OAuth token for a user
  • fundsTransferId String funds_transfer_id

Examples

let fundsTransferId = "funds_transfer_id-r3e9c1w";
wealthsimple.getDeposit(token, fundsTransferId).then(response=>console.log(response));

Returns Promise Fetch promise which will resolve with a deposit entity.

About

Wealthsimple API integration for Node

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%