@gem.co/api
Node.js client library for the Gem API.
Last updated 9 days ago by jasongem .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @gem.co/api 
SYNC missed versions from official npm registry.

Gem API Node.js Client

Node.js client library for the Gem API.

Install

npm install @gem.co/api

Quickstart

const { GEM_API_KEY, GEM_API_SECRET } = process.env;
const { Gem, Models, Enums } = require('@gem.co/api').SDK;
const { Profile, Document, PlaidAccount, Transaction } = Models;
const { NewAccountTypes } = Enums;
const BLOCKCHAIN_ADDRESS = 'mybitcoinaddress';

const fs = require('fs');
const passportFile = fs.createReadStream('/my/passport/file.png');

const gem = new Gem({
  apiKey: GEM_API_KEY,
  secretKey: GEM_API_SECRET,
  baseUrl: 'https://api.sandbox.gem.co',
});

const userProfile = new Profile({
  name: { given_names: 'My First Name', family_names: 'My Last Name' },
  phone_number: '+11234567890',
  address: {
    street_1: '1123 Flower st.',
    street_2: 'APT 123',
    city: 'Los Angeles',
    postal_code: '90024',
    country: 'US',
    state: 'CA',
  },
  email_address: 'someone@example.com',
  social_security_number: '123-45-0976',
  date_of_birth: '11-20-1976',
});

const profileDocument = new Document({
  type: 'passport',
  description: 'My passport',
  files: [
    {
      data: passportFile,
      media_type: 'image/png',
      description: 'the file description',
      orientation: 'front',
    },
  ],
});

(async () => {
  try {
    const user = await gem.createUser();
    const profile = await gem.createProfile(user.id, userProfile);
    await gem.createProfileDocument(profile.id, profileDocument);
    const institutionUser = await gem.createInstitutionUser(profile.id, 'wyre');

    const plaidAccount = new PlaidAccount({
      connection_id: institutionUser.connection_id,
      type: NewAccountTypes.PlaidAccount,
      plaid_token: 'a-wyre-plaid-public-token',
    });

    const account = await gem.createAccount(plaidAccount);

    // Create a transaction, assuming the third party has approved this account.
    const txn = await gem.createTransaction(
      new Transaction({
        source_id: account.id,
        source_amount: 100.0,
        blockchain_address: {
          address: BLOCKCHAIN_ADDRESS,
          asset_id: 'bitcoin',
        },
        type: 'buy',
        preview: false,
      })
    );

    console.log(txn);
  } catch (e) {
    console.error(e);
  }
})();

Client API Reference

Constructor

const gem = new Gem({
  /* Parameters */
});

Configuration Parameters:

parameter description
apiKey Gem API key for the respective environment.
secretKey Gem API secret for the respective environment.
baseUrl The Gem API base URL you want to use.
https://api.gem.co for production
https://api.sandbox.gem.co for sandbox.
options Configuration options that are passed to the Axios Client for each request made to the API.

SDK Requests

Users

method parameters description
createUser (emailAddress?: string) Create a user.
getUser (userId: string) Get a user by ID.
listUsers none List all users
deleteUser (userId: string) Delete a user by ID.

Profiles

method parameters description
createProfile ( userId: string, profile: ProfileModel ) Create a profile.
createTemporaryProfile ( userId: string, profile: ProfileModel ) Create a temporary profile. This profile will exist for up to one hour.
getProfile ( profileId: string ) Get a profile by ID.
listProfiles ( userId: string ) Get a list of profiles.
updateProfile ( userId: string, profile: ProfileModel ) Create a profile.
deleteProfile ( profileId: string ) Delete a profile by ID.

Documents

method parameters description
createProfileDocument ( profileId: string, document: string ) Attach a document to a profile. (Documents may have many files associated.)
listProfileDocuments ( profileId: string ) List all profile documents.
updateDocument ( profileId: string, document: string ) Update a document.
deleteDocument ( documentId: string ) Delete a document by ID.

Institutions

method parameters description
getInstitution ( institutionId: string ) Get an institution by ID.
listInstitutions none List all supported institutions.

Institution Users

method parameters description
createInstitutionUser ( profileId: string, institutionId: string ) Create an institution user.
getInstitutionUser ( institutionUserId: string ) Get an institution user by ID.
listInstitutionUser ( userId: string, profile_id: string ) Get an institution user by ID.
updateInstitutionUser ( institutionUserId: string, profileId: string ) Update an institution user.

Accounts

method parameters description
createAccount ( account: PlaidAccountModel ) Create an account.
getAccount ( accountId: string ) Get an account by ID
listAccounts ( connectionId: string, userId?: string ) Get a list of accounts.

Transactions

method parameters description
createTransaction ( transactionParams: TransactionModel ) Create a transaction.
confirmTransaction ( transactionId: string ) Confirm a transaction preview.
getTransaction ( transactionId: string ) Get a transaction by ID.
listTransactions ({ userId?: string, accountId?: string, beforeId?: string, afterId?: string, limit?: number }?: object) Get a list of transactions.

Credentials

method parameters description
createCredentials ( credentialParams: CredentialsModel ) Create a credentials object which can be used to link a user to a connection. No authentication is required.

Connections

method parameters description
createConnection ( userId: string, credentialId: string ) Create a connection which will link a credential object and a user.
getConnection ( connectionId: string ) Get a connection by ID.
listConnections ( userId: string ) Get a list of user connections.
updateConnection ( connectionId: string, credentialId: string ) Update a connection's credential_id.
deleteConnection ( connectionId: string ) Delete a connection by ID.

Assets

method parameters description
getAssets ( assetId: string, source?: string ) Get assets from a source. assetIds can be a comma seperated list.
listAssets ( category: 'cryptocurrency' or 'fiat' ) List all supported assets of a certain category.

Prices

method parameters description
getAssetPrice ( assetId: string, currencyId: string, source?: string ) Get an asset price in units of a requested currency.
listAssetPrices ( assetIds: string, currencyId: string, source?: string ) List asset prices in units of a requested currency.

Vanilla Requests

Each function makes a request to Gem's API and returns a promise in response.

gem.get(path, parameters, options);
gem.post(path, body, options);
gem.put(path, body, options);
gem.patch(path, body, options);
gem.delete(path, body, options);

Debugging

Setting the DEBUG environment variable will turn on Gem client debug logging.

  DEBUG=gem:* node bin/my_program

Current Tags

  • 1.13.0                                ...           dev (4 months ago)
  • 1.28.0                                ...           latest (9 days ago)

71 Versions

  • 1.28.0                                ...           9 days ago
  • 1.27.0                                ...           12 days ago
  • 1.26.0                                ...           12 days ago
  • 1.25.0                                ...           19 days ago
  • 1.25.0-beta.3                                ...           a month ago
  • 1.25.0-beta.2                                ...           a month ago
  • 1.25.0-beta.1                                ...           a month ago
  • 1.25.0-alpha.3                                ...           a month ago
  • 1.25.0-alpha.2                                ...           2 months ago
  • 1.25.0-alpha.1                                ...           2 months ago
  • 1.25.0-alpha                                ...           2 months ago
  • 1.24.0                                ...           2 months ago
  • 1.23.0                                ...           2 months ago
  • 1.22.0                                ...           2 months ago
  • 1.21.0                                ...           3 months ago
  • 1.20.1                                ...           3 months ago
  • 1.20.0                                ...           3 months ago
  • 1.19.0                                ...           3 months ago
  • 1.18.1                                ...           3 months ago
  • 1.18.0                                ...           4 months ago
  • 1.17.8                                ...           4 months ago
  • 1.17.7                                ...           4 months ago
  • 1.17.6                                ...           4 months ago
  • 1.17.5                                ...           4 months ago
  • 1.17.4                                ...           4 months ago
  • 1.17.3                                ...           4 months ago
  • 1.17.2                                ...           4 months ago
  • 1.17.1                                ...           4 months ago
  • 1.17.0                                ...           4 months ago
  • 1.16.0                                ...           4 months ago
  • 1.15.1                                ...           4 months ago
  • 1.15.0                                ...           4 months ago
  • 1.14.0                                ...           4 months ago
  • 1.13.0                                ...           4 months ago
  • 1.12.1                                ...           4 months ago
  • 1.12.0                                ...           4 months ago
  • 1.11.0                                ...           4 months ago
  • 1.10.1                                ...           4 months ago
  • 1.9.1                                ...           4 months ago
  • 1.9.0                                ...           4 months ago
  • 1.8.6                                ...           4 months ago
  • 1.8.5                                ...           4 months ago
  • 1.8.4                                ...           4 months ago
  • 1.8.3                                ...           4 months ago
  • 1.8.2                                ...           4 months ago
  • 1.8.1                                ...           4 months ago
  • 1.7.1                                ...           6 months ago
  • 1.7.0                                ...           6 months ago
  • 1.6.2                                ...           7 months ago
  • 1.6.1                                ...           7 months ago
  • 1.6.0                                ...           7 months ago
  • 1.5.0                                ...           7 months ago
  • 1.4.0                                ...           7 months ago
  • 1.3.3                                ...           7 months ago
  • 1.3.2                                ...           7 months ago
  • 1.3.1                                ...           7 months ago
  • 1.3.0                                ...           7 months ago
  • 1.2.4                                ...           8 months ago
  • 1.2.3                                ...           8 months ago
  • 1.2.2                                ...           8 months ago
  • 1.2.1                                ...           8 months ago
  • 1.2.0                                ...           8 months ago
  • 1.1.1                                ...           8 months ago
  • 1.1.0                                ...           8 months ago
  • 1.0.6                                ...           8 months ago
  • 1.0.5                                ...           8 months ago
  • 1.0.4                                ...           8 months ago
  • 1.0.3                                ...           8 months ago
  • 1.0.2                                ...           8 months ago
  • 1.0.1                                ...           8 months ago
  • 1.0.0                                ...           8 months ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 147
Dependencies (5)
Dev Dependencies (6)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |