Request format

Every method is an HTTP request to https://api.telegram.org/bot<TOKEN>/methodName, with parameters as a query string or JSON, and JSON responses.

Receiving updates

  • getUpdates: polling, simple, good for local testing;
  • setWebhook: pushed by Telegram, real-time, recommended in production.

Five common methods

  1. sendMessage: text with Markdown and buttons;
  2. sendPhoto / sendDocument: images and files;
  3. answerCallbackQuery: respond to inline button taps;
  4. setWebhook: set the push URL;
  5. getMe: check whether the token works.

Caution

A token is a password — never commit it to a public repository. Reading group messages needs privacy mode off or admin rights.