The Embed Node library provides easy access to the Embed Investment API by Cowrywise. Embed is an investment-as-a-service API that allows you to integrate investment features into your products and offer financial services to your customers at scale.
See the full Embed API Documentation.
- Node.js (v12+ recommended)
- npm or yarn
npm install @cowrywise/embed-nodeor
yarn add @cowrywise/embed-nodeTo get started, signup for developer credentials. You will receive a client_id and client_secret from the developer dashboard.
const Client = require('@cowrywise/embed-node');
const api = new Client({
client_id: 'YOUR_CLIENT_ID',
client_secret: 'YOUR_CLIENT_SECRET',
embed_api_base_url: 'https://sandbox.embed.cowrywise.com/api/v1' // Use sandbox for testing
});
// All methods return a Promise
api.wallets.getWallets()
.then(result => console.log(result))
.catch(err => console.error(err));The library handles token management internally. If you need to manually refresh the token:
await api.refreshToken();Manage investment accounts for your users.
// Create an investment account
await api.accounts.createAccount({
first_name: 'John',
last_name: 'Doe',
email: 'john.doe@example.com',
phone_number: '+2348000000000',
terms_of_use_accepted: true // Accept T&C on creation
});
// Accept T&C for an existing account
await api.accounts.acceptTerms('ACCOUNT_ID');
// Identity Verification (BVN)
await api.accounts.updateIdentity('ACCOUNT_ID', {
identity_type: 'bvn',
identity_value: '22222222281'
});
// Business Verification
await api.accounts.initiateBusinessVerification('ACCOUNT_ID', {
registration_type: 'RC',
registration_number: '0000008',
business_legal_name: 'Test Business Ltd',
industry_id: 'ind_1',
directors_info: [{ name: 'John Doe', bvn: '22222222281' }]
});
// Get Risk Profile Questions
const questions = await api.accounts.getRiskAssessmentQuestions();Withdrawals follow an "Intent" flow. An intent is initiated and fulfilled after a 24-hour waiting period.
// Initiate a withdrawal intent
await api.withdrawals.initiateWithdrawalIntent({
account_id: 'ACCOUNT_ID',
bank_id: 'BANK_ID',
amount: '5000',
currency: 'NGN'
});
// Get withdrawal intents
await api.withdrawals.getWithdrawalIntents('ACCOUNT_ID', 'NGN');
// Cancel an intent
await api.withdrawals.cancelWithdrawalIntent({
account_id: 'ACCOUNT_ID',
reference: 'REF123',
currency: 'NGN'
});// Create an investment
await api.investments.createInvestment({
account_id: 'ACCOUNT_ID',
asset_code: 'AST-FUND-123',
auto_reinvest: true
});
// Liquidate an investment
await api.investments.liquidateInvestment('INVESTMENT_ID', {
units: '10' // or amount: '5000'
});// Create a wallet
await api.wallets.createWallet({
account_id: 'ACCOUNT_ID',
currency_code: 'NGN'
});
// Fund an investment from a wallet
await api.wallets.transferFromWallet('WALLET_ID', {
product_code: 'PRCDE_123',
amount: '2000'
});// Create locked savings
await api.savings.createSavings({
account_id: 'ACCOUNT_ID',
currency_code: 'NGN',
days: '90',
interest_enabled: '1'
});
// Get savings interest rates
await api.savings.getSavingsRates('90');// Create a Fixed Note
await api.fixedNotes.createFixedNote({
account_id: 'ACCOUNT_ID',
asset_code: 'FN_123',
tenor_in_months: '3',
amount_range: '10M-100M'
});
// Withdraw from Flexible Savings
await api.flexibleSavings.withdraw('FLEX_ID', '5000');// List all investment assets
await api.assets.getAssets('mutual_fund');
// Fetch price history
await api.prices.getPriceHistory({
asset_id: 'ASSET_ID',
from_date: '2023-01-01',
to_date: '2023-12-31'
});await api.transactions.getTransfers();
await api.transactions.getDeposits();
await api.transactions.getWithdrawals();Before submitting a pull request, please ensure:
- Tests are added for the new changes.
- Commit messages are clear and descriptive.
- The code follows existing conventions.
This project is licensed under the ISC License.