Installation
This page walks you through adding chapa-nodejs to your project and creating a configured Chapa instance ready to make API calls.
Prerequisites
You need Node.js installed and a Chapa account with a secret key. You can get your secret key from the Chapa dashboard.
Install the package
Install with npm:
npm install -s chapa-nodejsOr with Yarn:
yarn add chapa-nodejsCreate a Chapa instance
Import Chapa from the package and instantiate it with your secret key. Every SDK method is called on this instance.
import { Chapa } from 'chapa-nodejs';
const chapa = new Chapa({
secretKey: 'your-chapa-secret-key',
});Note: Keep your secret key out of version control. Store it in an environment variable or a secrets manager and pass it in at runtime.
Verify the setup
Call getBanks() — it requires no arguments and returns immediately if your key is valid. It's the lightest possible check.
const banks = await chapa.getBanks();
console.log(banks.data); // array of supported banksIf you see a populated array, your credentials are working and you're ready to initialize transactions. Head to Quickstart for the full first-payment workflow.