Everything about Telegram is cool. No, seriously. It’s free, heavily encrypted, cloud-based, powerful, and there are plenty of great features like polls and archived and self-destroying chats. The only thing that might confuse app developers is the claim that it’s open-source.
We investigated Telegram’s source code and wrote this post because a lot of our clients have asked us to clarify whether they can use it to develop their own messaging applications. Our response is You can, but we don’t recommend it. Telegram source code is indeed free and open, but it will barely help app developers build their own messaging apps. Here’s why.
You can’t use the Telegram API to build an independent messaging app
In order to use the Telegram API to create your messaging software, you’ll have to register your app here. All you need to do is enter your phone number. Then you’ll receive a password to your Telegram account. After you receive the password, you can register an app on Telegram’s website. After doing that, you’ll receive a unique api_id and api_hash that are necessary to work with the Telegram API.
So, we actually used the Telegram API to build a messaging app. And when we entered our phone number in the messaging app we created, we got all the messages we’d previously sent in the Telegram app (both desktop and Android). In other words, all data associated with users is tied to their phone numbers they enter when they authorize with Telegram.
This is how we came to the conclusion that the Telegram API allows you to work with Telegram’s data only. In other words, it’s impossible to store your data on a separate server or in a separate database. The API will let you create an app that interacts with the Telegram messaging app, but your app won’t be able to live a life of its own.
Actually, you could use Telegram’s open-source client and build your own server to create secure chat functionality for your own company. But your backend specialists would surely need some time to conduct deep research on how to create a server that’s compatible with the Telegram API, build it, and fix any bugs. Also, keep in mind that you would need to hire experts in encryption and data security to build your own server.
A lot of apps have open APIs and let other developers use them. Take TweetCaster, for example. The service uses open Twitter APIs. All tweets published to TweetCaster are published to Twitter as well.
You’ll face a lot of hardcode and other major issues
The Telegram code itself has lots of hardcode and no constants. There are no system constants, nor are there constants in the app itself. Other Telegram open source pitfalls include:
Magic numbers for int values, such as 42540, which are passed as flag values. This made us think Telegram’s code is obfuscated, but most likely this isn’t the case.
If-Else statements are too long, and there are really long methods (i.e. 300 lines of code in one method). Moreover, you can’t find documentation (or there's some confusing one) for these methods and can’t support such code. If you decide to change, disable, or add a new feature, you might spend up to a month doing that.
Spaghetti code. Telegram’s code is complicated and hard to read, so it can make you spend days simply understanding its architecture. We haven’t met anyone who likes spaghetti in their code.
All of these issues will seriously frustrate and demotivate your development team, as they’ll have to carefully study so much code and remember it when working on your app. Potentially, this can lead to such problems as poor code quality and lengthy development.
You won’t be able to plan your app’s growth
If you decide to use Telegram’s open-source code along with its servers (and there's no open source code for Telegram's servers), you won’t be able to implement any new functionality in your Telegram client except for minor local changes (a new UI theme, different icons) and any functionality added in updates to Telegram itself.
If you look at the second scenario, when you choose to build your own servers to work with Telegram’s open-source code, you can plan and even try implementing your own features. But you’ll still have to add new Telegram functionality as soon as the official updates come out to stay up to date. This is how you double your amount of work and spend twice the resources on app development. Moreover, unplanned Telegram updates will always be disrupting your plans — unless Durov himself informs you beforehand.
If you develop an app with a Telegram license, it should go on GitHub
Even if you make an app based on Telegram, you have to publish your source code. The Telegram license says: “Please remember to publish your code as well in order to comply with the GNU GPL licence.”
If you commit your time and money to developing a messaging app using Telegram source code, you probably won’t be happy about having to publish your code for everyone else to use.
What about some successful cases of using the Telegram API?
Telegram X is the very first Telegram client that comes to mind when you think of a Telegram alternative. This is because Telegram X:
runs faster and offers smoother animations
requires less power from user devices (when working in the background, it consumes minimum energy without slowing down performance)
offers a better-thought-out UI with a variety of themes and allows users to change the font size in messages, enable or disable link previews, and customize unread message counters
Sounds great, right? Probably that’s why about five percent of Telegram users have switched to the X version. And that could make you think that Telegram X is a perfect Telegram competitor based on the open-source Telegram code. But the truth is that it’s not.
As mentioned on Telegram’s official website, both Telegram X apps were written by Pavel Durov’s development team from ground zero, using a totally new codebase and not using any legacy components. In other words, even Durov’s development team decided to build the Telegram X apps from scratch instead of reusing the original Telegram code, and the results turned out even better without it.
As Pavel Durov himself has stated, Telegram X is more of an experiment than an actual Telegram rival. And the main aim of the X version is to discover how to improve the original Telegram app and catch a broader audience. So you can’t really say that any businesses have actually benefited from creating a Telegram-based messenger — except for Telegram itself.
At the end of the day, however, it’s not a big deal that the Telegram source code can’t help you much in developing your app. Yalantis has plenty of experience designing and building custom messaging services. We’ll make sure you get the best messenger!