Authentication
Describes authentication-related fields included in the header.
Field Name
Description
How to create a signature
import CryptoJs from "crypto-js";
import sortJson from "sort-json";
import _ from "lodash";
function generateSignature(apiSecret, method, path, timestamp, nonce, body) {
// Body and QueryStrings must be sort by key value Ascending (ASC) and Stringified JSON
// Query strings sort by key ASC
const requestPath = path.split('?')[0];
const queryStrings = new URLSearchParams(path.split('?')[1]);
queryStrings.sort();
// Body sort by key ASC
const params = JSON.stringify(sortJson(body || {}, { ignoreCase: true, reverse: false }));
// Path Include Query Strings
// Params Must Stringified JSON
const apiPath = `${method}${requestPath}${queryStrings.toString().length > 0 ? '?' : ''}${decodeURIComponent(queryStrings.toString()}${nonce}${timestamp}${params}`;
// Encrypt apiPath By Hmac Sha512
let hash = CryptoJs.HmacSHA512(apiPath, apiSecret);
// And Encode By Base64
return CryptoJs.enc.Base64.stringify(hash);
}Examples
signature for Mapping Item API
signature for Get Item List API
Last updated