For information on changes for our US clients, please visit our Support Center article.

Пошук
Automating API workflows using N8N Cloud

Introduction

Workflow automation tools (such as N8N Cloud, Integromat, and Zapier) allow the Kraken REST API to be integrated with any number of third party services (such as scheduling apps, database services, and messaging apps), enabling an unlimited variety of crypto trading tasks to be easily and efficiently automated.
As some examples, combining workflow automation with the Kraken API would allow the following crypto trading tasks to be implemented in a matter of minutes:
  • Receive your current Bitcoin balance and equivalent in USD via Telegram every morning at 8 AM
  • Purchase an additional 0.25 BTC at midnight every Thursday
  • Purchase an additional 500 DOGE every time Elon posts a new tweet
  • Place/cancel orders by sending a Telegram/WhatsApp message (essentially a messaging based trading interface)
  • Purchase X amount of every new currency that Kraken lists (as soon as it is listed)
  • Rebalance your crypto portfolio whenever it is more than 10% unbalanced

Example workflow

Consider the task of purchasing crypto at recurring or scheduled times and receiving notification of the new crypto balance via a messaging app.
While a seemingly simple task to describe, this would be difficult to accomplish using any one individual service, but it could be easily accomplished by integrating several services in an automated workflow.
The individual components that would be required are as follows:
  • Scheduling (either regularly recurring or at specific times)
  • Placing an order to buy the desired crypto (via the Kraken API)
  • Retrieve the new account balance (via the Kraken API)
  • Send a message to a messaging app with the new account balance
Using N8N Cloud, the complete task would look similar to the following:
with each node performing the following tasks:
  • Scheduling - The Cron and Interval nodes control the schedule of the crypto purchases, and can be used separately (as shown above with the Interval node disabled), or can be combined to achieve any valid schedule.
  • Configuration - The API Settings node configures the API aspects of the workflow (such as the API key) and the crypto purchase itself (such as which currency pair and how much crypto to buy).
  • Crypto purchase - The JavaScript 1 node sets several variables required by the API request (such as the API endpoint, POST data, and nonce value). The API auth 1 and API auth 2 nodes create the API authentication signature using the SHA256 and HMAC SHA512 hashing algorithms. The API request node performs the actual HTTP POST request to the API
    AddOrder endpoint. The API error check and Logic 1 nodes check the response from the API to determine if the call was successful or not, and decide which path to take next (balance retrieval or messaging app).
  • Balance retrieval - The JavaScript 2 node sets several variables required by the second API request (such as the new API endpoint, POST data, and nonce value). The API auth 1, API auth 2, API request, API error check, and Logic 1 nodes perform the same functions as before, but for the second API request to the Balance endpoint.
  • Messaging app - The TG message 1 andTG message 2 nodes set the notification messages (such as the new account balance for success, or an error explanation for failure), and the Telegram node sends the message via Telegram (or any alternative messaging app using the appropriate node).
The JSON for the above workflow can be downloaded and imported directly into N8N Cloud, and can then be used directly (simply by editing the API Settings node with your own API key), or can be used as a starting point for a brand new workflow.

Kraken REST API nodes

For any workflow, the core nodes that implement the Kraken REST API can remain almost unchanged, with additional aspects being handled by their relevant nodes (such as the Google Sheets node to write data to a spreadsheet, for example). This allows many different crypto trading tasks to be accomplished with only minimal Kraken API knowledge, and only minimal JavaScript coding experience.
The JSON for the core API nodes can be downloaded and imported into your own N8N Cloud workflows.