This is a blog post about Microgram, a Telegram client for Java ME phones

Kilogram - a simple way to communicate with Telegram

2023-11-22

As mentioned before, Microgram relies on a proxy server that does the heavy lifting for it. I call this proxy server Kilogram. It can be considered a separate product that can be used for all kinds of work with Telegram. Telegram's feature list is very, very long and new features are added every month. If you want to work with Telegram as a simple messenger, sending and receiving texts, photos and videos 1:1 or in groups, you can easily be overwhelmed by the sheer amount of stuff to handle.

Even if you want to support just basic text conversation (and this is what I am focussing on at the moment), the Telegram API is built with all its features carefully laid out, so there is a lot of work to be done to rule out most of them to get to a basic functionality that I want.

Kilogram

To get from the interaction with Telegram to a simple, JSON-based API, we have Kilogram. Kilogram is a server in the middle between Microgram (and possibly other lightweight client apps) and Telegram itself. It is written in Javascript and is based on gram.js. It can be hosted by anyone who knows how to run a deno application (or a Docker container). You can point your Microgram app to any Kilogram URL in its configuration dialog.

The API

I hestitate to call the API RESTful, since their exist a ton of rules when to call your API really RESTful. Let's just say: You can call any API endpoint in any order and it should always work (you have to authenticate once to get your session string). You send the credentials with every request (it is not stored in Kilogram). And we use more than just GET as HTTP method.

Anyhow, these are the methods currently implemented:

And that's it for the moment. No contact list, no images or other media, no new chat etc. Still, I think this server is worthy to have a proper name and serves a purpose potentially much larger than just a hack to make Telegram work on old Java phones. I am working on a OpenAPI documentation and will release the whole thing, of course, as open source along the J2ME client as soon as I have something to release.


This is a blog post about Microgram, a Telegram client for Java ME phones