with BitMEX and Schedule?
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 Schedule app in Pipedream is a powerful tool that allows you to trigger workflows at regular intervals, ranging from every minute to once a year. This enables the automation of repetitive tasks and the scheduling of actions to occur without manual intervention. By leveraging this API, you can execute code, run integrations, and process data on a reliable schedule, all within Pipedream's serverless environment.