Getting Started

Installation

pip install equity-jenga-api

First Things First

Generating an openSSL private/public key pair.

Since v2 of the API, JengaHQ now requires some APIs to include signatures as a security measure. This signatures are usually generated by signing some request fields with a private key. In order to use JengaHQ you’ll have to upload your public key to the developer console on JengaHQ after you generate your key pair.

This Library provides a CLI command to help you generate those keys.

Note

The generated keys will be stored in your home directory under the .JengaAPI/keys/ folder and this is where by default the Library looks for your private key when initiating JengaRequest Objects.

After Installation, Generate Your Keys using the following command:

$ jenga_gen_key_pair

Note

Then copy the ~/.JengaApi/keys/publickey.pem to your developer console on JengaHq.

Using The APIs

Creating JengaRequest objects

By Design all API classes provided inherit from the equity_jenga.api.auth.JengaAuth class which takes the following parameters:

class equity_jenga.api.auth.JengaAuth(authorization_token: str, merchant_code: str, env: str, private_key='/home/docs/.JengaApi/keys/privatekey.pem', sandbox_url='https://sandbox.jengahq.io', live_url='')[source]

Jenga Base Authentication Class

Params

:authorization_token:: the bearer token used to access the API, i.e apiKey :merchant_code:: the merchant code provided by JengaHQ :private_key:: the path to the merchant private key default is “~/.JengaAPI/keys/privatekey.pem” :env:: the environment in which the API is to be used either sandbox or production :sandbox_url:: the url used to access the Sandbox API :live_url:: the url used to access the Production API

Example

from equity_jenga import api
jengabase = api.auth.JengaApi(
authorization_token="Bearer TofFGUeU9y448idLCKVAe35LmAtL",
merchant_code="4144142283",
env="sandbox",
)
# Similarly for all classes Inheriting from JengaAuth
acc_Bal = api.auth.account_services.balances.AccountBalance(
authorization_token="Bearer TofFGUeU9y448idLCKVAe35LmAtL",
merchant_code="4144142283",
env="sandbox",
)
# Get Available Balances
available_bal=acc_Bal.available(countryCode='KE',accountId="0011547896523")
print(available_bal)
# Opening and Closing Balances
opening_and_closing_bal=acc_Bal.get_opening_and_closing(accountId="0011547896523"countryCode='KE',date="2020-03-21")
print(opening_and_closing_bal)
signature(request_hash_fields: tuple)[source]

Build a String of concatenated values of the request fields with following order: as specificied by the API endpoint The resulting text is then signed with Private Key and Base64 encoded.

Takes a tuple of request fields in the order that they should be concatenated, hashes them with SHA-256,signs the resulting hash and returns a Base64 encoded string of the resulting signature