HELP - Creating a plugin for a signed API call

Hi everyone!

I looked for many ways to do one thing: get data from an API call to Kraken.
The complexity is that the call is “signed”, ie you have to take your API key and send it in your header in a hashed form (documentation here: https://www.kraken.com/fr-fr/features/api#general-usage). Everything must work on Bubble, this is the other complexity.

So I already tried some ways to do it:

  • do the hash in no-code in my bubble app (problem: it’s hash function is not directly available in the functionalities so we would have to find an API to do the conversion but I didn’t find one)
  • run a python code with Zappier (problem: I have a message of the type “Mapping input_data is not available in triggers.” and therefore I can not go to the end. However, I have some python code that works well to call this API on Jupyter)
  • create a plugin on Bubble where JavaScript can be executed. I think it’s the best way. (problem: I can’t retrieve the data with my little JS code, please see below).

Here is my plugin details:

function(properties, context) {
const key = properties.public_key; // API Key
const secret = properties.private_key; // API Private Key
const KrakenClient = require(‘kraken-api’);
const kraken = new KrakenClient(key, secret);
const Ledgers = kraken.api(‘Ledgers’);
return {“data”: Ledgers};
}

The result should be an object with a list of transactions as follow
image

Since I am still a beginner in this field, I have trouble finalizing this plugin and recovering the data in my workflow.
Can anyone help me ?
Many thanks in advance!

A cursory look at your code suggests the problem might be that you need to execute the call to the Kraken API asynchronously and await the response. See this post.

Is it better?

> function(properties, context) {
>   const key          = properties.public_key; // API Key
>   const secret       = properties.private_key; // API Private Key
>   const KrakenClient = require('kraken-api');
>   const kraken       = new KrakenClient(key, secret);
> return context.async( async callback => {
>     try {
>         let Ledgers = await kraken.api('Ledgers');
>         callback( undefined, {"data": Ledgers} );
>     }
>     catch ( err ) {
>         callback( err );
>     }
> });
> }