cURL
PUBLIC_KEY="pk_live_..."
PRIVATE_KEY="sk_live_..."
TIMESTAMP=$(date +%s)
PATH_URI="/api/v1/events?count=5"
SIGNATURE=$(printf '%s\n%s\n%s\n' "$TIMESTAMP" "GET" "$PATH_URI" \
| openssl dgst -sha256 -hmac "$PRIVATE_KEY" | awk '{print $2}')
curl -H "X-Public-Key: $PUBLIC_KEY" \
-H "X-Timestamp: $TIMESTAMP" \
-H "X-Signature: $SIGNATURE" \
"https://backend.localbusiness.pro$PATH_URI"
Node.js
const crypto = require("crypto");
const publicKey = "pk_live_...";
const privateKey = "sk_live_...";
const timestamp = Math.floor(Date.now() / 1000).toString();
const method = "GET";
const path = "/api/v1/events?count=5";
const body = "";
const signingString = `${timestamp}\n${method}\n${path}\n${body}`;
const signature = crypto
.createHmac("sha256", privateKey)
.update(signingString)
.digest("hex");
const response = await fetch("https://backend.localbusiness.pro/api/v1/events?count=5", {
headers: {
"X-Public-Key": publicKey,
"X-Timestamp": timestamp,
"X-Signature": signature,
},
});
const data = await response.json();
console.log(data);
Python
import hmac, hashlib, time, requests
public_key = "pk_live_..."
private_key = "sk_live_..."
timestamp = str(int(time.time()))
method = "GET"
path = "/api/v1/events?count=5"
body = ""
signing_string = f"{timestamp}\n{method}\n{path}\n{body}"
signature = hmac.new(
private_key.encode(), signing_string.encode(), hashlib.sha256
).hexdigest()
response = requests.get(
"https://backend.localbusiness.pro/api/v1/events?count=5",
headers={
"X-Public-Key": public_key,
"X-Timestamp": timestamp,
"X-Signature": signature,
},
)
print(response.json())
PHP
<?php
$publicKey = 'pk_live_...';
$privateKey = 'sk_live_...';
$timestamp = time();
$method = 'GET';
$path = '/api/v1/events?count=5';
$body = '';
$signingString = $timestamp . "\n" . $method . "\n" . $path . "\n" . $body;
$signature = hash_hmac('sha256', $signingString, $privateKey);
$ch = curl_init('https://backend.localbusiness.pro/api/v1/events?count=5');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"X-Public-Key: $publicKey",
"X-Timestamp: $timestamp",
"X-Signature: $signature",
]);
$response = curl_exec($ch);
curl_close($ch);
print_r(json_decode($response, true));