wealthica-sdk-js 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,14 +1,8 @@
1
1
  # Official Wealthica JS SDK for the Browser & NodeJS
2
2
 
3
- [![Build Status](https://semaphoreci.com/api/v1/wealthica/wealthica-sdk-js/branches/master/badge.svg)](https://semaphoreci.com/wealthica/wealthica-sdk-js)
3
+ ## What is Wealthica Connect?
4
4
 
5
- ## What is Wealthica? A Unified Cryptocurrency API.
6
-
7
- > *“We tried a few crypto data APIs to retrieve our users digital assets, Wealthica is the only one that actually works!”* — Wealth Tracking Dashboard Dev
8
-
9
- [Wealthica](https://wealthica.com/) is an API for connecting with cryptocurrency exchanges, wallets and protocols like Bitcoin. Instead of manually integrating with [Crypto Exchange APIs](https://wealthica.com/status/) like [Coinbase API](https://wealthica.com/), [Binance API](https://wealthica.com/), [Bitcoin APIs](https://wealthica.com/), [Crypto APIs](https://wealthica.com/) or the hundreds of other cryptocurrency APIs - you can simply use Wealthica for them all.
10
-
11
- Wealthica is the **#1** alternative to the discontinued [Zabo API](https://wealthica.com/).
5
+ [Wealthica](https://wealthica.com/) is an API for connecting with Canadian financial bands and brokerages platforms.
12
6
 
13
7
  We believe teams and developers should focus on building great products, not worry about the fragmented landscape of exchange APIs and blockchain protocols.
14
8
 
@@ -55,7 +49,7 @@ import Wealthica from 'wealthica-sdk-js';
55
49
  });
56
50
 
57
51
  // Call the user-specific API methods
58
- const account = await user.institutions.getOne('ACCOUNT_ID');
52
+ const institution = await user.institutions.getOne('INSTITUTION_ID');
59
53
  })();
60
54
  ```
61
55
 
@@ -85,8 +79,8 @@ const user1 = wealthica.login('USER_ID_1');
85
79
  const user2 = wealthica.login('USER_ID_2');
86
80
 
87
81
  // Call user APIs
88
- const user1Account = await user1.institutions.getOne('ACCOUNT_ID_1');
89
- const user2Account = await user2.institutions.getOne('ACCOUNT_ID_2');
82
+ const user1Institution = await user1.institutions.getOne('INSTITUTION_ID_1');
83
+ const user2Institution = await user2.institutions.getOne('INSTITUTION_ID_2');
90
84
  ```
91
85
 
92
86
  ##### From client (browser/ReactNative)
@@ -119,7 +113,7 @@ const wealthica = Wealthica.init({
119
113
  const user = wealthica.login();
120
114
 
121
115
  // Call user APIs
122
- const account = await user.institutions.getOne('ACCOUNT_ID_1');
116
+ const institution = await user.institutions.getOne('INSTITUTION_ID_1');
123
117
  ```
124
118
 
125
119
  Example server implementation for `authEndpoint`:
@@ -173,7 +167,7 @@ token = await user.getToken({ minimumLifeTime: 600 }); // fetches and returns an
173
167
 
174
168
  #### user.getConnectData({ provider, redirectURI, state, lang, theme, providersPerLine })
175
169
 
176
- This method returns a Wealthica Connect URL and authentication token for user to connect an account.
170
+ This method returns a Wealthica Connect URL and authentication token for user to connect an institution.
177
171
 
178
172
  Wealthica Connect URL must be called via POST method and pass token in the form data.
179
173
 
@@ -188,8 +182,8 @@ const { url, token } = await user.getConnectData({
188
182
  // required for Wealthica Connect drop-in widget, but already handled by the SDK when calling
189
183
  // `user.connect()` (defaults to `window.location.origin`).
190
184
  // https://wealthica.com/docs/#connect-url-parameters
191
- accountId: 'ACCOUNT_ID',
192
- // Pass accountId to re-connect an existing account that has expired/revoked credentials
185
+ institutionId: 'INSTITUTION_ID',
186
+ // Pass institutionId to re-connect an existing institution that has expired/revoked credentials
193
187
  origin: 'YOUR_SITE_ORIGIN',
194
188
  state: 'YOUR_APP_STATE', // optional
195
189
  lang: 'en', // optional (en | es | fr | it), 'en' by default
@@ -233,39 +227,39 @@ const user2 = wealthica.login('USER_ID_2');
233
227
  const { url: url2, token } = await user2.getConnectData();
234
228
  ```
235
229
 
236
- #### user.connect({ provider, providers, accountId, lang, theme, providersPerLine, features })
230
+ #### user.connect({ provider, providers, institutionId, lang, theme, providersPerLine, features })
237
231
 
238
- This method starts the Wealthica Connect process inside your webpage/app for user to connect their account.
232
+ This method starts the Wealthica Connect process inside your webpage/app for user to connect their institution.
239
233
 
240
234
  Connection response are provided via callbacks.
241
235
 
242
236
  This method accepts the same parameters as `user.getConnectData()` except for `redirectURI`, `origin` and `state`
243
237
 
244
238
  ```javascript
245
- user.connect().onConnection(account => {
246
- // Send the account to your server
247
- sendToServer('/some-route', account);
239
+ user.connect().onConnection(institution => {
240
+ // Send the institution to your server
241
+ sendToServer('/some-route', institution);
248
242
  }).onError(error => {
249
- console.error('account connection error:', error)
243
+ console.error('institution connection error:', error)
250
244
  }).onEvent((name, data) => {
251
- console.log('account connection event:', name, data);
245
+ console.log('institution connection event:', name, data);
252
246
  });
253
247
  ```
254
248
 
255
- #### user.reconnect(accountId)
249
+ #### user.reconnect(institutionId)
256
250
 
257
- This method starts the Wealthica Connect process to re-connect an existing account that has expired/revoked credentials.
251
+ This method starts the Wealthica Connect process to re-connect an existing institution that has expired/revoked credentials.
258
252
 
259
253
  Connection response are provided via callbacks.
260
254
 
261
255
  ```javascript
262
- user.reconnect('ACCOUNT_ID').onConnection(account => {
263
- // Send the account to your server
264
- sendToServer('/some-route', account);
256
+ user.reconnect('INSTITUTION_ID').onConnection(institution => {
257
+ // Send the institution to your server
258
+ sendToServer('/some-route', institution);
265
259
  }).onError(error => {
266
- console.error('account connection error:', error)
260
+ console.error('institution connection error:', error)
267
261
  }).onEvent((name, data) => {
268
- console.log('account connection event:', name, data);
262
+ console.log('institution connection event:', name, data);
269
263
  });
270
264
  ```
271
265
 
@@ -281,273 +275,97 @@ This method retrieves the list of institutions for a user.
281
275
  const institutions = await user.institutions.getList();
282
276
  ```
283
277
 
278
+ todo: add response example
284
279
  ```json
285
- [
286
- {
287
- "id": "603522490d2b02001233a5d6",
288
- "provider": {
289
- "name": "coinbase",
290
- "display_name": "Coinbase",
291
- "logo": "https://app.wealthica.com/images/institutions/coinbase.png",
292
- "type": "oauth",
293
- "scopes": [],
294
- "resource_type": "provider"
295
- },
296
- "balances": [
297
- {
298
- "ticker": "BTC",
299
- "provider_ticker": "BTC",
300
- "name": "Bitcoin",
301
- "asset_is_verified": null,
302
- "asset_type": "",
303
- "amount": "0.20210831",
304
- "decimals": 8,
305
- "fiat_ticker": "USD",
306
- "fiat_value": "2021.08",
307
- "fiat_asset_is_verified": null,
308
- "logo": "https://data.wealthica.com/api/securities/CRYPTO:BTC/logo",
309
- "updated_at": 1630412605283,
310
- "misc": null,
311
- "resource_type": "balance"
312
- }
313
- ],
314
- "blockchain": null,
315
- "created_at": 1630412605283,
316
- "updated_at": 1630412605283,
317
- "resource_type": "account",
318
- },
319
- {
320
- "id": "603522490d2b02001233a5d7",
321
- "provider": {
322
- "name": "bitcoin",
323
- "display_name": "Bitcoin Address",
324
- "logo": "https://app.wealthica.com/images/institutions/bitcoin.png",
325
- "type": "wallet",
326
- "scopes": [],
327
- "resource_type": "provider"
328
- },
329
- "balances": [],
330
- "blockchain": null,
331
- "created_at": 1630412605283,
332
- "updated_at": 1630412605283,
333
- "resource_type": "account",
334
- }
335
- ]
280
+
336
281
  ```
337
282
 
338
283
  #### user.institutions.getOne(id)
339
284
 
340
- This method retrieves a single account.
285
+ This method retrieves a single institution.
341
286
 
342
287
  ```javascript
343
- const account = await user.institutions.getOne('603522490d2b02001233a5d6');
288
+ const institution = await user.institutions.getOne('603522490d2b02001233a5d6');
344
289
  ```
345
290
 
291
+ todo: add response example
346
292
  ```json
347
- {
348
- "id": "603522490d2b02001233a5d6",
349
- "provider": {
350
- "name": "coinbase",
351
- "display_name": "Coinbase",
352
- "logo": "https://app.wealthica.com/images/institutions/coinbase.png",
353
- "type": "oauth",
354
- "scopes": [],
355
- "resource_type": "provider"
356
- },
357
- "balances": [
358
- {
359
- "ticker": "BTC",
360
- "provider_ticker": "BTC",
361
- "name": "Bitcoin",
362
- "asset_is_verified": null,
363
- "asset_type": "",
364
- "amount": "0.20210831",
365
- "decimals": 8,
366
- "fiat_ticker": "USD",
367
- "fiat_value": "2021.08",
368
- "fiat_asset_is_verified": null,
369
- "logo": "https://data.wealthica.com/api/securities/CRYPTO:BTC/logo",
370
- "updated_at": 1630412605283,
371
- "misc": null,
372
- "resource_type": "balance"
373
- }
374
- ],
375
- "blockchain": null,
376
- "created_at": 1630412605283,
377
- "updated_at": 1630412605283,
378
- "resource_type": "account",
379
- }
293
+
380
294
  ```
381
295
 
382
296
  #### user.institutions.sync(id)
383
297
 
384
- This method triggers an account sync.
298
+ This method triggers an institution sync.
385
299
 
386
300
  ```javascript
387
- const account = await user.institutions.sync('603522490d2b02001233a5d6');
301
+ const institution = await user.institutions.sync('603522490d2b02001233a5d6');
388
302
  ```
389
303
 
390
304
  #### user.institutions.remove(id)
391
305
 
392
- This method removes a single account from the user.
306
+ This method removes a single institution from the user.
393
307
 
394
308
  ```javascript
395
309
  await user.institutions.remove('603522490d2b02001233a5d6');
396
310
  ```
397
311
 
398
- #### user.history.getList({ accountId, from, to, wallet })
312
+ #### user.history.getList({ institutionId, from, to, investments })
399
313
 
400
- This method retrieves the balance history for an account.
314
+ This method retrieves the balance history for an institution.
401
315
 
402
316
  Returns data within the last 1 year by default.
403
317
 
404
318
  ```javascript
405
319
  const history = await user.history.getList({
406
- accountId: '603522490d2b02001233a5d6',
320
+ institutionId: '603522490d2b02001233a5d6',
407
321
  from: '2021-01-01',
408
322
  to: '2021-09-09',
409
- wallet: 'bitcoin:cash:usd',
323
+ investment: 'bitcoin:cash:usd',
410
324
  });
411
325
  ```
412
326
 
327
+ todo: add response example
413
328
  ```json
414
- [
415
- {
416
- "id": "6144755af8a77cae7174afa3",
417
- "date": 1630412605283,
418
- "wallet": "demo:cash:usd",
419
- "fiat_ticker": "USD",
420
- "fiat_value": "125.30"
421
- },
422
- {
423
- "id": "6144755af8a77cae7174afa4",
424
- "date": 1630412605283,
425
- "wallet": "demo:cash:cad",
426
- "fiat_ticker": "USD",
427
- "fiat_value": "125.30"
428
- },
429
- ]
329
+
430
330
  ```
431
331
 
432
- #### user.transactions.getList({ accountId, ticker, from, to, wallet, last, limit })
332
+ #### user.transactions.getList({ institutionId, ticker, from, to, investments, last, limit })
433
333
 
434
- This method retrieves the list of transactions for an account.
334
+ This method retrieves the list of transactions for an institution.
435
335
 
436
336
  Returns data within the last 1 year by default.
437
337
 
438
338
  ```javascript
439
339
  const transactions = await user.transactions.getList({
440
- accountId: '603522490d2b02001233a5d6',
340
+ institutionId: '603522490d2b02001233a5d6',
441
341
  ticker: 'BTC', // optional
442
342
  from: '2020-08-31', // optional
443
343
  to: '2021-08-31', // optional
444
- wallet: 'bitcoin:cash:usd', // optional
344
+ investment: 'bitcoin:cash:usd', // optional
445
345
  last: '603522490d2b02001233a5d6', // optional, blank string is allowed
446
346
  limit: 10, // optional
447
347
  });
448
348
  ```
449
349
 
350
+ todo: add response example
450
351
  ```json
451
- [
452
- {
453
- "id": "603522490d2b02001233a5d6",
454
- "status": null,
455
- "transaction_type": "deposit",
456
- "parts": [
457
- {
458
- "direction": "received",
459
- "ticker": "BTC",
460
- "provider_ticker": "BTC",
461
- "amount": "1.20210831",
462
- "asset_is_verified": null,
463
- "fiat_ticker": "USD",
464
- "fiat_value": "1234567.8",
465
- "fiat_asset_is_verified": null,
466
- "other_parties": []
467
- }
468
- ],
469
- "fees": [
470
- {
471
- "type": null,
472
- "ticker": "USD",
473
- "provider_ticker": "USD",
474
- "amount": "0.5",
475
- "asset_is_verified": null,
476
- "fiat_ticker": "",
477
- "fiat_value": "",
478
- "fiat_asset_is_verified": null,
479
- "resource_type": "transaction_fee"
480
- }
481
- ],
482
- "misc": [],
483
- "fiat_calculated_at": 1630412605283,
484
- "initiated_at": 1630412605283,
485
- "confirmed_at": 1630412605283,
486
- "resource_type": "transaction"
487
- },
488
- {
489
- "id": "603522490d2b02001233a5d7",
490
- "status": null,
491
- "transaction_type": "deposit",
492
- "parts": [],
493
- "fees": [],
494
- "misc": [],
495
- "fiat_calculated_at": 1630412605283,
496
- "initiated_at": 1630412605283,
497
- "confirmed_at": 1630412605283,
498
- "resource_type": "transaction"
499
- }
500
- ]
352
+
501
353
  ```
502
354
 
503
- #### user.transactions.getOne({ accountId, txId })
355
+ #### user.transactions.getOne({ institutionId, txId })
504
356
 
505
357
  This method retrieves a single transaction.
506
358
 
507
359
  ```javascript
508
360
  const transaction = await user.transactions.getOne({
509
- accountId: '603522490d2b02001233a5d6',
361
+ institutionId: '603522490d2b02001233a5d6',
510
362
  txId: '603522490d2b02001233a5d6'
511
363
  });
512
364
  ```
513
365
 
366
+ todo: add response example
514
367
  ```json
515
- {
516
- "id": "603522490d2b02001233a5d6",
517
- "status": null,
518
- "transaction_type": "deposit",
519
- "parts": [
520
- {
521
- "direction": "received",
522
- "ticker": "BTC",
523
- "provider_ticker": "BTC",
524
- "amount": "1.20210831",
525
- "asset_is_verified": null,
526
- "fiat_ticker": "USD",
527
- "fiat_value": "1234567.8",
528
- "fiat_asset_is_verified": null,
529
- "other_parties": []
530
- }
531
- ],
532
- "fees": [
533
- {
534
- "type": null,
535
- "ticker": "USD",
536
- "provider_ticker": "USD",
537
- "amount": "0.5",
538
- "asset_is_verified": null,
539
- "fiat_ticker": "",
540
- "fiat_value": "",
541
- "fiat_asset_is_verified": null,
542
- "resource_type": "transaction_fee"
543
- }
544
- ],
545
- "misc": [],
546
- "fiat_calculated_at": 1630412605283,
547
- "initiated_at": 1630412605283,
548
- "confirmed_at": 1630412605283,
549
- "resource_type": "transaction"
550
- }
368
+
551
369
  ```
552
370
 
553
371
  ### Data APIs
@@ -571,35 +389,9 @@ This method retrieves the list of Wealthica supported providers.
571
389
  const providers = await wealthica.providers.getList();
572
390
  ```
573
391
 
392
+ todo: add response example
574
393
  ```json
575
- [
576
- {
577
- "name": "coinbase",
578
- "display_name": "Coinbase",
579
- "logo": "https://app.wealthica.com/images/institutions/coinbase.png",
580
- "auth_type": "oauth",
581
- "available_scopes": [],
582
- "available_currencies": null,
583
- "resource_type": "provider",
584
- "status": null,
585
- "is_beta": true,
586
- "connect_notice": "",
587
- "credentials": ["code"]
588
- },
589
- {
590
- "name": "bitcoin",
591
- "display_name": "Bitcoin Address",
592
- "logo": "https://app.wealthica.com/images/institutions/bitcoin.png",
593
- "auth_type": "wallet",
594
- "available_scopes": [],
595
- "available_currencies": null,
596
- "resource_type": "provider",
597
- "status": null,
598
- "is_beta": true,
599
- "connect_notice": "",
600
- "credentials": ["wallet"]
601
- }
602
- ]
394
+
603
395
  ```
604
396
 
605
397
  #### wealthica.providers.getOne(id)
@@ -610,20 +402,9 @@ This method retrieves a single provider.
610
402
  const provider = await wealthica.providers.getOne('coinbase');
611
403
  ```
612
404
 
405
+ todo: add response example
613
406
  ```json
614
- {
615
- "name": "coinbase",
616
- "display_name": "Coinbase",
617
- "logo": "https://app.wealthica.com/images/institutions/coinbase.png",
618
- "auth_type": "oauth",
619
- "available_scopes": [],
620
- "available_currencies": null,
621
- "resource_type": "provider",
622
- "status": null,
623
- "is_beta": true,
624
- "connect_notice": "",
625
- "credentials": ["code"]
626
- }
407
+
627
408
  ```
628
409
 
629
410
  ## Development
@@ -17,7 +17,7 @@ interface APIInterface {
17
17
  getTeam(): string;
18
18
  getConnectData(options: ConnectDataOptions): Promise<ConnectData>
19
19
  connect(options?: APIConfig): APIInterface
20
- reconnect(accountId: string): APIUserInterface
20
+ reconnect(institutionId: string): APIUserInterface
21
21
  onConnection(callback: Function): APIInterface
22
22
  onError(callback: Function): APIInterface
23
23
  onEvent(callback: Function): APIInterface
@@ -45,9 +45,9 @@ interface APIUserInterface extends APIInterface {
45
45
 
46
46
  interface InstitutionsInterface {
47
47
  constructor(api: APIUserInterface)
48
- getList(): Promise<Account[]> | Promise<never>
49
- getOne(id: string, params?: {}): Promise<Account> | Promise<never>
50
- sync(id): Promise<Account> | Promise<never>
48
+ getList(): Promise<Institution[]> | Promise<never>
49
+ getOne(id: string, params?: {}): Promise<Institution> | Promise<never>
50
+ sync(id): Promise<Institution> | Promise<never>
51
51
  remove(id): Promise<void> | Promise<never>
52
52
  }
53
53
 
@@ -82,7 +82,7 @@ type TokenOptions = {
82
82
 
83
83
  type ConnectDataOptions = {
84
84
  provider: string;
85
- accountId: string;
85
+ institutionId: string;
86
86
  state: string;
87
87
  origin: string | undefined;
88
88
  lang: string;
@@ -96,16 +96,16 @@ type ConnectData = {
96
96
  }
97
97
 
98
98
  type TransactionsOptions = {
99
- accountId: string;
99
+ institutionId: string;
100
100
  from?: string;
101
101
  to?: string;
102
- wallet?: string;
102
+ investments?: string;
103
103
  last?: string;
104
104
  limit?: number;
105
105
  }
106
106
 
107
107
  type TransactionOptions = {
108
- accountId: string;
108
+ institutionId: string;
109
109
  txId: string;
110
110
  }
111
111
 
@@ -115,8 +115,6 @@ type Part = {
115
115
  provider_ticker: string;
116
116
  amount: string;
117
117
  asset_is_verified?: boolean | null;
118
- fiat_ticker: string;
119
- fiat_value: string;
120
118
  fiat_asset_is_verified?: boolean | null;
121
119
  other_parties: any[];
122
120
  }
@@ -127,8 +125,6 @@ type Fee = {
127
125
  provider_ticker: string;
128
126
  amount: string;
129
127
  asset_is_verified?: boolean | null;
130
- fiat_ticker: string;
131
- fiat_value: string;
132
128
  fiat_asset_is_verified?: boolean | null;
133
129
  resource_type: string;
134
130
  }
@@ -147,18 +143,16 @@ type Transactions = {
147
143
  }
148
144
 
149
145
  type HistoryListOptions = {
150
- accountId: string;
146
+ institutionId: string;
151
147
  from?: string;
152
148
  to?: string;
153
- wallet?: string;
149
+ investments?: string;
154
150
  }
155
151
 
156
152
  type BalanceHistory = {
157
153
  id: string;
158
154
  date: number;
159
- wallet: string;
160
- fiat_ticker: string;
161
- fiat_value: string;
155
+ investment: string;
162
156
  }
163
157
 
164
158
  type Provider = {
@@ -175,7 +169,7 @@ type Provider = {
175
169
  credentials: string[];
176
170
  }
177
171
 
178
- type AccountProvider = {
172
+ type InstitutionProvider = {
179
173
  name: string;
180
174
  display_name: string;
181
175
  logo: string;
@@ -192,8 +186,6 @@ type Balance = {
192
186
  asset_type: string;
193
187
  amount: string;
194
188
  decimals: number;
195
- fiat_ticker: string;
196
- fiat_value: string;
197
189
  fiat_asset_is_verified?: any;
198
190
  logo: string;
199
191
  updated_at: number;
@@ -201,9 +193,9 @@ type Balance = {
201
193
  resource_type: string;
202
194
  }
203
195
 
204
- type Account = {
196
+ type Institution = {
205
197
  id: string;
206
- provider: AccountProvider;
198
+ provider: InstitutionProvider;
207
199
  balances: Balance[];
208
200
  blockchain?: any;
209
201
  created_at: number;