How to interact with Telegram API

The Telegram API is not as easy to use as a normal HTTP/Rest API, you have to interact with their MTProto protocol. You also have to do all sorts of encryption and decryption. Telegram recently released a new Bot API which abstracts all the complications behind a decent HTTP API. Usage example in NodeJS using https://github.com/arcturial/telegrambot:

var TelegramBot = require('telegrambot');
var api = new TelegramBot('<YOUR TOKEN HERE>');

api.getUpdates({ offset: 0 }, function (err, updates) {
    // array of message updates since last poll
    console.log(updates);
});

api.sendMessage({ chat_id: 0, text: 'test' }, function (err, message) {
    // the chat_id is the id received in the getUpdates() call
});

The token can be generated using their BotFather application. You can also use their deep-linking feature to add a link to your website to initiate a conversation with the bot, like so:

https://telegram.me/triviabot?start=payload

The payload value can be anything you want, like a cache key you might use for validating a real person etc.

I know it doesn't directly answer your question, but from personal experience I found it's better to interact with the Bot API than trying to implement all the intricacies required for the normal API. If you are adamant about using their normal API, the IPs are 149.154.167.40:443 (test) and 149.154.167.50:443 (production). They provide the IP details under https://my.telegram.org/apps.


If you really want to understand Telegram API development from scratch. My advice would be to follow the steps here

https://core.telegram.org/mtproto/auth_key

and here

https://core.telegram.org/mtproto/samples-auth_key

Try to successfully generate an AuthKey.

This exercise will get you familiar with enough of the basics as well as help you build up routines you will need to do further work on Telegram API.

I have outlined the basics for you to get started in this SO post.

Also i think the API documentation online is not so well-written, but following the above step by step while reading the API documentation, for just AuthKey generation, would get you familiar with the language and writing style of the authors of the API

Good Luck.