Websockets 101: Practical Example With Python and Kraken Exchange

Konstantin Borimechkov
4 min readDec 4, 2023

Do you want your application to handle real-time data? Entering - websockets. Let’s learn how to leverage them to do exactly that!

More recently, I had an opportunity to improve my software development skills by working on an app that uses Kraken’s Websocket API to retrieve real-time data about available trades. This is when the idea for this article popped-up!

In this article, we will be going trough 👇

  • A brief intro to Websockets and how do they differ from the traditional HTTP requests
  • An implementation of Kraken’s Websocket using Python

Intro And Comparison of Websockets vs HTTP

For simplifying the explanation, let’s compare websockets to your normal HTTP request..

Whereas HTTP relies on a client request to receive a response from the server for every exchange, websockets allow for bidirectional communication between applications. What’s that? 🤔

Bidirectional communication means that the server can send real-time updates asynchronously, without requiring the client to submit a request each time.

--

--

Konstantin Borimechkov

Writing Code For a Living 🚀 | Software Engineer @ Tide | Writing Blogs About Python & CS