import { axios } from "@pipedream/platform";
import crypto from "crypto";
export default defineComponent({
props: {
mexc: {
type: "app",
app: "mexc",
}
},
async run({ steps, $ }) {
// Build query string
const timestamp = Date.now()
const recvWindow = 5000
const queryString = `recvWindow=${recvWindow}×tamp=${timestamp}`
// Generate signature
const signature = crypto
.createHmac('sha256', this.mexc.$auth.secret_key)
.update(queryString)
.digest('hex')
// Make authenticated request
return await axios($, {
method: 'GET',
url: 'https://api.mexc.com/api/v3/account',
headers: {
'X-MEXC-APIKEY': this.mexc.$auth.access_key
},
params: {
recvWindow,
timestamp,
signature
}
})
},
})
MEXC uses API keys for authentication. When you connect your MEXC account, Pipedream securely stores the keys so you can easily authenticate to MEXC APIs in both code and no-code steps.