@gem.co/api
v1.66.0
Published
Node.js client library for the Gem API.
Downloads
470
Readme
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,
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);
}
})();
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. | | 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. |
SDK Requests
Users
| method | parameters | description | | --------- | ---------------------------------------- | ----------------- | | getUser | (userId: string) | Get a user by ID. | | listUsers | (pageNumber?: number, pageSize?: number) | List all users |
Profiles
| method | parameters | description | | ------------- | ----------------------------------------- | ----------------- | | createProfile | ( userId: string, profile: ProfileModel ) | Create a profile. |
Documents
| method | parameters | description | | --------------------- | ----------------------------------------- | --------------------------------------------------------------------------- | | createProfileDocument | ( profileId: string, document: FormData ) | Attach a document to a profile. (Documents may have many files associated.) |
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