Last updated
Was this helpful?
Was this helpful?
elven-api-key: obtained api key
elven-api-sign: base64-encoded signature, e.g., LVT5aXA9064gpgZrPXPLJB/Aq9r45yMF10sTZQTteyE=
elven-api-timestamp: timestamp in milliseconds, e.g., 1721209655047, expires after 30 seconds// uses the crypto library from https://github.com/nodejs/node/blob/v16.9.0/lib/crypto.js
/**
* generate signature
* apiSecret: BjGiqCWfHGCrl065dlEBWFO5vLj7Hqiexxx,
* timestamp: 1721205912758
* method: POST
* path: /open/v3/businessData
*/
buildSign(apiSecret: string, timestamp: number, method: string, path: string) {
const str = `${timestamp}${method}${path}`
return crypto.createHmac('sha256', apiSecret).update(str).digest('base64')
}// example parameters
[
'D7JLJ3awwrTdNXtSrPI1GlYE', // key
'BjGiqCWfHGCrl065dlEBWFO5vLj7Hqie', // secret
'POST', // method, must be uppercase
'/open/v3/businessData' // path, must start with '/'
]
// headers
{
'elven-api-key': 'D7JLJ3awwrTdNXtSrPI1GlYE',
'elven-api-sign': 'LVT5aXA9064gpgZrPXPLJB/Aq9r45yMF10sTZQTteyE=',
'elven-api-timestamp': 1721209655047
}