@gem.co/api
    TypeScript icon, indicating that this package has built-in type declarations

    1.64.3 • Public • Published

    Official Gem API Node.js Client

    The official Node.js client for the Gem API.

    Install

    npm install @gem.co/api
    

    Quickstart

    Server

    // Set the SDK constants.
    const { GEM_API_KEY, GEM_API_SECRET } = process.env;
    const { Gem } = require('@gem.co/api').SDK;
    
    // Create client instance.
    const gem = new Gem({
      apiKey: GEM_API_KEY,
      secretKey: GEM_API_SECRET,
      baseUrl: 'https://api.sandbox.gem.co',
    });
    
    /**
     *
     * MAIN
     *
     **/
    
    (async () => {
      try {
        let transactions = [];
    
        const applicationUsers = await gem.listUsers();
        const firstUser = applicationUsers[0];
    
        if (firstUser) {
          transactions = await gem.listTransactions({ userId: firstUser.id });
        }
    
        console.log('User Transactions', transactions);
      } catch (e) {
        console.error('Gem Error', e);
      }
    })();

    Client API Reference

    Constructor

    const gem = new Gem({
      /* Configuration 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
    getUser (userId: string) Get a user by ID.
    listUsers (pageNumber?: number, pageSize?: number) List all users

    Institutions

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

    Transactions

    method parameters description
    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.

    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.

    Payment Methods + Supported Currencies

    method parameters description
    listSupportedCurrencies (institutionId: wyre or coinify) List payment methods for a particular institution and their supported currencies.

    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.

    const gem = new Gem({
      /* Configuration Parameters */
    });
    
    const client = gem.client;
    
    client.get(path, parameters, options);
    client.post(path, body, options);
    client.put(path, body, options);
    client.patch(path, body, options);
    client.delete(path, body, options);

    Debugging

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

      DEBUG=gem:* node bin/my_program

    Install

    npm i @gem.co/api

    DownloadsWeekly Downloads

    1,841

    Version

    1.64.3

    License

    MIT

    Unpacked Size

    104 kB

    Total Files

    31

    Last publish

    Collaborators

    • gemdev
    • chrisgem
    • micah-gem
    • rawad.rifai
    • jasongem