Bloc Nodejs SDK

A Nodejs API wrapper for Bloc banking services written in typescript
Table of content
Prerequisites
Node v16 and higher is required. To make sure you have them available on your machine, try running the following command.
node -v
Getting Started
To get started with this SDK, create an account on Bloc if you haven't already.
You can then retrieve your API keys from your Bloc dashboard.
Installation
This SDK can be installed with npm or yarn or pnpm.
npm install bloc-nodejs
yarn install bloc-nodejs
pnpm add bloc-nodejs
Usage
Import and Initialize the library
import { Bloc } from 'bloc-nodejs';
const { Bloc } = require('bloc-nodejs')
const bloc = new Bloc('SECRET_KEY, PUBLIC_KEY');
Available Methods exposed by the SDK
Accounts API
Accounts API operations
Create Fixed Account
import type { ICreateFixedAccountRequest, IAccountResponse } from 'bloc-nodejs';
const payload: ICreateFixedAccountRequest = {
}
const response = await bloc.createFixedAccount(payload)
console.log(response)
Find more details about the parameters and response for the above method here
Create Collection Account
import type { ICreateCollectionAccountRequest, ICreateCollectionAccountResponse } from 'bloc-nodejs';
const payload: ICreateCollectionAccountRequest = {
}
const response = await bloc.createCollectionAccount(payload)
console.log(response)
Find more details about the parameters and response for the above method here
Get Accounts
import type { IGetAccountsResponse } from 'bloc-nodejs';
const response = await bloc.getAccounts(payload)
console.log(response)
Find more details about the parameters and response for the above method here
Get Account By ID
import type { IAccountResponse } from 'bloc-nodejs';
const response = await bloc.getAccountById('account-id')
console.log(response)
Find more details about the parameters and response for the above method here
Get Collection Account
import type { IGetCollectionAccountResponse } from 'bloc-nodejs';
const response = await bloc.getCollectionAccount()
console.log(response)
Find more details about the parameters and response for the above method here
Get Account by Account Number
import type { IAccountResponse } from 'bloc-nodejs';
const response = await bloc.getAccountByAccountNumber('account-number')
console.log(response)
Find more details about the parameters and response for the above method here
Get Customer Accounts
import type { IGetAccountsResponse } from 'bloc-nodejs';
const response = await bloc.getCustomerAccounts('customer-id')
console.log(response)
Find more details about the parameters and response for the above method here
Get Organisation Default Accounts
import type { IGetOrganisationDefaultAccountsResponse } from 'bloc-nodejs';
const response = await bloc.getOrganisationDefaultAccounts()
console.log(response)
Find more details about the parameters and response for the above method here
Freeze Account
import type { IUpdateAccountRequest, IUpdateAccountResponse } from 'bloc-nodejs';
const payload: IUpdateAccountRequest = {
}
const response = await bloc.freezeAccount('account-id', data)
console.log(response)
Find more details about the parameters and response for the above method here
Unfreeze Account
import type { IUpdateAccountRequest, IUpdateAccountResponse } from 'bloc-nodejs';
const payload: IUpdateAccountRequest = {
}
const response = await bloc.unfreezeAccount('account-id', data)
console.log(response)
Find more details about the parameters and response for the above method here
Close Account
import type { IUpdateAccountRequest, IUpdateAccountResponse } from 'bloc-nodejs';
const payload: IUpdateAccountRequest = {
}
const response = await bloc.closeAccount('account-id', data)
console.log(response)
Find more details about the parameters and response for the above method here
Reopen Account
import type { IUpdateAccountRequest, IUpdateAccountResponse } from 'bloc-nodejs';
const payload: IUpdateAccountRequest = {
}
const response = await bloc.reopenAccount('account-id', data)
console.log(response)
Find more details about the parameters and response for the above method here
Wallets API
Wallets API operations
Create Wallet
import type { IWallet, IWalletResponse } from 'bloc-nodejs';
const payload: IWallet = {
}
const response = await bloc.createWallet(payload)
console.log(response)
Find more details about the parameters and response for the above method here
Get Wallets
import type { IGetWalletResponse } from 'bloc-nodejs';
const response = await bloc.getWallets()
console.log(response)
Find more details about the parameters and response for the above method here
Get Wallet By ID
import type { IWalletResponse } from 'bloc-nodejs';
const response = await bloc.getWalletById('wallet-id')
console.log(response)
Find more details about the parameters and response for the above method here
Get Customer Wallets
import type { IGetCustomerWalletResponse } from 'bloc-nodejs';
const response = await bloc.getCustomerWallets('customer-id')
console.log(response)
Find more details about the parameters and response for the above method here
Debit Wallet
import type { IDebitWallet, IGetCustomerWalletResponse } from 'bloc-nodejs';
const payload: IDebitWallet = {
}
const response = await bloc.debitWallet(payload)
console.log(response)
Find more details about the parameters and response for the above method here
Bills Payments API
Bills Payments API operations
Get Supported Bills
import type { ISupportedBillsResponse } from 'bloc-nodejs';
const response = await bloc.getSupportedBills()
console.log(response)
Find more details about the parameters and response for the above method here
Get Supported Operators
import type { ISupportedOperatorsResponse } from 'bloc-nodejs';
const response = await bloc.getSupportedOperators()
console.log(response)
Find more details about the parameters and response for the above method here
Get Operator Products
import type { IOperatorProductsResponse } from 'bloc-nodejs';
const response = await bloc.getOperatorProducts('operator-id')
console.log(response)
Find more details about the parameters and response for the above method here
Customer Device Validation
import type { IGetCustomerWalletResponse } from 'bloc-nodejs';
const response = await bloc.customerDeviceValidation('operator-id')
console.log(response)
Find more details about the parameters and response for the above method here
Make Payment
import type { IMakePaymentResponse, IMakePaymentResponse } from 'bloc-nodejs';
const payload: IMakePaymentResponse = {
}
const response = await bloc.makePayment(payload)
console.log(response)
Find more details about the parameters and response for the above method here
Disputes API
Disputes API operations
Get Card Dispute Reasons
import type { IGetCardDisputeReasonsResponse } from 'bloc-nodejs';
const response = await bloc.getCardDisputeReasons()
console.log(response)
Find more details about the parameters and response for the above method here
Create Card Dispute
import type { ICreateCardDisputeRequest, ICardDisputeResponse } from 'bloc-nodejs';
const payload: ICreateCardDisputeRequest = {
}
const response = await bloc.createCardDispute(payload)
console.log(response)
Find more details about the parameters and response for the above method here
Get Card Disputes
import type { IGetCardDisputesResponse } from 'bloc-nodejs';
const response = await bloc.getCardDisputes()
console.log(response)
Find more details about the parameters and response for the above method here
Get Card Dispute
import type { ICardDisputeResponse } from 'bloc-nodejs';
const response = await bloc.getCardDisputeById('dispute-id')
console.log(response)
Find more details about the parameters and response for the above method here
Update Card Dispute
import type { IUpdateCardDisputeRequest, ICardDisputeResponse } from 'bloc-nodejs';
const payload: IUpdateCardDisputeRequest = {
}
const response = await bloc.updateCardDispute('dispute-id', payload)
console.log(response)
Find more details about the parameters and response for the above method here
Cards API
Cards API operations
Issue Card
import type { IIssueCardRequest, ICardResponse } from 'bloc-nodejs';
const payload: IIssueCardRequest = {
}
const response = await bloc.issueCard(payload)
console.log(response)
Find more details about the parameters and response for the above method here
Get Cards
import type { IGetCardsResponse } from 'bloc-nodejs';
const response = await bloc.getCards()
console.log(response)
Find more details about the parameters and response for the above method here
Get Card by Id
import type { ICardResponse } from 'bloc-nodejs';
const response = await bloc.getCardById('card-id')
console.log(response)
Find more details about the parameters and response for the above method here
Get Customer Cards
import type { IGetCardsResponse } from 'bloc-nodejs';
const response = await bloc.getCustomerCards('customer-id')
console.log(response)
Find more details about the parameters and response for the above method here
Get Card Secure Data
import type { ICardSecureDataResponse } from 'bloc-nodejs';
const response = await bloc.getCardSecureData('card-id')
console.log(response)
Find more details about the parameters and response for the above method here
Change Card PIN
import type { IChangeCardPinRequest, ICardResponse } from 'bloc-nodejs';
const payload: IChangeCardPinRequest = {
}
const response = await bloc.changeCardPIN('card-id', payload)
console.log(response)
Find more details about the parameters and response for the above method here
Freeze Card
import type { ICardResponse } from 'bloc-nodejs';
const response = await bloc.freezeCard('card-id')
console.log(response)
Find more details about the parameters and response for the above method here
Unfreeze Card
import type { ICardResponse } from 'bloc-nodejs';
const response = await bloc.unfreezeCard('card-id')
console.log(response)
Find more details about the parameters and response for the above method here
Block Card
import type { IBlockCardRequest, ICardResponse } from 'bloc-nodejs';
const payload: IBlockCardRequest = {
}
const response = await bloc.blockCard('card-id', payload)
console.log(response)
Find more details about the parameters and response for the above method here
Link Card with Fixed Account
import type { ILinkCardwithFixedAccountRequest, ICardResponse } from 'bloc-nodejs';
const payload: ILinkCardwithFixedAccountRequest = {
}
const response = await bloc.linkCardwithFixedAccount(payload)
console.log(response)
Find more details about the parameters and response for the above method here
Unlink Card From Fixed Account
import type { ICardResponse } from 'bloc-nodejs';
const response = await bloc.unlinkCardwithFixedAccount('card-id')
console.log(response)
Find more details about the parameters and response for the above method here
Fund Card
import type { IFundCardRequest, ICardResponse } from 'bloc-nodejs';
const payload: IFundCardRequest = {
}
const response = await bloc.fundCard('card-id', payload)
console.log(response)
Find more details about the parameters and response for the above method here
Withdraw From Card
import type { IWithdrawFromCardRequest, ICardResponse } from 'bloc-nodejs';
const payload: IWithdrawFromCardRequest = {
}
const response = await bloc.withdrawFromCard('card-id', payload)
console.log(response)
Find more details about the parameters and response for the above method here
Checkout API
Checkout API operations
Create Checkout
import type { ICreateCheckout, ICheckoutResponse } from 'bloc-nodejs';
const payload: ICreateCheckout = {
}
const response = await bloc.createCheckout(payload)
console.log(response)
Find more details about the parameters and response for the above method here
Customers API
Customer API operations
Create Customer
import type { ICreateCustomer, ICreateCustomerResponse } from 'bloc-nodejs';
const payload: ICreateCustomer = {
}
const response = await bloc.createCustomer(payload)
console.log(response)
Find more details about the parameters and response for the above method here
Get Customers
import type { IGetCustomerResponse } from 'bloc-nodejs';
const response = await bloc.getCustomers()
console.log(response)
Find more details about the parameters and response for the above method here
Upgrade Customer to KYC T1
import type { IUpgradeCustomerToKYCT1, IUpgradeCustomerToKYCTierResponse } from 'bloc-nodejs';
const payload: IUpgradeCustomerToKYCT1 = {
}
const response = await bloc.upgradeCustomerToKYCT1('customer-id', payload)
console.log(response)
Find more details about the parameters and response for the above method here
Upgrade Customer to KYC T2
import type { IUpgradeCustomerToKYCT2, IUpgradeCustomerToKYCTierResponse } from 'bloc-nodejs';
const payload: IUpgradeCustomerToKYCT2 = {
}
const response = await bloc.upgradeCustomerToKYCT2('customer-id', payload)
console.log(response)
Find more details about the parameters and response for the above method here
Upgrade Customer to KYC T3
import type { IUpgradeCustomerToKYCT3, IUpgradeCustomerToKYCTierResponse } from 'bloc-nodejs';
const payload: IUpgradeCustomerToKYCT3 = {
}
const response = await bloc.upgradeCustomerToKYCT3('customer-id', payload)
console.log(response)
Find more details about the parameters and response for the above method here
Update Customer
import type { IUpdateCustomer, IUpdateCustomerResponse } from 'bloc-nodejs';
const payload: IUpdateCustomer = {
}
const response = await bloc.updateCustomer('customer-id', payload)
console.log(response)
Find more details about the parameters and response for the above method here
Get Customer By ID
import type { IGetCustomerByIdResponse } from 'bloc-nodejs';
const response = await bloc.getCustomerById('customer-id')
console.log(response)
Find more details about the parameters and response for the above method here
Means of Identification
import type { IMeansOfIdentification } from 'bloc-nodejs';
const response = await bloc.meansOfIdentification()
console.log(response)
Find more details about the parameters and response for the above method here
Revalidate Customer KYC
import type { IRevalidateCustomerKYCResponse } from 'bloc-nodejs';
const response = await bloc.revalidateCustomerKYC('customer-id')
console.log(response)
Find more details about the parameters and response for the above method here
Miscellaneous API
Miscellaneous API operations
Get List of Banks
import type { IListOfBanksResponse } from 'bloc-nodejs';
const response = await bloc.getListOfBanks()
console.log(response)
Find more details about the parameters and response for the above method here
Resolve Account
import type { IResolveAccountResponse } from 'bloc-nodejs';
const response = await bloc.resolveAccount()
console.log(response)
Find more details about the parameters and response for the above method here
Get Exchange Rate
import type { IGetExchangeRateResponse } from 'bloc-nodejs';
const response = await bloc.getExchangeRate('NGN-USD')
console.log(response)
Find more details about the parameters and response for the above method here
Simulation API
Simulation API operations
Credit Account
import type { ISimulationAccount, ICreditAccountResponse } from 'bloc-nodejs';
const payload: ISimulationAccount = {
}
const response = await bloc.creditAccount(payload)
console.log(response)
Find more details about the parameters and response for the above method here
Debit Account
import type { ISimulationAccount, IDebitAccountResponse } from 'bloc-nodejs';
const payload: ISimulationAccount = {
}
const response = await bloc.debitAccount(payload)
console.log(response)
Find more details about the parameters and response for the above method here
Transactions API
Transactions API operations
Get All Transactions
import type { ITransactionResponse } from 'bloc-nodejs';
const response = await bloc.getAllTransactions()
console.log(response)
Find more details about the parameters and response for the above method here
Get Transaction by Reference
import type { ITransactionByReferenceResponse } from 'bloc-nodejs';
const response = await bloc.getTransactionByReference('ref_num')
console.log(response)
Find more details about the parameters and response for the above method here
Transfers API
Transfers API operations
Transfer From A Fixed Account
import type { ITransferFromAFixedAccountRequest, ITransferResponse } from 'bloc-nodejs';
const payload: ITransferFromAFixedAccountRequest = {
}
const response = await bloc.transferFromAFixedAccount(payload)
console.log(response)
Find more details about the parameters and response for the above method here
Transfer From Organization Balance
import type { ITransferFromOrganizationBalance, ITransferResponse } from 'bloc-nodejs';
const payload: ITransferFromOrganizationBalance = {
}
const response = await bloc.transferFromOrganizationBalance(payload)
console.log(response)
Find more details about the parameters and response for the above method here
Internal Transfer
import type { IInternalTransferRequest, ITransferResponse } from 'bloc-nodejs';
const payload: IInternalTransferRequest = {
}
const response = await bloc.internalTransfer(payload)
console.log(response)
Find more details about the parameters and response for the above method here
Bulk Transfer
import type { IBulkTransferRequest, ITransferResponse } from 'bloc-nodejs';
const payload: IBulkTransferRequest = {
}
const response = await bloc.bulkTransfer(payload)
console.log(response)
Find more details about the parameters and response for the above method here
Webhook API
Webhook API operations
Set Webhook
import type { ISetWebhook, IWebhookResponse } from 'bloc-nodejs';
const payload: ISetWebhook = {
}
const response = await bloc.setWebhook(payload)
console.log(response)
Find more details about the parameters and response for the above method here
Get Webhook
import type { IWebhookResponse } from 'bloc-nodejs';
const response = await bloc.getWebhook()
console.log(response)
Find more details about the parameters and response for the above method here
Payment Links API
Payment Link API operations
Create Payment Link
import type { ICreatePaymentLinkRequest, IPaymentLinkResponse } from 'bloc-nodejs';
const payload: ICreatePaymentLinkRequest = {
}
const response = await bloc.createPaymentLink(payload)
console.log(response)
Find more details about the parameters and response for the above method here
Get Payment Links
import type { IGetPaymentLinksResponse } from 'bloc-nodejs';
const response = await bloc.getPaymentLinks()
console.log(response)
Find more details about the parameters and response for the above method here
Get Payment Link By id
import type { IPaymentLinkResponse } from 'bloc-nodejs';
const response = await bloc.getPaymentLinkById('link-id')
console.log(response)
Find more details about the parameters and response for the above method here
Edit Payment Link
import type { IEditPaymentLinkRequest, IPaymentLinkResponse } from 'bloc-nodejs';
const payload: IEditPaymentLinkRequest = {
}
const response = await bloc.editPaymentLink('link-id', payload)
console.log(response)
Find more details about the parameters and response for the above method here
Delete Payment Link
import type { IDeletePaymentLinksRequest, IPaymentLinkResponse } from 'bloc-nodejs';
const payload: IDeletePaymentLinksRequest = {
}
const response = await bloc.deletePaymentLink(payload)
console.log(response)
Find more details about the parameters and response for the above method here
Beneficiaries API
Beneficiaries API operations
Create Beneficiary
import type { ICreateBeneficiary, IBeneficiaryResponse } from 'bloc-nodejs';
const payload: ICreateBeneficiary = {
}
const response = await bloc.createBeneficiary(payload)
console.log(response)
Find more details about the parameters and response for the above method here
Get Beneficiary by ID
import type { IBeneficiaryResponse } from 'bloc-nodejs';
const response = await bloc.getBeneficiaryById('beneficiary-id')
console.log(response)
Find more details about the parameters and response for the above method here
Update Beneficiary
import type { IUpdateBeneficiary, IBeneficiaryResponse } from 'bloc-nodejs';
const payload: ICreateBeneficiary = {
}
const response = await bloc.updateBeneficiary('beneficiary-id', payload)
console.log(response)
Find more details about the parameters and response for the above method here
Delete Beneficiary
const response = await bloc.deleteBeneficiary('beneficiary-id')
console.log(response)
Find more details about the parameters and response for the above method here
License
MIT
Back to Top