telegram-crawler/data/corefork.telegram.org.html
2022-03-04 19:34:00 +00:00

257 lines
24 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html class="">
<head>
<meta charset="utf-8">
<title>Telegram APIs</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta property="description" content="We offer two kinds of APIs for developers. The Bot API allows you to easily create programs that use Telegram messages for…">
<meta property="og:title" content="Telegram APIs">
<meta property="og:image" content="df8a0f9162ddfc1daf">
<meta property="og:description" content="We offer two kinds of APIs for developers. The Bot API allows you to easily create programs that use Telegram messages for…">
<link rel="shortcut icon" href="/favicon.ico?4" type="image/x-icon" />
<link href="/css/bootstrap.min.css?3" rel="stylesheet">
<link href="/css/telegram.css?219" rel="stylesheet" media="screen">
<style>
</style>
</head>
<body class="preload">
<div class="dev_page_wrap">
<div class="dev_page_head navbar navbar-static-top navbar-tg">
<div class="navbar-inner">
<div class="container clearfix">
<ul class="nav navbar-nav navbar-right hidden-xs"><li class="navbar-twitter"><a href="https://twitter.com/telegram" target="_blank" data-track="Follow/Twitter" onclick="trackDlClick(this, event)"><i class="icon icon-twitter"></i><span> Twitter</span></a></li></ul>
<ul class="nav navbar-nav">
<li><a href="//telegram.org/">Home</a></li>
<li class="hidden-xs"><a href="//telegram.org/faq">FAQ</a></li>
<li class="hidden-xs"><a href="//telegram.org/apps">Apps</a></li>
<li class="active"><a href="/api">API</a></li>
<li class=""><a href="/mtproto">Protocol</a></li>
<li class=""><a href="/schema">Schema</a></li>
</ul>
</div>
</div>
</div>
<div class="container clearfix">
<div class="dev_page">
<div id="dev_page_content_wrap" class=" ">
<div class="dev_page_bread_crumbs"></div>
<h1 id="dev_page_title">Telegram APIs</h1>
<div id="dev_page_content"><p>We offer two kinds of APIs for developers. The <a href="#bot-api"><strong>Bot API</strong></a> allows you to easily create programs that use Telegram messages for an interface. The <a href="#tdlib-build-your-own-telegram"><strong>Telegram API and TDLib</strong></a> allow you to build your own customized Telegram clients. You are welcome to use both APIs free of charge.</p>
<p>You can also add <a href="/widgets"><strong>Telegram Widgets</strong></a> to your website.</p>
<p>Designers are welcome to create <a href="/animated_stickers"><strong>Animated Stickers</strong></a> or <a href="/themes"><strong>Custom Themes</strong></a> for Telegram.</p>
<hr>
<h3><a class="anchor" href="#bot-api" id="bot-api" name="bot-api"><i class="anchor-icon"></i></a>Bot API</h3>
<div>
<a href="/file/811140327/1/zlN4goPTupk/9ff2f2f01c4bd1b013" target="_blank"><img src="/file/811140934/1/tbDSLHSaijc/fdcc7b6d5fb3354adf" title="The Botfather. Click for hi-res picture" style="max-width: 200px;float:right"></a>
</div>
<p>This API allows you to connect bots to our system. <a href="/bots"><strong>Telegram Bots</strong></a> are special accounts that do not require an additional phone number to set up. These accounts serve as an interface for code running somewhere on your server.</p>
<p>To use this, you don't need to know anything about how our MTProto encryption protocol works — our intermediary server will handle all encryption and communication with the Telegram API for you. You communicate with this server via a simple HTTPS-interface that offers a simplified version of the Telegram API.</p>
<blockquote>
<p><a href="/bots"><strong>Learn more about the Bot API here »</strong></a></p>
</blockquote>
<p>Bot developers can also make use of our <a href="/bots/payments"><strong>Payments API</strong></a> to accept <strong>payments</strong> from Telegram users around the world.</p>
<hr>
<h3><a class="anchor" href="#tdlib--build-your-own-telegram" id="tdlib--build-your-own-telegram" name="tdlib--build-your-own-telegram"><i class="anchor-icon"></i></a>TDLib build your own Telegram</h3>
<p>Even if you're looking for maximum customization, you don't have to create your app from scratch. Try our <a href="https://core.telegram.org/tdlib"><strong>Telegram Database Library</strong></a> (or simply TDLib), a tool for third-party developers that makes it easy to build fast, secure and feature-rich Telegram apps.</p>
<p>TDLib takes care of all <strong>network implementation</strong> details, <strong>encryption</strong> and <strong>local data storage</strong>, so that you can dedicate more time to design, responsive interfaces and beautiful animations.</p>
<p>TDLib supports all Telegram features and makes developing Telegram apps a breeze on any platform. It can be used on Android, iOS, Windows, macOS, Linux and virtually any other system. The library is open source and compatible with virtually <strong>any programming language</strong>.</p>
<blockquote>
<p><a href="https://core.telegram.org/tdlib"><strong>Learn more about TDLib here »</strong></a></p>
</blockquote>
<hr>
<h3><a class="anchor" href="#telegram-api" id="telegram-api" name="telegram-api"><i class="anchor-icon"></i></a>Telegram API</h3>
<p>This API allows you to build your own customized Telegram clients. It is 100% open for all developers who wish to create Telegram applications on our platform. Feel free to study the open <a href="https://telegram.org/apps#source-code">source code</a> of existing Telegram applications for examples of how things work here. Don't forget to <a href="/api/obtaining_api_id">register</a> your application in our system. </p>
<ul>
<li><a href="#getting-started">Getting Started</a></li>
<li><a href="#security">Security</a></li>
<li><a href="#optimization">Optimization</a></li>
<li><a href="#api-methods">API methods</a></li>
</ul>
<h3><a class="anchor" href="#getting-started" id="getting-started" name="getting-started"><i class="anchor-icon"></i></a>Getting started</h3>
<h4><a class="anchor" href="#creating-an-application" id="creating-an-application" name="creating-an-application"><i class="anchor-icon"></i></a><a href="/api/obtaining_api_id">Creating an application</a></h4>
<p>How to get your application identifier and create a new Telegram app.</p>
<h4><a class="anchor" href="#user-authorization" id="user-authorization" name="user-authorization"><i class="anchor-icon"></i></a><a href="/api/auth">User authorization</a></h4>
<p>How to register a user's phone to start using the API.</p>
<h4><a class="anchor" href="#two-factor-authentication" id="two-factor-authentication" name="two-factor-authentication"><i class="anchor-icon"></i></a><a href="/api/srp">Two-factor authentication</a></h4>
<p>How to login to a user's account if they have enabled 2FA, how to change password.</p>
<h4><a class="anchor" href="#qr-code-login" id="qr-code-login" name="qr-code-login"><i class="anchor-icon"></i></a><a href="/api/qr-login">QR code login</a></h4>
<p><a href="https://en.wikipedia.org/wiki/QR_code">QR code</a> login flow</p>
<h4><a class="anchor" href="#error-handling" id="error-handling" name="error-handling"><i class="anchor-icon"></i></a><a href="/api/errors">Error handling</a></h4>
<p>How to handle API return errors correctly.</p>
<h4><a class="anchor" href="#handling-different-data-centers" id="handling-different-data-centers" name="handling-different-data-centers"><i class="anchor-icon"></i></a><a href="/api/datacenter">Handling different data centers</a></h4>
<p>How to connect to the closest DC access point for faster interaction with the API, and things to watch out for when developing a client.</p>
<h4><a class="anchor" href="#handling-updates" id="handling-updates" name="handling-updates"><i class="anchor-icon"></i></a><a href="/api/updates">Handling updates</a></h4>
<p>How to subscribe to updates and handle them properly.</p>
<h4><a class="anchor" href="#handling-push-notifications" id="handling-push-notifications" name="handling-push-notifications"><i class="anchor-icon"></i></a><a href="/api/push-updates">Handling PUSH-notifications</a></h4>
<p>How to subscribe and handle them properly.</p>
<h4><a class="anchor" href="#channels-supergroups-and-groups" id="channels-supergroups-and-groups" name="channels-supergroups-and-groups"><i class="anchor-icon"></i></a><a href="/api/channel">Channels, supergroups and groups</a></h4>
<p>How to handle channels, supergroups, groups, and what's the difference between them.</p>
<h4><a class="anchor" href="#channel-statistics" id="channel-statistics" name="channel-statistics"><i class="anchor-icon"></i></a><a href="/api/stats">Channel statistics</a></h4>
<p>Telegram offers detailed channel statistics for channels and supergroups. </p>
<h4><a class="anchor" href="#calling-methods" id="calling-methods" name="calling-methods"><i class="anchor-icon"></i></a><a href="/api/invoking">Calling methods</a></h4>
<p>Additional options for calling methods.</p>
<h4><a class="anchor" href="#uploading-and-downloading-files" id="uploading-and-downloading-files" name="uploading-and-downloading-files"><i class="anchor-icon"></i></a><a href="/api/files">Uploading and Downloading Files</a></h4>
<p>How to transfer large data batches correctly.</p>
<h4><a class="anchor" href="#pagination" id="pagination" name="pagination"><i class="anchor-icon"></i></a><a href="/api/offsets">Pagination</a></h4>
<p>How to fetch results from large lists of objects.</p>
<h4><a class="anchor" href="#client-configuration" id="client-configuration" name="client-configuration"><i class="anchor-icon"></i></a><a href="/api/config">Client configuration</a></h4>
<p>The MTProto API has multiple client configuration parameters that can be fetched with the appropriate methods. </p>
<h3><a class="anchor" href="#security" id="security" name="security"><i class="anchor-icon"></i></a>Security</h3>
<h4><a class="anchor" href="#secret-chats-end-to-end-encryption" id="secret-chats-end-to-end-encryption" name="secret-chats-end-to-end-encryption"><i class="anchor-icon"></i></a><a href="/api/end-to-end">Secret chats, end-to-end encryption</a></h4>
<p>End-to-end-encrypted messaging.</p>
<h4><a class="anchor" href="#security-guidelines" id="security-guidelines" name="security-guidelines"><i class="anchor-icon"></i></a><a href="/mtproto/security_guidelines">Security guidelines</a></h4>
<p>Important checks required in your client application.</p>
<h4><a class="anchor" href="#perfect-forward-secrecy" id="perfect-forward-secrecy" name="perfect-forward-secrecy"><i class="anchor-icon"></i></a><a href="/api/pfs">Perfect Forward Secrecy</a></h4>
<p>Binding temporary authorization key to permanent ones.</p>
<h4><a class="anchor" href="#end-to-end-encryption-in-voice-and-video-calls" id="end-to-end-encryption-in-voice-and-video-calls" name="end-to-end-encryption-in-voice-and-video-calls"><i class="anchor-icon"></i></a><a href="https://core.telegram.org/api/end-to-end/video-calls">End-to-End Encryption in Voice and Video Calls</a></h4>
<p>End-to-end-encrypted calls.</p>
<h3><a class="anchor" href="#optimization" id="optimization" name="optimization"><i class="anchor-icon"></i></a>Optimization</h3>
<h4><a class="anchor" href="#client-optimization" id="client-optimization" name="client-optimization"><i class="anchor-icon"></i></a><a href="/api/optimisation">Client optimization</a></h4>
<p>Ways to boost API interactions.</p>
<h3><a class="anchor" href="#api-methods" id="api-methods" name="api-methods"><i class="anchor-icon"></i></a>API methods</h3>
<h4><a class="anchor" href="#available-method-list" id="available-method-list" name="available-method-list"><i class="anchor-icon"></i></a><a href="/methods">Available method list</a></h4>
<p>A list of available high-level methods.</p>
<h4><a class="anchor" href="#api-tl-schema-as-json" id="api-tl-schema-as-json" name="api-tl-schema-as-json"><i class="anchor-icon"></i></a><a href="/schema">API TL-schema</a>, <a href="/schema/json">as JSON</a></h4>
<p>Text and JSON-presentation of types and methods used in API.</p>
<h4><a class="anchor" href="#available-layer-list" id="available-layer-list" name="available-layer-list"><i class="anchor-icon"></i></a><a href="/api/layers">Available layer list</a></h4>
<p>A list of available schema versions.</p>
<h3><a class="anchor" href="#other-articles" id="other-articles" name="other-articles"><i class="anchor-icon"></i></a>Other articles</h3>
<h4><a class="anchor" href="#working-with-bots-using-the-mtproto-api" id="working-with-bots-using-the-mtproto-api" name="working-with-bots-using-the-mtproto-api"><i class="anchor-icon"></i></a><a href="/api/bots">Working with bots, using the MTProto API</a></h4>
<p>How to work with bots using the MTProto API.</p>
<h3><a class="anchor" href="#commands" id="commands" name="commands"><i class="anchor-icon"></i></a><a href="/api/bots/commands">Commands</a></h3>
<p><a href="/bots">Bots</a> offer a set of commands that can be used by users in private, or in a chat. </p>
<h3><a class="anchor" href="#buttons" id="buttons" name="buttons"><i class="anchor-icon"></i></a><a href="/api/bots/buttons">Buttons</a></h3>
<p>Users can interact with your bot via <strong>buttons</strong> or even <strong>inline buttons</strong>, straight from inline <strong>messages</strong> in <strong>any</strong> chat. </p>
<h3><a class="anchor" href="#inline-queries" id="inline-queries" name="inline-queries"><i class="anchor-icon"></i></a><a href="/api/bots/inline">Inline queries</a></h3>
<p>Users can interact with your bot via <strong>inline queries</strong>, straight from the <strong>text input field</strong> in <strong>any</strong> chat. </p>
<h3><a class="anchor" href="#games" id="games" name="games"><i class="anchor-icon"></i></a><a href="/api/bots/games">Games</a></h3>
<p>Bots can offer users HTML5 games to play solo or to compete against each other in groups and one-on-one chats; how to work with games in the MTProto API.</p>
<h3><a class="anchor" href="#search--filters" id="search--filters" name="search--filters"><i class="anchor-icon"></i></a><a href="/api/search">Search &amp; filters</a></h3>
<p>Telegram allows applying detailed message filters while looking for messages in chats.
This allows the server to filter messages based on a text query, and even on their type, and this feature is often used by graphical clients to implement features like the chat gallery, chat profile pictures and more.</p>
<h3><a class="anchor" href="#polls" id="polls" name="polls"><i class="anchor-icon"></i></a><a href="/api/poll">Polls</a></h3>
<p>Telegram allows sending polls and quizzes, that can be voted on by thousands, if not millions of users in chats and channels.</p>
<h3><a class="anchor" href="#reactions" id="reactions" name="reactions"><i class="anchor-icon"></i></a><a href="/api/reactions">Reactions</a></h3>
<p>Telegram allows users to react on any message using specific emojis, triggering cute lottie animations. </p>
<h4><a class="anchor" href="#invite-links-and-join-requests" id="invite-links-and-join-requests" name="invite-links-and-join-requests"><i class="anchor-icon"></i></a><a href="/api/invites">Invite links and join requests</a></h4>
<p>Channels, legacy groups and supergroups may have a public username or a private invite link: private invite links may be further enhanced with per-user join requests.</p>
<h4><a class="anchor" href="#admin-banned-and-default-rights-for-channels-supergroups-and-groups" id="admin-banned-and-default-rights-for-channels-supergroups-and-groups" name="admin-banned-and-default-rights-for-channels-supergroups-and-groups"><i class="anchor-icon"></i></a><a href="/api/rights">Admin, banned and default rights for channels, supergroups and groups</a></h4>
<p>How to handle admin permissions, granular bans and global permissions in channels, groups and supergroups.</p>
<h4><a class="anchor" href="#discussion-groups" id="discussion-groups" name="discussion-groups"><i class="anchor-icon"></i></a><a href="/api/discussion">Discussion groups</a></h4>
<p><a href="/api/channel">Groups</a> can be associated to a <a href="/api/channel">channel</a> as a <a href="https://telegram.org/blog/privacy-discussions-web-bots">discussion group</a>, to allow users to discuss about posts. </p>
<h4><a class="anchor" href="#channel-comments-and-message-threads" id="channel-comments-and-message-threads" name="channel-comments-and-message-threads"><i class="anchor-icon"></i></a><a href="/api/threads">Channel comments and message threads</a></h4>
<p>Telegram allows commenting on a <a href="/api/channel">channel post</a> or on a generic <a href="/api/channel">group message</a>, thanks to message threads.</p>
<h4><a class="anchor" href="#admin-log" id="admin-log" name="admin-log"><i class="anchor-icon"></i></a><a href="/api/recent-actions">Admin log</a></h4>
<p>Both supergroups and channels offer a so-called <a href="https://telegram.org/blog/admin-revolution">admin log</a>, a log of recent relevant supergroup and channel actions, like the modification of group/channel settings or information on behalf of an admin, user kicks and bans, and more. </p>
<h4><a class="anchor" href="#pinned-messages" id="pinned-messages" name="pinned-messages"><i class="anchor-icon"></i></a><a href="/api/pin">Pinned messages</a></h4>
<p>Telegram allows pinning multiple messages on top of a specific chat. </p>
<h4><a class="anchor" href="#mentions" id="mentions" name="mentions"><i class="anchor-icon"></i></a><a href="/api/mentions">Mentions</a></h4>
<p>Telegram allows mentioning other users in case of urgent duckling matters, and quickly navigating to those mentions in order to read them as swiftly as possible.</p>
<h4><a class="anchor" href="#scheduled-messages" id="scheduled-messages" name="scheduled-messages"><i class="anchor-icon"></i></a><a href="/api/scheduled-messages">Scheduled messages</a></h4>
<p>Telegram allows scheduling messages.</p>
<h4><a class="anchor" href="#live-geolocations" id="live-geolocations" name="live-geolocations"><i class="anchor-icon"></i></a><a href="/api/live-location">Live geolocations</a></h4>
<p>Telegram allows sending the live geolocation of a user in a chat, optionally setting a proximity alert. </p>
<h4><a class="anchor" href="#min-constructors" id="min-constructors" name="min-constructors"><i class="anchor-icon"></i></a><a href="/api/min">Min constructors</a></h4>
<p>Sometimes, <a href="/constructor/user">user</a> and <a href="/constructor/channel">channel</a> constructors met in group chat updates may not contain full info about the user: how to handle such constructors.</p>
<h4><a class="anchor" href="#account-deletion" id="account-deletion" name="account-deletion"><i class="anchor-icon"></i></a><a href="/api/account-deletion">Account deletion</a></h4>
<p>How to reset an account if the <a href="/api/srp">2FA</a> password was forgotten.</p>
<h4><a class="anchor" href="#imported-messages" id="imported-messages" name="imported-messages"><i class="anchor-icon"></i></a><a href="/api/import">Imported messages</a></h4>
<p>Telegram allows importing messages and media from foreign chat apps.</p>
<h4><a class="anchor" href="#telegram-passport" id="telegram-passport" name="telegram-passport"><i class="anchor-icon"></i></a><a href="/api/passport">Telegram Passport</a></h4>
<p>How to work with <a href="/api/passport">Telegram Passport</a> directly using the MTProto API.</p>
<h4><a class="anchor" href="#telegram-payments" id="telegram-payments" name="telegram-payments"><i class="anchor-icon"></i></a><a href="/api/payments">Telegram Payments</a></h4>
<p>How to work with Telegram Payments directly using the MTProto API.</p>
<h4><a class="anchor" href="#styled-text-with-message-entities" id="styled-text-with-message-entities" name="styled-text-with-message-entities"><i class="anchor-icon"></i></a><a href="/api/entities">Styled text with message entities</a></h4>
<p>How to create styled text with message entities</p>
<h4><a class="anchor" href="#working-with-animated-emojis" id="working-with-animated-emojis" name="working-with-animated-emojis"><i class="anchor-icon"></i></a><a href="/api/animated-emojis">Working with animated emojis</a></h4>
<p>Graphical telegram clients should transform emojis into their respective animated version. </p>
<h4><a class="anchor" href="#working-with-animated-dice" id="working-with-animated-dice" name="working-with-animated-dice"><i class="anchor-icon"></i></a><a href="/api/dice">Working with animated dice</a></h4>
<p>Telegram supports sending <a href="https://telegram.org/blog/folders#and-one-more-thing">animated dice</a> emojis. </p>
<h4><a class="anchor" href="#message-drafts" id="message-drafts" name="message-drafts"><i class="anchor-icon"></i></a><a href="/api/drafts">Message drafts</a></h4>
<p>How to handle message drafts</p>
<h4><a class="anchor" href="#folders" id="folders" name="folders"><i class="anchor-icon"></i></a><a href="/api/folders">Folders</a></h4>
<p>Working with folders</p>
<h4><a class="anchor" href="#top-peer-rating" id="top-peer-rating" name="top-peer-rating"><i class="anchor-icon"></i></a><a href="/api/top-rating">Top peer rating</a></h4>
<p>If <a href="/method/contacts.toggleTopPeers">enabled</a>, the rating of <a href="/constructor/topPeer">top peers</a> indicates the relevance of a frequently used peer in a certain <a href="/type/TopPeerCategory">category</a> (frequently messaged users, frequently used bots, inline bots, frequently visited channels and so on).</p>
<h4><a class="anchor" href="#handling-file-references" id="handling-file-references" name="handling-file-references"><i class="anchor-icon"></i></a><a href="/api/file_reference">Handling file references</a></h4>
<p>How to handle file references.</p>
<h4><a class="anchor" href="#seamless-telegram-login" id="seamless-telegram-login" name="seamless-telegram-login"><i class="anchor-icon"></i></a><a href="/api/url-authorization">Seamless Telegram Login</a></h4>
<p>Handle Seamless Telegram Login URL authorization requests.</p>
<h4><a class="anchor" href="#web-events" id="web-events" name="web-events"><i class="anchor-icon"></i></a><a href="/api/web-events">Web events</a></h4>
<p>When interacting with HTML5 games and the websites of payment gateways, Telegram apps should expose the following JS APIs.</p></div>
</div>
</div>
</div>
<div class="footer_wrap">
<div class="footer_columns_wrap footer_desktop">
<div class="footer_column footer_column_telegram">
<h5>Telegram</h5>
<div class="footer_telegram_description"></div>
Telegram is a cloud-based mobile and desktop messaging app with a focus on security and speed.
</div>
<div class="footer_column">
<h5><a href="//telegram.org/faq">About</a></h5>
<ul>
<li><a href="//telegram.org/faq">FAQ</a></li>
<li><a href="//telegram.org/blog">Blog</a></li>
<li><a href="//telegram.org/jobs">Jobs</a></li>
</ul>
</div>
<div class="footer_column">
<h5><a href="//telegram.org/apps#mobile-apps">Mobile Apps</a></h5>
<ul>
<li><a href="//telegram.org/dl/ios">iPhone/iPad</a></li>
<li><a href="//telegram.org/dl/android">Android</a></li>
<li><a href="//telegram.org/dl/wp">Windows Phone</a></li>
</ul>
</div>
<div class="footer_column">
<h5><a href="//telegram.org/apps#desktop-apps">Desktop Apps</a></h5>
<ul>
<li><a href="//desktop.telegram.org/">PC/Mac/Linux</a></li>
<li><a href="//macos.telegram.org/">macOS</a></li>
<li><a href="//telegram.org/dl/web">Web-browser</a></li>
</ul>
</div>
<div class="footer_column footer_column_platform">
<h5><a href="//core.telegram.org/">Platform</a></h5>
<ul>
<li><a href="//core.telegram.org/api">API</a></li>
<li><a href="//translations.telegram.org/">Translations</a></li>
<li><a href="//instantview.telegram.org/">Instant View</a></li>
</ul>
</div>
</div>
<div class="footer_columns_wrap footer_mobile">
<div class="footer_column">
<h5><a href="//telegram.org/faq">About</a></h5>
</div>
<div class="footer_column">
<h5><a href="//telegram.org/blog">Blog</a></h5>
</div>
<div class="footer_column">
<h5><a href="//telegram.org/apps">Apps</a></h5>
</div>
<div class="footer_column">
<h5><a href="//core.telegram.org/">Platform</a></h5>
</div>
<div class="footer_column">
<h5><a href="https://twitter.com/telegram" target="_blank" data-track="Follow/Twitter" onclick="trackDlClick(this, event)">Twitter</a></h5>
</div>
</div>
</div>
</div>
<script src="/js/main.js?43"></script>
<script>backToTopInit("Go up");
removePreloadInit();
</script>
</body>
</html>