Official Gem API Node.js Client
The official Node.js client for the Gem API .
// 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 ,
environment : 'sandbox' ,
} ) ;
/**
*
* MAIN
*
**/
( async ( ) => {
try {
const applicationUsers = await gem . listUsers ( ) ;
const firstUser = applicationUsers [ 0 ] ;
const transactions = await gem . listTransactions ( { userId : firstUser . id } ) ;
console . log ( 'User Transactions' , transactions ) ;
} catch ( e ) {
console . error ( 'Gem Error' , e ) ;
}
} ) ( ) ;
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.
environment
The Gem API environment. Options: sandbox or production .
options
Configuration options that are passed to the Axios Client for each request made to the API.
method
parameters
description
getUser
(userId: string)
Get a user by ID.
listUsers
(pageNumber?: number, pageSize?: number)
List all users
method
parameters
description
createProfile
( userId: string, profile: ProfileModel )
Create a profile.
method
parameters
description
createProfileDocument
( profileId: string, document: FormData )
Attach a document to a profile. (Documents may have many files associated.)
method
parameters
description
getInstitution
( institutionId: string )
Get an institution by ID.
listInstitutions
none
List all supported institutions.
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.
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.
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.
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 ) ;
Setting the DEBUG environment variable will turn on Gem client debug logging.
DEBUG=gem:* node bin/my_program