4 min readUpdated Oct 12, 2023

Channel subscription now possible with the new Python Realtime SDK

Channel subscription now possible with the new Python Realtime SDK
Faye McClenahanFaye McClenahan

Python is a popular programming language known for its simplicity and versatility. It's commonly used for web development, data analysis, and automation. While it's not usually associated with client-side development, it can be useful in scenarios where server-side applications need to exchange data in realtime.

This is why we’ve released a new Python Realtime SDK component that enables developers to integrate Ably's realtime functionality into their Python applications. Features include the creation of persistent WebSocket connections, channel subscription, authentication via tokens, and connection hardening.

Popularity of Python in multiple use cases

Python is a high-level programming language that is widely used today for a variety of purposes. It is known for its simplicity, readability, and versatility, making it a popular choice for both beginners and experienced programmers. Python can be used for web development, data analysis, machine learning, artificial intelligence, scientific computing, automation, and more. It has become an essential tool in many industries, including finance, healthcare, and tech, due to its ease of use, flexibility, and vast library of pre-built modules.

While Python is a very popular programming language (probably second only to JavaScript), it may not be the immediate language that springs to mind when envisioning realtime experiences, as it is associated more with backend than client-side applications. Languages such as JS, Swift, and Kotlin are more prominent in client-side development.

The need for realtime Python

Many developers today build server-based applications with Python, using REST functionality to publish data. Whilst other languages are still preferred/better suited to client applications, there are scenarios where also having a Python-based realtime capability is advantageous. It’s particularly useful, for example, when two server-side applications need to exchange data prior to then delivering to an end user device/browser or where applications, running data analytics and AI, need to communicate asynchronously between internal microservices.

Introducing the new Python Realtime SDK

The new Python Realtime SDK will enable developers to integrate Ably into their Python applications and enable realtime functionality (e.g. subscribing to channels) through the establishment of a persistent WebSocket connection. Specifically, you can subscribe to channels, you can authenticate via tokens, and we've added additional connection hardening - so if there are drops in connections, the SDK will apply retry logic and use fallback hosts.

Python realtime deployment scenarios

Realtime Python data subscription

Take a financial data company that publishes real time data, from their server-side applications (highly volatile, changing very quickly e.g. stock prices). They publish this data to their customers, via Ably, who use it to provide a service to end users. However these customers also have a Python-based server-side application that needs to subscribe to data, in realtime. This is now made possible using the Python Realtime SDK to create a persistent connection with Ably.

Asynchronous communication between internal microservices using Python

Another example: take an order fulfilment service built in Python that is made up of multiple microservices (e.g. orders, billing, inventory, and shipping). While the order service is processing and validating order requests coming from customers, it will need to asynchronously send valid orders to the other microservices while it continues handling orders. With the realtime functionality we have added to the Python Realtime SDK, this is now possible as Python applications can publish and subscribe to Ably channels.

The Python Realtime SDK is available via PyPI. As this is an improvement to our existing SDK (ably-python) to add realtime functionality, you will be able to add ably-python as a dependency to your projects, similar to how you do today. Additional details on getting started can be found here.

We would love to hear your realtime use cases and how the Python Realtime SDK can better help to improve this experience. Get in touch and help guide the direction of the Python SDK.

Join the Ably newsletter today

1000s of industry pioneers trust Ably for monthly insights on the realtime data economy.
Enter your email