with BitMEX and Klaviyo?
import crypto from "crypto";
import { axios } from "@pipedream/platform";
export default defineComponent({
props: {
bitmex: {
type: "app",
app: "bitmex",
}
},
async run({ steps, $ }) {
// Set verb, path, and data as needed
const verb = "GET";
const path = "/api/v1/user";
const expires = Math.floor(Date.now() / 1000) + 60; // UNIX timestamp in seconds
const data = ""; // No body for GET
// Function to generate signature
function generateSignature(apiSecret, verb, path, expires, data) {
const message = verb + path + expires + data;
return crypto
.createHmac("sha256", apiSecret)
.update(message)
.digest("hex");
}
// Build headers
const signature = generateSignature(
this.bitmex.$auth.api_secret,
verb,
path,
expires,
data
);
const headers = {
"api-key": this.bitmex.$auth.api_key,
"api-expires": expires,
"api-signature": signature,
};
// Perform request
return await axios($, {
method: verb,
url: `${this.bitmex.$auth.api_url}${path}`,
headers,
});
},
})The Klaviyo API grants you the power to automate and personalize your email marketing efforts. With it, you can manage lists, profiles, and campaigns, track event-driven communications, and analyze the results. By leveraging this API on Pipedream, you can create intricate, automated workflows that respond in real-time to your users' behavior, sync data across multiple platforms, and tailor your marketing strategies to improve engagement and conversion rates.
import { axios } from "@pipedream/platform"
export default defineComponent({
props: {
klaviyo: {
type: "app",
app: "klaviyo",
}
},
async run({steps, $}) {
return await axios($, {
url: ` https://a.klaviyo.com/api/accounts/`,
headers: {
"Authorization": `Klaviyo-API-Key ${this.klaviyo.$auth.api_key}`,
"revision": `2023-12-15`,
},
})
},
})