Introduction
BANGJEFF provides easy API / REST API connection facilities. With BANGJEFF, you do not need to bother setting the request or response format on each client, BANGJEFF will make it easier for you to manage your connection.
Authentication
To ensure secure access, you will need to provide the following header:
- Name
X-Client-Id
- Type
- uuid
- Description
API Key (provided by BANGJEFF or retrieve from our Reseller Portal).
Sample
X-Client-Id: 4fa770d1-d500-4a7f-86aa-390611228351
- Name
X-Request-Time
- Type
- YYYY-MM-DDTHH:mm:ssZ
- Description
Request Time should be ISO 8601 and will be used to generate Signature.
Sample
X-Request-Time: 2024-09-03T21:59:00+07:00
- Name
X-Signature
- Type
- string
- Description
Below is the explaination to generate Signature.
Prepare Request Information :
- Method: Ensure that the method is set to
POST
. - Pathname: The pathname should be provided without the leading slash (
/
). For example, if your original pathname is/api/v4/balance
, it should beapi/v4/balance
. - Payload: The payload should have all whitespace and newlines removed before being processed. Ensure that the payload is a single, continuous string with no spaces or line breaks.
Sample Request
POST/api/v4/balance{ "region": "ID" }
Please follow these step to generate Signature :
- Encode your payload to MD5
Payload Encoding Sample
Payload = MD5({"region":"ID"}) MD5 Result = ca06c494d590574127263feeed50bae5
- Constructing the signature payload
Signature Payload Constructing Sample
Method = POST Pathname = /api/v4/balance Payload = MD5({"region":"ID"}) // ca06c494d590574127263feeed50bae5 Request Time = 2024-09-03T21:59:00+07:00 POST:api/v4/balance:ca06c494d590574127263feeed50bae5:2024-09-03T21:59:00+07:00
- Generate HMAC Signature using SHA-256 algorithm. The signature payload is signed with your API Key
export const bangjeffGenerateSignature = <T>( method: string, pathname: string, payload: T, timestamp: Date, clientId: string ): string => { const payloadString = JSON.stringify(payload); const timestampString = moment(timestamp).format("YYYY-MM-DDTHH:mm:ssZ"); // Encode your payload to MD5 const hashedPayload = Crypto.MD5(payloadString); const hashedPayloadString = hashedPayload.toString(CryptoJS.enc.Hex); // Constructing the signature payload const signaturePayload = `${method}:${pathname}:${hashedPayloadString}:${timestampString}`; // Generate HMAC Signature using SHA-256 algorithm. The signature payload is signed with your API Key const signatureHmac = CryptoJS.HmacSHA256(signaturePayload, clientId); const signatureString = signatureHmac.toString(CryptoJS.enc.Hex); return signatureString; };
- Method: Ensure that the method is set to