{"id":279750,"date":"2026-08-13T10:55:26","date_gmt":"2026-08-13T08:55:26","guid":{"rendered":"https:\/\/www.unipile.com\/telegram-api-python\/"},"modified":"2026-08-13T15:20:54","modified_gmt":"2026-08-13T13:20:54","slug":"telegram-api-python","status":"publish","type":"post","link":"https:\/\/www.unipile.com\/it\/telegram-api-python\/","title":{"rendered":"Telegram API with Python: Bot API, MTProto and Linked Accounts"},"content":{"rendered":"<p>[et_pb_section fb_built=&#8221;1&#8243; _builder_version=&#8221;4.27.3&#8243; background_color=&#8221;transparent&#8221; custom_padding=&#8221;40px|0px|0px|0px|false|false&#8221; global_colors_info=&#8221;{}&#8221;]<br \/>\n[et_pb_row _builder_version=&#8221;4.27.3&#8243; background_color=&#8221;transparent&#8221; custom_padding=&#8221;0px|0px|0px|0px|false|false&#8221; global_colors_info=&#8221;{}&#8221;]<br \/>\n[et_pb_column type=&#8221;4_4&#8243; _builder_version=&#8221;4.27.3&#8243; global_colors_info=&#8221;{}&#8221;]<br \/>\n[et_pb_code _builder_version=&#8221;4.27.3&#8243; global_colors_info=&#8221;{}&#8221;]\n<link href=\"https:\/\/fonts.googleapis.com\/css2?family=Inter:wght@400;500;600;700&#038;family=Poppins:wght@700;800&#038;display=swap\" rel=\"stylesheet\">\n<style>\n#unipile-toc,\n#unipile-toc *,\n#unipile-toc *::before,\n#unipile-toc *::after {\n  margin: 0 !important;\n  padding: 0 !important;\n  box-sizing: border-box !important;\n  border: none !important;\n  outline: none !important;\n  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;\n  line-height: normal !important;\n  letter-spacing: normal !important;\n  text-transform: none !important;\n  text-decoration: none !important;\n  list-style: none !important;\n  background: transparent !important;\n  float: none !important;\n}\n#unipile-toc {\n  all: initial !important;\n  display: block !important;\n  max-width: 1100px !important;\n  margin: 0 auto !important;\n  padding: 0 !important;\n  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;\n}\n#unipile-toc .utc-card {\n  background: #ffffff !important;\n  border-radius: 16px !important;\n  border: 1px solid #e5e7eb !important;\n  padding: 32px !important;\n  box-shadow: 0 2px 12px rgba(15, 39, 54, 0.04) !important;\n}\n#unipile-toc .utc-header {\n  display: flex !important;\n  align-items: center !important;\n  justify-content: space-between !important;\n  gap: 12px !important;\n  margin-bottom: 24px !important;\n  padding-bottom: 20px !important;\n  border-bottom: 1px solid #e5e7eb !important;\n}\n#unipile-toc .utc-header-left {\n  display: flex !important;\n  align-items: center !important;\n  gap: 12px !important;\n}\n#unipile-toc .utc-icon-box {\n  width: 36px !important;\n  height: 36px !important;\n  background: rgba(59, 185, 139, 0.12) !important;\n  border-radius: 8px !important;\n  display: flex !important;\n  align-items: center !important;\n  justify-content: center !important;\n  flex-shrink: 0 !important;\n}\n#unipile-toc .utc-icon-box svg {\n  width: 18px !important;\n  height: 18px !important;\n  stroke: #3BB98B !important;\n  fill: none !important;\n  stroke-width: 2.2 !important;\n  stroke-linecap: round !important;\n  stroke-linejoin: round !important;\n}\n#unipile-toc .utc-title {\n  font-family: 'Poppins', sans-serif !important;\n  font-size: 15px !important;\n  font-weight: 700 !important;\n  color: #0f2736 !important;\n  text-transform: uppercase !important;\n  letter-spacing: 0.5px !important;\n}\n#unipile-toc .utc-toggle {\n  display: none !important;\n  align-items: center !important;\n  gap: 6px !important;\n  background: transparent !important;\n  cursor: pointer !important;\n  font-size: 13px !important;\n  font-weight: 600 !important;\n  color: #3BB98B !important;\n  padding: 6px 10px !important;\n  border-radius: 6px !important;\n  transition: background 0.2s ease !important;\n}\n#unipile-toc .utc-toggle svg {\n  width: 14px !important;\n  height: 14px !important;\n  stroke: #3BB98B !important;\n  fill: none !important;\n  stroke-width: 2.5 !important;\n  stroke-linecap: round !important;\n  stroke-linejoin: round !important;\n  transition: transform 0.3s ease !important;\n}\n#unipile-toc.utc-collapsed .utc-toggle svg {\n  transform: rotate(-90deg) !important;\n}\n#unipile-toc .utc-grid {\n  display: grid !important;\n  grid-template-columns: repeat(4, 1fr) !important;\n  gap: 0 !important;\n}\n#unipile-toc .utc-col {\n  padding: 0 24px !important;\n  border-left: 1px solid #e5e7eb !important;\n}\n#unipile-toc .utc-col:first-child {\n  padding-left: 0 !important;\n  border-left: none !important;\n}\n#unipile-toc .utc-col:last-child {\n  padding-right: 0 !important;\n}\n#unipile-toc .utc-col-label {\n  font-size: 11px !important;\n  font-weight: 700 !important;\n  color: #94a3b8 !important;\n  text-transform: uppercase !important;\n  letter-spacing: 0.8px !important;\n  margin-bottom: 14px !important;\n  display: block !important;\n}\n#unipile-toc .utc-link-list {\n  display: flex !important;\n  flex-direction: column !important;\n  gap: 10px !important;\n}\n#unipile-toc .utc-link {\n  display: flex !important;\n  align-items: flex-start !important;\n  gap: 10px !important;\n  cursor: pointer !important;\n  transition: all 0.2s ease !important;\n  text-decoration: none !important;\n  padding: 4px 0 !important;\n}\n#unipile-toc .utc-num {\n  width: 18px !important;\n  height: 18px !important;\n  flex-shrink: 0 !important;\n  background: #f4f5f7 !important;\n  border-radius: 4px !important;\n  display: flex !important;\n  align-items: center !important;\n  justify-content: center !important;\n  font-size: 10px !important;\n  font-weight: 700 !important;\n  color: #94a3b8 !important;\n  transition: all 0.2s ease !important;\n  margin-top: 1px !important;\n}\n#unipile-toc .utc-num.utc-num-faq {\n  font-size: 8px !important;\n  letter-spacing: 0.2px !important;\n}\n#unipile-toc .utc-link-text {\n  font-size: 13px !important;\n  font-weight: 500 !important;\n  color: #383838 !important;\n  line-height: 1.45 !important;\n  transition: color 0.2s ease !important;\n  flex: 1 !important;\n}\n#unipile-toc .utc-link:hover .utc-num {\n  background: rgba(59, 185, 139, 0.15) !important;\n  color: #3BB98B !important;\n}\n#unipile-toc .utc-link:hover .utc-link-text {\n  color: #0f2736 !important;\n}\n#unipile-toc .utc-link.utc-active .utc-num {\n  background: #3BB98B !important;\n  color: #ffffff !important;\n}\n#unipile-toc .utc-link.utc-active .utc-link-text {\n  color: #0f2736 !important;\n  font-weight: 600 !important;\n}\n#unipile-toc .utc-link.utc-read .utc-num {\n  background: rgba(59, 185, 139, 0.15) !important;\n  color: #3BB98B !important;\n}\n#unipile-toc .utc-tag-best {\n  display: inline-block !important;\n  font-size: 9px !important;\n  font-weight: 700 !important;\n  color: #ffffff !important;\n  background: #3BB98B !important;\n  padding: 2px 6px !important;\n  border-radius: 4px !important;\n  text-transform: uppercase !important;\n  letter-spacing: 0.5px !important;\n  margin-left: 6px !important;\n  vertical-align: middle !important;\n}<\/p>\n<p>@media (max-width: 1000px) {\n  #unipile-toc .utc-grid {\n    grid-template-columns: repeat(2, 1fr) !important;\n    gap: 24px 0 !important;\n  }\n  #unipile-toc .utc-col {\n    padding: 0 20px !important;\n  }\n  #unipile-toc .utc-col:nth-child(2n+1) {\n    padding-left: 0 !important;\n    border-left: none !important;\n  }\n  #unipile-toc .utc-col:nth-child(2n) {\n    padding-right: 0 !important;\n  }\n}<\/p>\n<p>@media (max-width: 700px) {\n  #unipile-toc .utc-card {\n    padding: 22px !important;\n  }\n  #unipile-toc .utc-header {\n    margin-bottom: 0 !important;\n    padding-bottom: 0 !important;\n    border-bottom: none !important;\n  }\n  #unipile-toc .utc-toggle {\n    display: flex !important;\n  }\n  #unipile-toc .utc-grid {\n    grid-template-columns: 1fr !important;\n    gap: 22px !important;\n    max-height: 2000px !important;\n    overflow: hidden !important;\n    transition: max-height 0.4s ease, margin-top 0.3s ease, padding-top 0.3s ease !important;\n    margin-top: 22px !important;\n    padding-top: 22px !important;\n    border-top: 1px solid #e5e7eb !important;\n  }\n  #unipile-toc.utc-collapsed .utc-grid {\n    max-height: 0 !important;\n    margin-top: 0 !important;\n    padding-top: 0 !important;\n    border-top: none !important;\n  }\n  #unipile-toc .utc-col {\n    padding: 0 !important;\n    border-left: none !important;\n    border-top: 1px solid #e5e7eb !important;\n    padding-top: 18px !important;\n  }\n  #unipile-toc .utc-col:first-child {\n    border-top: none !important;\n    padding-top: 0 !important;\n  }\n}\n\/* Defensive wpautop parade (additive only, does not touch template structure\/JS) *\/\n#unipile-toc br { display: none !important; }\n<\/style>\n<div id=\"unipile-toc\">\n<div class=\"utc-card\">\n<div class=\"utc-header\">\n<div class=\"utc-header-left\">\n<div class=\"utc-icon-box\">\n          <svg viewBox=\"0 0 24 24\">\n            <line x1=\"8\" y1=\"6\" x2=\"21\" y2=\"6\"\/>\n            <line x1=\"8\" y1=\"12\" x2=\"21\" y2=\"12\"\/>\n            <line x1=\"8\" y1=\"18\" x2=\"21\" y2=\"18\"\/>\n            <line x1=\"3\" y1=\"6\" x2=\"3.01\" y2=\"6\"\/>\n            <line x1=\"3\" y1=\"12\" x2=\"3.01\" y2=\"12\"\/>\n            <line x1=\"3\" y1=\"18\" x2=\"3.01\" y2=\"18\"\/>\n          <\/svg>\n        <\/div>\n<p>        <span class=\"utc-title\">Table of Contents<\/span>\n      <\/div>\n<p>      <button type=\"button\" class=\"utc-toggle\" aria-label=\"Toggle table of contents\"><br \/>\n        <span class=\"utc-toggle-label\">Hide<\/span><br \/>\n        <svg viewBox=\"0 0 24 24\"><polyline points=\"6 9 12 15 18 9\"\/><\/svg><br \/>\n      <\/button>\n    <\/div>\n<div class=\"utc-grid\">\n<div class=\"utc-col\">\n        <span class=\"utc-col-label\">Choose Your Path<\/span><\/p>\n<div class=\"utc-link-list\">\n          <a class=\"utc-link\" href=\"#typ-paths\"><br \/>\n            <span class=\"utc-num\">01<\/span><br \/>\n            <span class=\"utc-link-text\">3 ways to build Telegram in Python<\/span><br \/>\n          <\/a><br \/>\n          <a class=\"utc-link\" href=\"#typ-requests\"><br \/>\n            <span class=\"utc-num\">02<\/span><br \/>\n            <span class=\"utc-link-text\">Bot API in Python with requests<\/span><br \/>\n          <\/a>\n        <\/div>\n<\/p><\/div>\n<div class=\"utc-col\">\n        <span class=\"utc-col-label\">Bot API In Python<\/span><\/p>\n<div class=\"utc-link-list\">\n          <a class=\"utc-link\" href=\"#typ-ptb\"><br \/>\n            <span class=\"utc-num\">03<\/span><br \/>\n            <span class=\"utc-link-text\">Bot API with python-telegram-bot<\/span><br \/>\n          <\/a><br \/>\n          <a class=\"utc-link\" href=\"#typ-mtproto\"><br \/>\n            <span class=\"utc-num\">04<\/span><br \/>\n            <span class=\"utc-link-text\">User accounts: Telethon and Pyrogram<\/span><br \/>\n          <\/a>\n        <\/div>\n<\/p><\/div>\n<div class=\"utc-col\">\n        <span class=\"utc-col-label\">Beyond MTProto<\/span><\/p>\n<div class=\"utc-link-list\">\n          <a class=\"utc-link\" href=\"#typ-sdk\"><br \/>\n            <span class=\"utc-num\">05<\/span><br \/>\n            <span class=\"utc-link-text\">User accounts with the Unipile SDK<\/span><br \/>\n          <\/a><br \/>\n          <a class=\"utc-link\" href=\"#typ-errors\"><br \/>\n            <span class=\"utc-num\">06<\/span><br \/>\n            <span class=\"utc-link-text\">Errors and rate limits in Python<\/span><br \/>\n          <\/a>\n        <\/div>\n<\/p><\/div>\n<div class=\"utc-col\">\n        <span class=\"utc-col-label\">Resources<\/span><\/p>\n<div class=\"utc-link-list\">\n          <a class=\"utc-link\" href=\"#typ-compare\"><br \/>\n            <span class=\"utc-num\">07<\/span><br \/>\n            <span class=\"utc-link-text\">Compare the 3 approaches<span class=\"utc-tag-best\">Best<\/span><\/span><br \/>\n          <\/a><br \/>\n          <a class=\"utc-link\" href=\"#faq-typ\"><br \/>\n            <span class=\"utc-num utc-num-faq\">FAQ<\/span><br \/>\n            <span class=\"utc-link-text\">Frequently Asked Questions<\/span><br \/>\n          <\/a>\n        <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/div>\n<p><script>\n(function(){\n  var toc = document.getElementById('unipile-toc');\n  if (!toc) return;<\/p>\n<p>  var toggleBtn = toc.querySelector('.utc-toggle');\n  var toggleLabel = toc.querySelector('.utc-toggle-label');\n  if (toggleBtn) {\n    toggleBtn.addEventListener('click', function(){\n      var isCollapsed = toc.classList.toggle('utc-collapsed');\n      if (toggleLabel) toggleLabel.textContent = isCollapsed ? 'Show' : 'Hide';\n    });\n    if (window.innerWidth <= 700) {\n      toc.classList.add('utc-collapsed');\n      if (toggleLabel) toggleLabel.textContent = 'Show';\n    }\n  }\n\n  var links = toc.querySelectorAll('.utc-link');\n  links.forEach(function(link){\n    link.addEventListener('click', function(e){\n      var href = link.getAttribute('href');\n      if (!href || href.charAt(0) !== '#') return;\n      var target = document.getElementById(href.substring(1));\n      if (target) {\n        e.preventDefault();\n        var offset = 80;\n        var top = target.getBoundingClientRect().top + window.pageYOffset - offset;\n        window.scrollTo({ top: top, behavior: 'smooth' });\n      }\n    });\n  });\n\n  var sectionIds = [];\n  links.forEach(function(link){\n    var href = link.getAttribute('href');\n    if (href &#038;&#038; href.charAt(0) === '#') sectionIds.push(href.substring(1));\n  });\n\n  function updateActive(){\n    var scrollY = window.pageYOffset + 120;\n    var activeId = null;\n    var readIds = [];\n    sectionIds.forEach(function(id){\n      var el = document.getElementById(id);\n      if (el) {\n        var top = el.getBoundingClientRect().top + window.pageYOffset;\n        if (top <= scrollY) {\n          activeId = id;\n          readIds.push(id);\n        }\n      }\n    });\n    links.forEach(function(link){\n      var href = link.getAttribute('href');\n      var id = href ? href.substring(1) : '';\n      link.classList.remove('utc-active', 'utc-read');\n      if (id === activeId) {\n        link.classList.add('utc-active');\n      } else if (readIds.indexOf(id) !== -1) {\n        link.classList.add('utc-read');\n      }\n    });\n  }\n\n  if ('IntersectionObserver' in window) {\n    var observer = new IntersectionObserver(function(){\n      updateActive();\n    }, { rootMargin: '-120px 0px -60% 0px' });\n    sectionIds.forEach(function(id){\n      var el = document.getElementById(id);\n      if (el) observer.observe(el);\n    });\n  }\n  window.addEventListener('scroll', updateActive, { passive: true });\n  updateActive();\n})();\n<\/script><\/p>\n<p>[\/et_pb_code]<br \/>\n[\/et_pb_column]<br \/>\n[\/et_pb_row]<br \/>\n[\/et_pb_section]<br \/>\n[et_pb_section fb_built=\"1\" _builder_version=\"4.27.3\" background_color=\"transparent\" custom_padding=\"0px|0px|0px|0px|false|false\" global_colors_info=\"{}\"]<br \/>\n[et_pb_row _builder_version=\"4.27.3\" background_color=\"transparent\" custom_padding=\"0px|0px|0px|0px|false|false\" global_colors_info=\"{}\"]<br \/>\n[et_pb_column type=\"4_4\" _builder_version=\"4.27.3\" global_colors_info=\"{}\"]<br \/>\n[et_pb_code _builder_version=\"4.27.3\" global_colors_info=\"{}\"]\n<link href=\"https:\/\/fonts.googleapis.com\/css2?family=Inter:wght@400;500;600;700&#038;family=Poppins:wght@700;800&#038;display=swap\" rel=\"stylesheet\">\n<style>\n#unipile-typ-hero,\n#unipile-typ-hero *,\n#unipile-typ-hero *::before,\n#unipile-typ-hero *::after {\n  margin: 0 !important;\n  padding: 0 !important;\n  box-sizing: border-box !important;\n  border: none !important;\n  outline: none !important;\n  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;\n  line-height: 1.5 !important;\n  letter-spacing: normal !important;\n  text-transform: none !important;\n  text-decoration: none !important;\n  list-style: none !important;\n  background: transparent !important;\n}\n#unipile-typ-hero {\n  background: transparent !important;\n  display: block !important;\n  width: 100% !important;\n  overflow-x: hidden !important;\n}\n#unipile-typ-hero p { display: contents !important; }\n#unipile-typ-hero br { display: none !important; }\n#unipile-typ-hero .typh-wrap {\n  max-width: 1100px !important;\n  margin: 0 auto !important;\n  padding: 60px 20px 50px !important;\n  display: grid !important;\n  grid-template-columns: 1fr 1fr !important;\n  gap: 48px !important;\n  align-items: center !important;\n}\n#unipile-typ-hero .typh-badge {\n  display: inline-flex !important;\n  align-items: center !important;\n  gap: 8px !important;\n  background: rgba(59, 185, 139, 0.12) !important;\n  color: #2aaa7e !important;\n  padding: 6px 14px !important;\n  border-radius: 20px !important;\n  font-size: 12px !important;\n  font-weight: 700 !important;\n  text-transform: uppercase !important;\n  letter-spacing: 0.5px !important;\n  margin-bottom: 20px !important;\n}\n#unipile-typ-hero .typh-badge-dot {\n  width: 7px !important;\n  height: 7px !important;\n  background: #3BB98B !important;\n  border-radius: 50% !important;\n  flex-shrink: 0 !important;\n  display: inline-block !important;\n}\n#unipile-typ-hero .typh-h1 {\n  font-family: 'Poppins', sans-serif !important;\n  font-size: 42px !important;\n  font-weight: 700 !important;\n  color: #0f2736 !important;\n  line-height: 1.18 !important;\n  margin-bottom: 20px !important;\n}\n#unipile-typ-hero .typh-accent {\n  color: #3BB98B !important;\n}\n#unipile-typ-hero .typh-desc {\n  font-size: 17px !important;\n  line-height: 1.75 !important;\n  color: #383838 !important;\n  margin-bottom: 32px !important;\n}\n#unipile-typ-hero .typh-desc code {\n  font-family: 'Courier New', monospace !important;\n  background: rgba(15, 39, 54, 0.06) !important;\n  padding: 2px 6px !important;\n  border-radius: 4px !important;\n  font-size: 15px !important;\n}\n#unipile-typ-hero .typh-actions {\n  display: flex !important;\n  align-items: center !important;\n  gap: 14px !important;\n  flex-wrap: wrap !important;\n}\n#unipile-typ-hero .typh-cta-primary {\n  display: inline-flex !important;\n  align-items: center !important;\n  gap: 8px !important;\n  background: #DDDF4C !important;\n  color: #0f2736 !important;\n  padding: 14px 24px !important;\n  border-radius: 8px !important;\n  font-size: 15px !important;\n  font-weight: 600 !important;\n  border: 2px solid #DDDF4C !important;\n  cursor: pointer !important;\n  white-space: nowrap !important;\n  transition: transform 0.25s ease !important;\n  text-decoration: none !important;\n}\n#unipile-typ-hero .typh-cta-primary:hover {\n  transform: translateY(-5px) !important;\n}\n#unipile-typ-hero .typh-cta-primary svg {\n  width: 16px !important;\n  height: 16px !important;\n  stroke: currentColor !important;\n  fill: none !important;\n  stroke-width: 2.5 !important;\n  stroke-linecap: round !important;\n  stroke-linejoin: round !important;\n  flex-shrink: 0 !important;\n}\n#unipile-typ-hero .typh-cta-secondary {\n  display: inline-flex !important;\n  align-items: center !important;\n  gap: 8px !important;\n  background: transparent !important;\n  color: #0f2736 !important;\n  padding: 12px 22px !important;\n  border-radius: 8px !important;\n  font-size: 15px !important;\n  font-weight: 600 !important;\n  border: 2px solid #0f2736 !important;\n  cursor: pointer !important;\n  white-space: nowrap !important;\n  transition: all 0.25s ease !important;\n  text-decoration: none !important;\n}\n#unipile-typ-hero .typh-cta-secondary:hover {\n  background: #0f2736 !important;\n  color: #ffffff !important;\n}\n#unipile-typ-hero .typh-hero-right {}\n#unipile-typ-hero .typh-code-wrap {\n  border-radius: 14px !important;\n  overflow: hidden !important;\n  background: #0d1117 !important;\n}\n#unipile-typ-hero .typh-editor-bar {\n  background: #161b22 !important;\n  padding: 12px 18px !important;\n  display: flex !important;\n  align-items: center !important;\n  gap: 8px !important;\n  border-bottom: 1px solid rgba(255,255,255,0.06) !important;\n}\n#unipile-typ-hero .typh-dot {\n  width: 12px !important;\n  height: 12px !important;\n  border-radius: 50% !important;\n  display: inline-block !important;\n  flex-shrink: 0 !important;\n}\n#unipile-typ-hero .typh-dot-r { background: #ff5f57 !important; }\n#unipile-typ-hero .typh-dot-y { background: #febc2e !important; }\n#unipile-typ-hero .typh-dot-g { background: #28c840 !important; }\n#unipile-typ-hero .typh-filename {\n  color: #8b949e !important;\n  font-size: 13px !important;\n  margin-left: 6px !important;\n  font-family: 'Courier New', monospace !important;\n}\n#unipile-typ-hero .typh-pre {\n  padding: 22px 24px !important;\n  font-size: 12.5px !important;\n  line-height: 1.75 !important;\n  overflow-x: auto !important;\n  background: #0d1117 !important;\n  white-space: pre-wrap !important;\n  word-break: break-word !important;\n}\n#unipile-typ-hero .typh-pre code {\n  font-family: 'Courier New', monospace !important;\n  white-space: pre-wrap !important;\n  display: block !important;\n  word-break: break-word !important;\n}\n#unipile-typ-hero .c { color: #8b949e !important; }\n#unipile-typ-hero .k { color: #ff7b72 !important; }\n#unipile-typ-hero .fn { color: #d2a8ff !important; }\n#unipile-typ-hero .s { color: #a5d6ff !important; }\n#unipile-typ-hero .n { color: #79c0ff !important; }\n#unipile-typ-hero .w { color: #e6edf3 !important; }\n#unipile-typ-hero .typh-editor-ok {\n  background: rgba(59, 185, 139, 0.1) !important;\n  border-top: 1px solid rgba(59, 185, 139, 0.25) !important;\n  color: #3BB98B !important;\n  padding: 11px 24px !important;\n  font-size: 12.5px !important;\n  font-family: 'Courier New', monospace !important;\n  display: flex !important;\n  align-items: center !important;\n  gap: 8px !important;\n}\n#unipile-typ-hero .typh-ok-dot {\n  width: 7px !important;\n  height: 7px !important;\n  background: #3BB98B !important;\n  border-radius: 50% !important;\n  flex-shrink: 0 !important;\n  display: inline-block !important;\n}\n@media (max-width: 900px) {\n  #unipile-typ-hero .typh-wrap {\n    grid-template-columns: 1fr !important;\n    gap: 36px !important;\n    padding: 50px 20px 40px !important;\n  }\n  #unipile-typ-hero .typh-h1 {\n    font-size: 32px !important;\n  }\n}\n@media (max-width: 600px) {\n  #unipile-typ-hero .typh-wrap {\n    padding: 40px 16px 32px !important;\n  }\n  #unipile-typ-hero .typh-h1 {\n    font-size: 27px !important;\n  }\n  #unipile-typ-hero .typh-desc {\n    font-size: 16px !important;\n  }\n  #unipile-typ-hero .typh-actions {\n    flex-direction: column !important;\n    width: 100% !important;\n  }\n  #unipile-typ-hero .typh-cta-primary,\n  #unipile-typ-hero .typh-cta-secondary {\n    width: 100% !important;\n    justify-content: center !important;\n  }\n  #unipile-typ-hero .typh-pre {\n    font-size: 11.5px !important;\n    padding: 16px !important;\n  }\n}\n@media (max-width: 400px) {\n  #unipile-typ-hero .typh-h1 {\n    font-size: 25px !important;\n  }\n}\n<\/style>\n<div id=\"unipile-typ-hero\">\n<div class=\"typh-wrap\">\n<div class=\"typh-hero-left\">\n<div class=\"typh-badge\"><span class=\"typh-badge-dot\"><\/span><span>Python Implementation Guide<\/span><\/div>\n<h1 class=\"typh-h1\">The <span class=\"typh-accent\">Telegram API Python<\/span> guide: working code for every approach<\/h1>\n<div class=\"typh-desc\">A code-first walkthrough of the <strong style=\"color:#0f2736;\">Python Telegram Bot API<\/strong>: the <code>sendMessage<\/code> call with <code>requests<\/code>, a minimal bot with <code>python-telegram-bot<\/code>, a real linked account with Telethon, Pyrogram, or the Unipile SDK, and how to handle rate limits without your script crashing on the first <code>429<\/code>. Whether you landed here looking for a <strong style=\"color:#0f2736;\">telegram bot api python<\/strong> example or the full <strong style=\"color:#0f2736;\">telegram api python<\/strong> picture, every approach below ships with working code.<\/div>\n<div class=\"typh-actions\">\n        <a class=\"typh-cta-primary\" href=\"https:\/\/dashboard.unipile.com\/signup\/\" target=\"_blank\" rel=\"noopener\"><br \/>\n          <svg viewBox=\"0 0 24 24\"><line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\"\/><polyline points=\"12 5 19 12 12 19\"\/><\/svg><br \/>\n          <span>Build with Unipile<\/span><br \/>\n        <\/a><br \/>\n        <a class=\"typh-cta-secondary\" href=\"https:\/\/developer.unipile.com\/docs\/getting-started\" target=\"_blank\" rel=\"noopener\"><br \/>\n          <span>Read the docs<\/span><br \/>\n        <\/a>\n      <\/div>\n<\/p><\/div>\n<div class=\"typh-hero-right\">\n<div class=\"typh-code-wrap\">\n<div class=\"typh-editor-bar\">\n          <span class=\"typh-dot typh-dot-r\"><\/span><br \/>\n          <span class=\"typh-dot typh-dot-y\"><\/span><br \/>\n          <span class=\"typh-dot typh-dot-g\"><\/span><br \/>\n          <span class=\"typh-filename\">telegram_bot.py<\/span>\n        <\/div>\n<div class=\"typh-pre\"><code><span class=\"k\">import<\/span> <span class=\"w\">requests<\/span>&#10;&#10;<span class=\"w\">TOKEN <\/span><span class=\"k\">=<\/span> <span class=\"s\">\"123456:ABC-your-bot-token\"<\/span>&#10;<span class=\"w\">url <\/span><span class=\"k\">=<\/span> <span class=\"s\">f\"https:\/\/api.telegram.org\/bot{TOKEN}\/sendMessage\"<\/span>&#10;&#10;<span class=\"w\">payload <\/span><span class=\"k\">=<\/span> <span class=\"w\">{<\/span>&#10;    <span class=\"s\">\"chat_id\"<\/span><span class=\"w\">: <\/span><span class=\"n\">123456789<\/span><span class=\"w\">,<\/span>&#10;    <span class=\"s\">\"text\"<\/span><span class=\"w\">: <\/span><span class=\"s\">\"Hello from Python\"<\/span><span class=\"w\">,<\/span>&#10;    <span class=\"s\">\"parse_mode\"<\/span><span class=\"w\">: <\/span><span class=\"s\">\"MarkdownV2\"<\/span>&#10;<span class=\"w\">}<\/span>&#10;&#10;<span class=\"w\">response <\/span><span class=\"k\">=<\/span> <span class=\"w\">requests.<\/span><span class=\"fn\">post<\/span><span class=\"w\">(url, json=payload)<\/span>&#10;<span class=\"fn\">print<\/span><span class=\"w\">(response.<\/span><span class=\"fn\">json<\/span><span class=\"w\">())<\/span><\/code><\/div>\n<div class=\"typh-editor-ok\"><span class=\"typh-ok-dot\"><\/span><span>200 OK: message sent<\/span><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/div>\n<p>[\/et_pb_code]<br \/>\n[\/et_pb_column]<br \/>\n[\/et_pb_row]<br \/>\n[\/et_pb_section]<br \/>\n[et_pb_section fb_built=\"1\" _builder_version=\"4.27.3\" background_color=\"transparent\" custom_padding=\"0px|0px|0px|0px|false|false\" global_colors_info=\"{}\"]<br \/>\n[et_pb_row _builder_version=\"4.27.3\" background_color=\"transparent\" custom_padding=\"0px|0px|0px|0px|false|false\" global_colors_info=\"{}\"]<br \/>\n[et_pb_column type=\"4_4\" _builder_version=\"4.27.3\" global_colors_info=\"{}\"]<br \/>\n[et_pb_code _builder_version=\"4.27.3\" global_colors_info=\"{}\"]\n<link href=\"https:\/\/fonts.googleapis.com\/css2?family=Inter:wght@400;500;600;700&#038;family=Poppins:wght@700;800&#038;display=swap\" rel=\"stylesheet\">\n<style>\n#unipile-typ-paths,\n#unipile-typ-paths *,\n#unipile-typ-paths *::before,\n#unipile-typ-paths *::after {\n  margin: 0 !important;\n  padding: 0 !important;\n  box-sizing: border-box !important;\n  border: none !important;\n  outline: none !important;\n  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;\n  line-height: 1.5 !important;\n  letter-spacing: normal !important;\n  text-transform: none !important;\n  text-decoration: none !important;\n  list-style: none !important;\n  background: transparent !important;\n}\n#unipile-typ-paths {\n  background: transparent !important;\n  display: block !important;\n  width: 100% !important;\n  overflow-x: hidden !important;\n}\n#unipile-typ-paths p { display: contents !important; }\n#unipile-typ-paths br { display: none !important; }\n#unipile-typ-paths .typp-wrap {\n  max-width: 1100px !important;\n  margin: 0 auto !important;\n  padding: 70px 20px !important;\n}\n#unipile-typ-paths .typp-badge {\n  display: inline-flex !important;\n  align-items: center !important;\n  gap: 8px !important;\n  background: rgba(59, 185, 139, 0.12) !important;\n  color: #2aaa7e !important;\n  padding: 6px 14px !important;\n  border-radius: 20px !important;\n  font-size: 12px !important;\n  font-weight: 700 !important;\n  text-transform: uppercase !important;\n  letter-spacing: 0.5px !important;\n  margin-bottom: 18px !important;\n}\n#unipile-typ-paths .typp-badge-dot {\n  width: 7px !important;\n  height: 7px !important;\n  background: #3BB98B !important;\n  border-radius: 50% !important;\n  flex-shrink: 0 !important;\n  display: inline-block !important;\n}\n#unipile-typ-paths h2 {\n  font-family: 'Poppins', sans-serif !important;\n  font-size: 35px !important;\n  font-weight: 700 !important;\n  color: #0f2736 !important;\n  line-height: 1.2 !important;\n  margin-bottom: 16px !important;\n}\n#unipile-typ-paths .typp-lead {\n  font-size: 17px !important;\n  line-height: 1.75 !important;\n  color: #383838 !important;\n  margin-bottom: 40px !important;\n}\n#unipile-typ-paths .typp-lead code {\n  font-family: 'Courier New', monospace !important;\n  background: rgba(15, 39, 54, 0.06) !important;\n  padding: 2px 6px !important;\n  border-radius: 4px !important;\n  font-size: 15px !important;\n}\n#unipile-typ-paths .typp-grid {\n  display: grid !important;\n  grid-template-columns: repeat(3, 1fr) !important;\n  gap: 20px !important;\n  margin-bottom: 32px !important;\n}\n#unipile-typ-paths .typp-card {\n  background: #ffffff !important;\n  border: 1px solid #e5e7eb !important;\n  border-radius: 16px !important;\n  padding: 26px !important;\n  display: flex !important;\n  flex-direction: column !important;\n}\n#unipile-typ-paths .typp-card.typp-best {\n  border-color: #3BB98B !important;\n  box-shadow: 0 8px 24px rgba(59, 185, 139, 0.10) !important;\n}\n#unipile-typ-paths .typp-icon {\n  width: 40px !important;\n  height: 40px !important;\n  border-radius: 10px !important;\n  background: rgba(59, 185, 139, 0.12) !important;\n  display: flex !important;\n  align-items: center !important;\n  justify-content: center !important;\n  margin-bottom: 16px !important;\n}\n#unipile-typ-paths .typp-icon svg {\n  width: 20px !important;\n  height: 20px !important;\n  stroke: #2aaa7e !important;\n  fill: none !important;\n  stroke-width: 2 !important;\n  stroke-linecap: round !important;\n  stroke-linejoin: round !important;\n}\n#unipile-typ-paths .typp-card-title {\n  font-family: 'Poppins', sans-serif !important;\n  font-size: 17px !important;\n  font-weight: 700 !important;\n  color: #0f2736 !important;\n  margin-bottom: 10px !important;\n  display: flex !important;\n  align-items: center !important;\n  gap: 8px !important;\n  flex-wrap: wrap !important;\n}\n#unipile-typ-paths .typp-card-title code {\n  font-family: 'Courier New', monospace !important;\n  background: rgba(15, 39, 54, 0.06) !important;\n  padding: 1px 6px !important;\n  border-radius: 4px !important;\n  font-size: 14px !important;\n  font-weight: 500 !important;\n}\n#unipile-typ-paths .typp-pill {\n  display: inline-block !important;\n  font-size: 9px !important;\n  font-weight: 700 !important;\n  color: #ffffff !important;\n  background: #3BB98B !important;\n  padding: 3px 8px !important;\n  border-radius: 4px !important;\n  text-transform: uppercase !important;\n  letter-spacing: 0.5px !important;\n}\n#unipile-typ-paths .typp-card-text {\n  font-size: 14.5px !important;\n  line-height: 1.68 !important;\n  color: #4a5568 !important;\n  margin-bottom: 14px !important;\n  flex: 1 !important;\n}\n#unipile-typ-paths .typp-card-text code {\n  font-family: 'Courier New', monospace !important;\n  background: rgba(15, 39, 54, 0.06) !important;\n  padding: 1px 5px !important;\n  border-radius: 4px !important;\n  font-size: 13px !important;\n}\n#unipile-typ-paths .typp-tag {\n  font-size: 12px !important;\n  font-weight: 600 !important;\n  color: #8a8c2e !important;\n  background: rgba(221, 223, 76, 0.18) !important;\n  padding: 5px 10px !important;\n  border-radius: 6px !important;\n  width: fit-content !important;\n}\n#unipile-typ-paths .typp-note {\n  background: #f4f5f7 !important;\n  border-radius: 12px !important;\n  padding: 18px 22px !important;\n  font-size: 14.5px !important;\n  line-height: 1.7 !important;\n  color: #4a5568 !important;\n  margin-bottom: 32px !important;\n}\n#unipile-typ-paths .typp-note a,\n#unipile-typ-paths .typp-link {\n  color: #2aaa7e !important;\n  text-decoration: underline !important;\n  font-weight: 600 !important;\n  cursor: pointer !important;\n}\n#unipile-typ-paths .typp-cta {\n  display: inline-flex !important;\n  align-items: center !important;\n  gap: 8px !important;\n  background: #DDDF4C !important;\n  color: #0f2736 !important;\n  padding: 13px 22px !important;\n  border-radius: 8px !important;\n  font-size: 14.5px !important;\n  font-weight: 600 !important;\n  border: 2px solid #DDDF4C !important;\n  cursor: pointer !important;\n  white-space: nowrap !important;\n  transition: transform 0.25s ease !important;\n  text-decoration: none !important;\n}\n#unipile-typ-paths .typp-cta:hover {\n  transform: translateY(-5px) !important;\n}\n#unipile-typ-paths .typp-cta svg {\n  width: 15px !important;\n  height: 15px !important;\n  stroke: currentColor !important;\n  fill: none !important;\n  stroke-width: 2.5 !important;\n  stroke-linecap: round !important;\n  stroke-linejoin: round !important;\n  flex-shrink: 0 !important;\n}\n@media (max-width: 900px) {\n  #unipile-typ-paths .typp-wrap { padding: 50px 20px !important; }\n  #unipile-typ-paths h2 { font-size: 28px !important; }\n  #unipile-typ-paths .typp-grid { grid-template-columns: 1fr !important; }\n}\n@media (max-width: 600px) {\n  #unipile-typ-paths .typp-wrap { padding: 40px 16px !important; }\n  #unipile-typ-paths h2 { font-size: 24px !important; }\n  #unipile-typ-paths .typp-lead { font-size: 16px !important; }\n  #unipile-typ-paths .typp-cta { width: 100% !important; justify-content: center !important; }\n}\n<\/style>\n<div id=\"unipile-typ-paths\">\n<div class=\"typp-wrap\">\n    <span id=\"typ-paths\" style=\"display:block;position:relative;top:-80px;visibility:hidden;\"><\/span><\/p>\n<div class=\"typp-badge\"><span class=\"typp-badge-dot\"><\/span><span>Decision Guide<\/span><\/div>\n<h2>Three ways to build the Telegram API in Python, and which one to pick<\/h2>\n<div class=\"typp-lead\">Once you have credentials, there are three concrete ways to talk to Telegram from a Python codebase. They are not interchangeable libraries for the same job: each one authenticates as a different kind of sender, with different code and different constraints.<\/div>\n<div class=\"typp-grid\">\n<div class=\"typp-card\">\n<div class=\"typp-icon\"><svg viewBox=\"0 0 24 24\"><rect x=\"3\" y=\"11\" width=\"18\" height=\"10\" rx=\"2\"\/><circle cx=\"12\" cy=\"5\" r=\"2\"\/><path d=\"M12 7v4\"\/><line x1=\"8\" y1=\"16\" x2=\"8\" y2=\"16\"\/><line x1=\"16\" y1=\"16\" x2=\"16\" y2=\"16\"\/><\/svg><\/div>\n<div class=\"typp-card-title\">Python Telegram Bot API<\/div>\n<div class=\"typp-card-text\">A bot token from BotFather, called from Python with <code>requests<\/code> or a wrapper library like <code>python-telegram-bot<\/code>. The fastest way to ship, but a bot can only message a user who has written to it first.<\/div>\n<p>        <span class=\"typp-tag\">Best for notifications and support bots<\/span>\n      <\/div>\n<div class=\"typp-card\">\n<div class=\"typp-icon\"><svg viewBox=\"0 0 24 24\"><rect x=\"4\" y=\"2\" width=\"16\" height=\"20\" rx=\"2\"\/><line x1=\"8\" y1=\"18\" x2=\"16\" y2=\"18\"\/><\/svg><\/div>\n<div class=\"typp-card-title\">Telethon \/ Pyrogram (MTProto)<\/div>\n<div class=\"typp-card-text\">A Python client library that speaks the raw Telegram protocol with your own <code>api_id<\/code> and <code>api_hash<\/code>. Logs in as a real account, but you own session storage, reconnects and the 2FA flow.<\/div>\n<p>        <span class=\"typp-tag\">Best for a fully custom Python client<\/span>\n      <\/div>\n<div class=\"typp-card typp-best\">\n<div class=\"typp-icon\"><svg viewBox=\"0 0 24 24\"><path d=\"M17 21v-2a4 4 0 00-4-4H5a4 4 0 00-4 4v2\"\/><circle cx=\"9\" cy=\"7\" r=\"4\"\/><path d=\"M23 21v-2a4 4 0 00-3-3.87\"\/><path d=\"M16 3.13a4 4 0 010 7.75\"\/><\/svg><\/div>\n<div class=\"typp-card-title\">Unipile Python SDK<span class=\"typp-pill\">Unipile<\/span><\/div>\n<div class=\"typp-card-text\">A linked account, called from Python with a few SDK lines instead of a raw MTProto client. No session files to persist, no 2FA branch to write yourself.<\/div>\n<p>        <span class=\"typp-tag\">Best for shipping fast without owning MTProto<\/span>\n      <\/div>\n<\/p><\/div>\n<div class=\"typp-note\">This section is about the Python code once you have credentials. For the full arbitration between the Bot API and the Telegram Client API (limits, identity, what each one can and cannot do), see our dedicated comparison: <a class=\"typp-link\" href=\"https:\/\/www.unipile.com\/telegram-bot-api-vs-telegram-api\/\" target=\"_self\">Telegram Bot API vs Telegram API<\/a>. For getting your bot token or <code>api_id<\/code> \/ <code>api_hash<\/code> in the first place, see the <a class=\"typp-link\" href=\"https:\/\/www.unipile.com\/how-to-get-telegram-api-the-ultimate-step-by-step-guide\/\" target=\"_self\">step-by-step access guide<\/a>.<\/div>\n<p>    <a class=\"typp-cta\" href=\"https:\/\/dashboard.unipile.com\/signup\/\" target=\"_blank\" rel=\"noopener\"><br \/>\n      <svg viewBox=\"0 0 24 24\"><line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\"\/><polyline points=\"12 5 19 12 12 19\"\/><\/svg><br \/>\n      <span>Build your Python integration<\/span><br \/>\n    <\/a>\n  <\/div>\n<\/div>\n<p><script>\n(function(){\n  var root = document.getElementById('unipile-typ-paths');\n  if (!root) return;\n  root.addEventListener('click', function(e){\n    var el = e.target.closest('[data-upl-link]');\n    if (!el) return;\n    e.preventDefault();\n    window.open(el.getAttribute('data-upl-link'), el.getAttribute('data-upl-target') || '_self');\n  });\n})();\n<\/script><\/p>\n<p>[\/et_pb_code]<br \/>\n[\/et_pb_column]<br \/>\n[\/et_pb_row]<br \/>\n[\/et_pb_section]<br \/>\n[et_pb_section fb_built=\"1\" _builder_version=\"4.27.3\" background_color=\"transparent\" custom_padding=\"0px|0px|0px|0px|false|false\" global_colors_info=\"{}\"]<br \/>\n[et_pb_row _builder_version=\"4.27.3\" background_color=\"transparent\" custom_padding=\"0px|0px|0px|0px|false|false\" global_colors_info=\"{}\"]<br \/>\n[et_pb_column type=\"4_4\" _builder_version=\"4.27.3\" global_colors_info=\"{}\"]<br \/>\n[et_pb_code _builder_version=\"4.27.3\" global_colors_info=\"{}\"]\n<link href=\"https:\/\/fonts.googleapis.com\/css2?family=Inter:wght@400;500;600;700&#038;family=Poppins:wght@700;800&#038;display=swap\" rel=\"stylesheet\">\n<style>\n#unipile-typ-requests,\n#unipile-typ-requests *,\n#unipile-typ-requests *::before,\n#unipile-typ-requests *::after {\n  margin: 0 !important;\n  padding: 0 !important;\n  box-sizing: border-box !important;\n  border: none !important;\n  outline: none !important;\n  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;\n  line-height: 1.5 !important;\n  letter-spacing: normal !important;\n  text-transform: none !important;\n  text-decoration: none !important;\n  list-style: none !important;\n  background: transparent !important;\n}\n#unipile-typ-requests {\n  background: transparent !important;\n  display: block !important;\n  width: 100% !important;\n  overflow-x: hidden !important;\n}\n#unipile-typ-requests p { display: contents !important; }\n#unipile-typ-requests br { display: none !important; }\n#unipile-typ-requests .typr-wrap {\n  max-width: 1100px !important;\n  margin: 0 auto !important;\n  padding: 70px 20px !important;\n}\n#unipile-typ-requests .typr-badge {\n  display: inline-flex !important;\n  align-items: center !important;\n  gap: 8px !important;\n  background: rgba(221, 223, 76, 0.18) !important;\n  color: #8a8c2e !important;\n  padding: 6px 14px !important;\n  border-radius: 20px !important;\n  font-size: 12px !important;\n  font-weight: 700 !important;\n  text-transform: uppercase !important;\n  letter-spacing: 0.5px !important;\n  margin-bottom: 18px !important;\n}\n#unipile-typ-requests .typr-badge-dot {\n  width: 7px !important;\n  height: 7px !important;\n  background: #DDDF4C !important;\n  border-radius: 50% !important;\n  flex-shrink: 0 !important;\n  display: inline-block !important;\n}\n#unipile-typ-requests h2 {\n  font-family: 'Poppins', sans-serif !important;\n  font-size: 35px !important;\n  font-weight: 700 !important;\n  color: #0f2736 !important;\n  line-height: 1.2 !important;\n  margin-bottom: 16px !important;\n}\n#unipile-typ-requests .typr-lead {\n  font-size: 17px !important;\n  line-height: 1.75 !important;\n  color: #383838 !important;\n  margin-bottom: 32px !important;\n}\n#unipile-typ-requests .typr-lead code {\n  font-family: 'Courier New', monospace !important;\n  background: rgba(15, 39, 54, 0.06) !important;\n  padding: 2px 6px !important;\n  border-radius: 4px !important;\n  font-size: 15px !important;\n}\n#unipile-typ-requests .typr-steps {\n  display: flex !important;\n  flex-direction: column !important;\n  gap: 28px !important;\n  margin-bottom: 8px !important;\n}\n#unipile-typ-requests .typr-step {\n  display: flex !important;\n  gap: 20px !important;\n}\n#unipile-typ-requests .typr-step-num {\n  width: 40px !important;\n  height: 40px !important;\n  min-width: 40px !important;\n  background: rgba(221, 223, 76, 0.18) !important;\n  border-radius: 10px !important;\n  display: flex !important;\n  align-items: center !important;\n  justify-content: center !important;\n  font-family: 'Poppins', sans-serif !important;\n  font-size: 15px !important;\n  font-weight: 700 !important;\n  color: #8a8c2e !important;\n}\n#unipile-typ-requests .typr-step-body { flex: 1 !important; min-width: 0 !important; }\n#unipile-typ-requests .typr-step-title {\n  font-size: 16px !important;\n  font-weight: 700 !important;\n  color: #0f2736 !important;\n  margin-bottom: 10px !important;\n  display: block !important;\n}\n#unipile-typ-requests .typr-step-text {\n  font-size: 15px !important;\n  line-height: 1.75 !important;\n  color: #4a5568 !important;\n  margin-bottom: 14px !important;\n  display: block !important;\n}\n#unipile-typ-requests .typr-step-text code {\n  font-family: 'Courier New', monospace !important;\n  background: rgba(15, 39, 54, 0.06) !important;\n  padding: 1px 5px !important;\n  border-radius: 4px !important;\n  font-size: 13px !important;\n}\n#unipile-typ-requests .typr-code-wrap {\n  border-radius: 14px !important;\n  overflow: hidden !important;\n  background: #0d1117 !important;\n  margin-bottom: 8px !important;\n}\n#unipile-typ-requests .typr-editor-bar {\n  background: #161b22 !important;\n  padding: 12px 18px !important;\n  display: flex !important;\n  align-items: center !important;\n  gap: 8px !important;\n  border-bottom: 1px solid rgba(255,255,255,0.06) !important;\n}\n#unipile-typ-requests .typr-dot {\n  width: 12px !important;\n  height: 12px !important;\n  border-radius: 50% !important;\n  display: inline-block !important;\n  flex-shrink: 0 !important;\n}\n#unipile-typ-requests .typr-dot-r { background: #ff5f57 !important; }\n#unipile-typ-requests .typr-dot-y { background: #febc2e !important; }\n#unipile-typ-requests .typr-dot-g { background: #28c840 !important; }\n#unipile-typ-requests .typr-filename {\n  color: #8b949e !important;\n  font-size: 13px !important;\n  margin-left: 6px !important;\n  font-family: 'Courier New', monospace !important;\n}\n#unipile-typ-requests .typr-pre {\n  padding: 22px 24px !important;\n  font-size: 13px !important;\n  line-height: 1.8 !important;\n  overflow-x: auto !important;\n  background: #0d1117 !important;\n  white-space: pre-wrap !important;\n  word-break: break-word !important;\n}\n#unipile-typ-requests .typr-pre code {\n  font-family: 'Courier New', monospace !important;\n  white-space: pre-wrap !important;\n  display: block !important;\n  word-break: break-word !important;\n}\n#unipile-typ-requests .c { color: #8b949e !important; }\n#unipile-typ-requests .k { color: #ff7b72 !important; }\n#unipile-typ-requests .fn { color: #d2a8ff !important; }\n#unipile-typ-requests .s { color: #a5d6ff !important; }\n#unipile-typ-requests .n { color: #79c0ff !important; }\n#unipile-typ-requests .w { color: #e6edf3 !important; }\n\/* Params table *\/\n#unipile-typ-requests .typr-table-wrap {\n  background: #ffffff !important;\n  border: 1px solid #e5e7eb !important;\n  border-radius: 16px !important;\n  overflow: hidden !important;\n  margin: 28px 0 32px !important;\n}\n#unipile-typ-requests table { width: 100% !important; border-collapse: collapse !important; }\n#unipile-typ-requests thead tr { background: #f4f5f7 !important; }\n#unipile-typ-requests th {\n  text-align: left !important;\n  font-size: 12px !important;\n  font-weight: 700 !important;\n  color: #64748b !important;\n  text-transform: uppercase !important;\n  letter-spacing: 0.5px !important;\n  padding: 14px 20px !important;\n}\n#unipile-typ-requests td {\n  padding: 14px 20px !important;\n  font-size: 14px !important;\n  color: #383838 !important;\n  border-top: 1px solid #e5e7eb !important;\n  vertical-align: top !important;\n}\n#unipile-typ-requests td code {\n  font-family: 'Courier New', monospace !important;\n  background: rgba(15, 39, 54, 0.06) !important;\n  padding: 2px 6px !important;\n  border-radius: 4px !important;\n  font-size: 12.5px !important;\n  color: #0f2736 !important;\n}\n#unipile-typ-requests .typr-req {\n  display: inline-block !important;\n  font-size: 10px !important;\n  font-weight: 700 !important;\n  color: #ffffff !important;\n  background: #ef4444 !important;\n  padding: 2px 7px !important;\n  border-radius: 4px !important;\n  text-transform: uppercase !important;\n}\n#unipile-typ-requests .typr-opt {\n  display: inline-block !important;\n  font-size: 10px !important;\n  font-weight: 700 !important;\n  color: #64748b !important;\n  background: #e2e8f0 !important;\n  padding: 2px 7px !important;\n  border-radius: 4px !important;\n  text-transform: uppercase !important;\n}\n#unipile-typ-requests .typr-cta {\n  display: inline-flex !important;\n  align-items: center !important;\n  gap: 8px !important;\n  background: #DDDF4C !important;\n  color: #0f2736 !important;\n  padding: 13px 22px !important;\n  border-radius: 8px !important;\n  font-size: 14.5px !important;\n  font-weight: 600 !important;\n  border: 2px solid #DDDF4C !important;\n  cursor: pointer !important;\n  white-space: nowrap !important;\n  transition: transform 0.25s ease !important;\n  text-decoration: none !important;\n}\n#unipile-typ-requests .typr-cta:hover { transform: translateY(-5px) !important; }\n#unipile-typ-requests .typr-cta svg {\n  width: 15px !important;\n  height: 15px !important;\n  stroke: currentColor !important;\n  fill: none !important;\n  stroke-width: 2.5 !important;\n  stroke-linecap: round !important;\n  stroke-linejoin: round !important;\n  flex-shrink: 0 !important;\n}\n@media (max-width: 900px) {\n  #unipile-typ-requests .typr-wrap { padding: 50px 20px !important; }\n  #unipile-typ-requests h2 { font-size: 28px !important; }\n}\n@media (max-width: 600px) {\n  #unipile-typ-requests .typr-wrap { padding: 40px 16px !important; }\n  #unipile-typ-requests h2 { font-size: 24px !important; }\n  #unipile-typ-requests .typr-lead { font-size: 16px !important; }\n  #unipile-typ-requests .typr-step { flex-direction: column !important; gap: 12px !important; }\n  #unipile-typ-requests .typr-pre { font-size: 12px !important; padding: 16px !important; }\n  #unipile-typ-requests .typr-cta { width: 100% !important; justify-content: center !important; }\n  \/* Table -> stacked cards on mobile (no horizontal scroll) *\/\n  #unipile-typ-requests table, #unipile-typ-requests thead, #unipile-typ-requests tbody,\n  #unipile-typ-requests th, #unipile-typ-requests td, #unipile-typ-requests tr {\n    display: block !important;\n    width: 100% !important;\n  }\n  #unipile-typ-requests thead { display: none !important; }\n  #unipile-typ-requests tr {\n    border-top: 1px solid #e5e7eb !important;\n    padding: 14px 16px !important;\n  }\n  #unipile-typ-requests tr:first-child { border-top: none !important; }\n  #unipile-typ-requests td {\n    padding: 4px 0 !important;\n    border-top: none !important;\n    font-size: 13px !important;\n  }\n  #unipile-typ-requests td::before {\n    content: attr(data-label) !important;\n    display: block !important;\n    font-size: 10.5px !important;\n    font-weight: 700 !important;\n    color: #94a3b8 !important;\n    text-transform: uppercase !important;\n    letter-spacing: 0.5px !important;\n    margin-bottom: 3px !important;\n  }\n}\n<\/style>\n<div id=\"unipile-typ-requests\">\n<div class=\"typr-wrap\">\n    <span id=\"typ-requests\" style=\"display:block;position:relative;top:-80px;visibility:hidden;\"><\/span><\/p>\n<div class=\"typr-badge\"><span class=\"typr-badge-dot\"><\/span><span>Code Tutorial<\/span><\/div>\n<h2>The Python Telegram Bot API with requests<\/h2>\n<div class=\"typr-lead\">The most direct way to call the <strong style=\"color:#0f2736;\">Telegram Bot API in Python<\/strong> is a plain HTTP call with <code>requests<\/code>, no wrapper library involved. As of Bot API 10.2 (July 14, 2026), a bot token from BotFather and two parameters are all that <code>sendMessage<\/code> requires.<\/div>\n<div class=\"typr-steps\">\n<div class=\"typr-step\">\n<div class=\"typr-step-num\">1<\/div>\n<div class=\"typr-step-body\">\n          <span class=\"typr-step-title\">Get a bot token, then call sendMessage<\/span><\/p>\n<div class=\"typr-step-text\">BotFather issues a token shaped like <code>123456:ABC-your-bot-token<\/code>. Every Bot API call, including <code>sendMessage<\/code>, is a <code>POST<\/code> to <code>https:\/\/api.telegram.org\/bot&lt;TOKEN&gt;\/sendMessage<\/code> with a JSON body.<\/div>\n<div class=\"typr-code-wrap\">\n<div class=\"typr-editor-bar\">\n              <span class=\"typr-dot typr-dot-r\"><\/span><br \/>\n              <span class=\"typr-dot typr-dot-y\"><\/span><br \/>\n              <span class=\"typr-dot typr-dot-g\"><\/span><br \/>\n              <span class=\"typr-filename\">send_message.py<\/span>\n            <\/div>\n<div class=\"typr-pre\"><code><span class=\"k\">import<\/span> <span class=\"w\">os<\/span>&#10;<span class=\"k\">import<\/span> <span class=\"w\">requests<\/span>&#10;&#10;<span class=\"w\">TOKEN <\/span><span class=\"k\">=<\/span> <span class=\"w\">os.<\/span><span class=\"fn\">environ<\/span><span class=\"w\">[<\/span><span class=\"s\">\"TELEGRAM_BOT_TOKEN\"<\/span><span class=\"w\">]<\/span>&#10;<span class=\"w\">URL <\/span><span class=\"k\">=<\/span> <span class=\"s\">f\"https:\/\/api.telegram.org\/bot{TOKEN}\/sendMessage\"<\/span>&#10;&#10;<span class=\"w\">payload <\/span><span class=\"k\">=<\/span> <span class=\"w\">{<\/span>&#10;    <span class=\"s\">\"chat_id\"<\/span><span class=\"w\">: <\/span><span class=\"n\">123456789<\/span><span class=\"w\">,<\/span>&#10;    <span class=\"s\">\"text\"<\/span><span class=\"w\">: <\/span><span class=\"s\">\"Your order #4821 has shipped.\"<\/span><span class=\"w\">,<\/span>&#10;    <span class=\"s\">\"parse_mode\"<\/span><span class=\"w\">: <\/span><span class=\"s\">\"MarkdownV2\"<\/span>&#10;<span class=\"w\">}<\/span>&#10;&#10;<span class=\"w\">response <\/span><span class=\"k\">=<\/span> <span class=\"w\">requests.<\/span><span class=\"fn\">post<\/span><span class=\"w\">(URL, json=payload, timeout=10)<\/span><\/code><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div class=\"typr-step\">\n<div class=\"typr-step-num\">2<\/div>\n<div class=\"typr-step-body\">\n          <span class=\"typr-step-title\">Check the response, don't assume it worked<\/span><\/p>\n<div class=\"typr-step-text\">The Bot API always answers with a JSON body containing an <code>ok<\/code> boolean. A non-200 status code or <code>ok: false<\/code> means the message was not sent, and the payload includes a human-readable <code>description<\/code> to log.<\/div>\n<div class=\"typr-code-wrap\">\n<div class=\"typr-editor-bar\">\n              <span class=\"typr-dot typr-dot-r\"><\/span><br \/>\n              <span class=\"typr-dot typr-dot-y\"><\/span><br \/>\n              <span class=\"typr-dot typr-dot-g\"><\/span><br \/>\n              <span class=\"typr-filename\">send_message.py<\/span>\n            <\/div>\n<div class=\"typr-pre\"><code><span class=\"w\">data <\/span><span class=\"k\">=<\/span> <span class=\"w\">response.<\/span><span class=\"fn\">json<\/span><span class=\"w\">()<\/span>&#10;&#10;<span class=\"k\">if<\/span> <span class=\"w\">response.status_code <\/span><span class=\"k\">==<\/span> <span class=\"n\">200<\/span> <span class=\"k\">and<\/span> <span class=\"w\">data.<\/span><span class=\"fn\">get<\/span><span class=\"w\">(<\/span><span class=\"s\">\"ok\"<\/span><span class=\"w\">):<\/span>&#10;    <span class=\"w\">message_id <\/span><span class=\"k\">=<\/span> <span class=\"w\">data[<\/span><span class=\"s\">\"result\"<\/span><span class=\"w\">][<\/span><span class=\"s\">\"message_id\"<\/span><span class=\"w\">]<\/span>&#10;    <span class=\"fn\">print<\/span><span class=\"w\">(<\/span><span class=\"s\">f\"sent, message_id={message_id}\"<\/span><span class=\"w\">)<\/span>&#10;<span class=\"k\">else<\/span><span class=\"w\">:<\/span>&#10;    <span class=\"fn\">print<\/span><span class=\"w\">(<\/span><span class=\"s\">f\"failed: {data.get('description')}\"<\/span><span class=\"w\">)<\/span><\/code><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div class=\"typr-table-wrap\">\n<table>\n<thead>\n<tr>\n<th>Parameter<\/th>\n<th>Type<\/th>\n<th>Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td data-label=\"Parameter\"><code>chat_id<\/code> <span class=\"typr-req\">Required<\/span><\/td>\n<td data-label=\"Type\">int or str<\/td>\n<td data-label=\"Description\">Target chat identifier, or <code>@username<\/code> for a public channel.<\/td>\n<\/tr>\n<tr>\n<td data-label=\"Parameter\"><code>text<\/code> <span class=\"typr-req\">Required<\/span><\/td>\n<td data-label=\"Type\">str<\/td>\n<td data-label=\"Description\">Message text, 1 to 4096 characters after entity parsing.<\/td>\n<\/tr>\n<tr>\n<td data-label=\"Parameter\"><code>parse_mode<\/code> <span class=\"typr-opt\">Optional<\/span><\/td>\n<td data-label=\"Type\">str<\/td>\n<td data-label=\"Description\"><code>MarkdownV2<\/code> or <code>HTML<\/code>, to render bold, links and code formatting in the text.<\/td>\n<\/tr>\n<tr>\n<td data-label=\"Parameter\"><code>disable_notification<\/code> <span class=\"typr-opt\">Optional<\/span><\/td>\n<td data-label=\"Type\">bool<\/td>\n<td data-label=\"Description\">Sends the message silently, without a push notification sound.<\/td>\n<\/tr>\n<tr>\n<td data-label=\"Parameter\"><code>reply_parameters<\/code> <span class=\"typr-opt\">Optional<\/span><\/td>\n<td data-label=\"Type\">dict<\/td>\n<td data-label=\"Description\">Sends the message as a reply to an existing message in the chat.<\/td>\n<\/tr>\n<\/tbody>\n<\/table><\/div>\n<p>    <a class=\"typr-cta\" href=\"https:\/\/dashboard.unipile.com\/signup\/\" target=\"_blank\" rel=\"noopener\"><br \/>\n      <svg viewBox=\"0 0 24 24\"><line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\"\/><polyline points=\"12 5 19 12 12 19\"\/><\/svg><br \/>\n      <span>Build past the bot-only limit<\/span><br \/>\n    <\/a>\n  <\/div>\n<\/div>\n<p>[\/et_pb_code]<br \/>\n[\/et_pb_column]<br \/>\n[\/et_pb_row]<br \/>\n[\/et_pb_section]<br \/>\n[et_pb_section fb_built=\"1\" _builder_version=\"4.27.3\" background_color=\"transparent\" custom_padding=\"0px|0px|0px|0px|false|false\" global_colors_info=\"{}\"]<br \/>\n[et_pb_row _builder_version=\"4.27.3\" background_color=\"transparent\" custom_padding=\"0px|0px|0px|0px|false|false\" global_colors_info=\"{}\"]<br \/>\n[et_pb_column type=\"4_4\" _builder_version=\"4.27.3\" global_colors_info=\"{}\"]<br \/>\n[et_pb_code _builder_version=\"4.27.3\" global_colors_info=\"{}\"]\n<link href=\"https:\/\/fonts.googleapis.com\/css2?family=Inter:wght@400;500;600;700&#038;family=Poppins:wght@700;800&#038;display=swap\" rel=\"stylesheet\">\n<style>\n#unipile-typ-ptb,\n#unipile-typ-ptb *,\n#unipile-typ-ptb *::before,\n#unipile-typ-ptb *::after {\n  margin: 0 !important;\n  padding: 0 !important;\n  box-sizing: border-box !important;\n  border: none !important;\n  outline: none !important;\n  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;\n  line-height: normal !important;\n  letter-spacing: normal !important;\n  text-transform: none !important;\n  text-decoration: none !important;\n  list-style: none !important;\n  background: transparent !important;\n}\n#unipile-typ-ptb { display: block !important; overflow-x: hidden !important; max-width: 100% !important; }\n#unipile-typ-ptb br { display: none !important; }\n#unipile-typ-ptb p { display: contents !important; }\n#unipile-typ-ptb .typtb-wrap { max-width: 1100px !important; margin: 0 auto !important; padding: 70px 24px !important; }\n#unipile-typ-ptb .typtb-anchor { display: block !important; position: relative !important; top: -80px !important; visibility: hidden !important; }\n#unipile-typ-ptb .typtb-badge {\n  display: inline-flex !important; align-items: center !important; gap: 8px !important;\n  background: rgba(221, 223, 76, 0.18) !important; color: #8a8c2e !important;\n  padding: 6px 14px !important; border-radius: 20px !important; font-size: 12px !important;\n  font-weight: 700 !important; text-transform: uppercase !important; letter-spacing: 0.5px !important;\n  width: fit-content !important; margin-bottom: 18px !important;\n}\n#unipile-typ-ptb .typtb-badge .typtb-dot { width: 7px !important; height: 7px !important; background: #DDDF4C !important; border-radius: 50% !important; flex-shrink: 0 !important; display: block !important; }\n#unipile-typ-ptb h2 { font-family: 'Poppins', sans-serif !important; font-size: 35px !important; font-weight: 700 !important; color: #0f2736 !important; line-height: 1.2 !important; margin-bottom: 16px !important; }\n#unipile-typ-ptb .typtb-intro { font-size: 17px !important; line-height: 1.8 !important; color: #383838 !important; margin-bottom: 32px !important; display: block !important; }\n#unipile-typ-ptb .typtb-intro code { font-family: 'Courier New', monospace !important; background: #f4f5f7 !important; padding: 2px 6px !important; border-radius: 4px !important; font-size: 14.5px !important; color: #0f2736 !important; }<\/p>\n<p>#unipile-typ-ptb .typtb-grid { display: grid !important; grid-template-columns: 1fr 1fr !important; gap: 40px !important; align-items: start !important; }<\/p>\n<p>#unipile-typ-ptb .typtb-col-title { font-family: 'Poppins', sans-serif !important; font-size: 15px !important; font-weight: 700 !important; color: #0f2736 !important; margin-bottom: 14px !important; display: block !important; }\n#unipile-typ-ptb .typtb-checklist { display: flex !important; flex-direction: column !important; gap: 10px !important; margin-bottom: 22px !important; }\n#unipile-typ-ptb .typtb-check { display: flex !important; align-items: flex-start !important; gap: 10px !important; font-size: 14.5px !important; color: #383838 !important; line-height: 1.6 !important; }\n#unipile-typ-ptb .typtb-check svg { width: 16px !important; height: 16px !important; stroke: #3BB98B !important; fill: none !important; stroke-width: 2.5 !important; stroke-linecap: round !important; stroke-linejoin: round !important; flex-shrink: 0 !important; margin-top: 2px !important; }<\/p>\n<p>#unipile-typ-ptb .typtb-para { font-size: 15px !important; color: #4a5568 !important; line-height: 1.75 !important; display: block !important; }\n#unipile-typ-ptb .typtb-para strong { color: #0f2736 !important; font-weight: 700 !important; }\n#unipile-typ-ptb .typtb-para code { font-family: 'Courier New', monospace !important; background: #f4f5f7 !important; padding: 2px 6px !important; border-radius: 4px !important; font-size: 13.5px !important; color: #0f2736 !important; }<\/p>\n<p>#unipile-typ-ptb .typtb-code-wrap { border-radius: 14px !important; overflow: hidden !important; background: #0d1117 !important; }\n#unipile-typ-ptb .typtb-editor-bar { background: #161b22 !important; padding: 12px 18px !important; display: flex !important; align-items: center !important; gap: 8px !important; border-bottom: 1px solid rgba(255,255,255,0.06) !important; }\n#unipile-typ-ptb .typtb-dot2 { width: 12px !important; height: 12px !important; border-radius: 50% !important; display: inline-block !important; flex-shrink: 0 !important; }\n#unipile-typ-ptb .typtb-dot-r { background: #ff5f57 !important; }\n#unipile-typ-ptb .typtb-dot-y { background: #febc2e !important; }\n#unipile-typ-ptb .typtb-dot-g { background: #28c840 !important; }\n#unipile-typ-ptb .typtb-filename { color: #8b949e !important; font-size: 13px !important; margin-left: 6px !important; font-family: 'Courier New', monospace !important; }\n#unipile-typ-ptb .typtb-pre { padding: 22px 24px !important; font-size: 12.5px !important; line-height: 1.8 !important; overflow-x: auto !important; background: #0d1117 !important; white-space: pre-wrap !important; word-break: break-word !important; }\n#unipile-typ-ptb .typtb-pre code { font-family: 'Courier New', monospace !important; white-space: pre-wrap !important; display: block !important; word-break: break-word !important; }\n#unipile-typ-ptb .c { color: #8b949e !important; }\n#unipile-typ-ptb .k { color: #ff7b72 !important; }\n#unipile-typ-ptb .fn { color: #d2a8ff !important; }\n#unipile-typ-ptb .s { color: #a5d6ff !important; }\n#unipile-typ-ptb .n { color: #79c0ff !important; }\n#unipile-typ-ptb .w { color: #e6edf3 !important; }<\/p>\n<p>@media (max-width: 900px) {\n  #unipile-typ-ptb .typtb-wrap { padding: 50px 20px !important; }\n  #unipile-typ-ptb h2 { font-size: 28px !important; }\n  #unipile-typ-ptb .typtb-grid { grid-template-columns: 1fr !important; gap: 24px !important; }\n}\n@media (max-width: 600px) {\n  #unipile-typ-ptb .typtb-wrap { padding: 40px 16px !important; }\n  #unipile-typ-ptb h2 { font-size: 26px !important; }\n  #unipile-typ-ptb .typtb-pre { font-size: 11.5px !important; padding: 16px !important; }\n}\n@media (max-width: 400px) {\n  #unipile-typ-ptb h2 { font-size: 24px !important; }\n}\n<\/style>\n<div id=\"unipile-typ-ptb\">\n<div class=\"typtb-wrap\">\n    <span id=\"typ-ptb\" class=\"typtb-anchor\"><\/span><\/p>\n<div class=\"typtb-badge\"><span class=\"typtb-dot\"><\/span><span>Code Tutorial<\/span><\/div>\n<h2>The Telegram Bot API in Python with python-telegram-bot<\/h2>\n<div class=\"typtb-intro\">Raw <code>requests<\/code> calls work fine for a single outbound message. Past that, most Python codebases wrap the <strong style=\"color:#0f2736;\">Telegram Bot API<\/strong> in <code>python-telegram-bot<\/code>, a library that turns the same HTTP endpoints into an async Python object model with built-in update polling.<\/div>\n<div class=\"typtb-grid\">\n<div>\n        <span class=\"typtb-col-title\">What the library adds over raw requests<\/span><\/p>\n<div class=\"typtb-checklist\">\n<div class=\"typtb-check\"><svg viewBox=\"0 0 24 24\"><polyline points=\"20 6 9 17 4 12\"\/><\/svg><span>An <code>Application<\/code> object that manages the update loop for you (polling or webhook)<\/span><\/div>\n<div class=\"typtb-check\"><svg viewBox=\"0 0 24 24\"><polyline points=\"20 6 9 17 4 12\"\/><\/svg><span>Typed methods like <code>bot.send_message()<\/code> instead of hand-built JSON payloads<\/span><\/div>\n<div class=\"typtb-check\"><svg viewBox=\"0 0 24 24\"><polyline points=\"20 6 9 17 4 12\"\/><\/svg><span>Command and message handlers, so replying to <code>\/start<\/code> is a decorator, not a loop<\/span><\/div>\n<\/p><\/div>\n<div class=\"typtb-para\">The parameters are the same ones covered above: <code>chat_id<\/code>, <code>text<\/code>, <code>parse_mode<\/code>. The library still cannot make a bot message a user first, that restriction lives in Telegram's platform rules, not in the client you use to call it.<\/div>\n<\/p><\/div>\n<div>\n<div class=\"typtb-code-wrap\">\n<div class=\"typtb-editor-bar\">\n            <span class=\"typtb-dot2 typtb-dot-r\"><\/span><br \/>\n            <span class=\"typtb-dot2 typtb-dot-y\"><\/span><br \/>\n            <span class=\"typtb-dot2 typtb-dot-g\"><\/span><br \/>\n            <span class=\"typtb-filename\">bot.py<\/span>\n          <\/div>\n<div class=\"typtb-pre\"><code><span class=\"k\">from<\/span> <span class=\"w\">telegram <\/span><span class=\"k\">import<\/span> <span class=\"w\">Update<\/span>&#10;<span class=\"k\">from<\/span> <span class=\"w\">telegram.ext <\/span><span class=\"k\">import<\/span> <span class=\"w\">ApplicationBuilder, CommandHandler, ContextTypes<\/span>&#10;&#10;<span class=\"k\">async<\/span> <span class=\"k\">def<\/span> <span class=\"fn\">start<\/span><span class=\"w\">(update: Update, context: ContextTypes.DEFAULT_TYPE):<\/span>&#10;    <span class=\"k\">await<\/span> <span class=\"w\">context.bot.<\/span><span class=\"fn\">send_message<\/span><span class=\"w\">(<\/span>&#10;        <span class=\"w\">chat_id=update.effective_chat.id,<\/span>&#10;        <span class=\"w\">text=<\/span><span class=\"s\">\"Hello from python-telegram-bot\"<\/span><span class=\"w\">,<\/span>&#10;        <span class=\"w\">parse_mode=<\/span><span class=\"s\">\"MarkdownV2\"<\/span>&#10;    <span class=\"w\">)<\/span>&#10;&#10;<span class=\"w\">app <\/span><span class=\"k\">=<\/span> <span class=\"w\">ApplicationBuilder().<\/span><span class=\"fn\">token<\/span><span class=\"w\">(<\/span><span class=\"s\">\"123456:ABC-your-bot-token\"<\/span><span class=\"w\">).<\/span><span class=\"fn\">build<\/span><span class=\"w\">()<\/span>&#10;<span class=\"w\">app.add_handler(<\/span><span class=\"fn\">CommandHandler<\/span><span class=\"w\">(<\/span><span class=\"s\">\"start\"<\/span><span class=\"w\">, start))<\/span>&#10;<span class=\"w\">app.<\/span><span class=\"fn\">run_polling<\/span><span class=\"w\">()<\/span><\/code><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/div>\n<p>[\/et_pb_code]<br \/>\n[\/et_pb_column]<br \/>\n[\/et_pb_row]<br \/>\n[\/et_pb_section]<br \/>\n[et_pb_section fb_built=\"1\" _builder_version=\"4.27.3\" background_color=\"transparent\" custom_padding=\"0px|0px|0px|0px|false|false\" global_colors_info=\"{}\"]<br \/>\n[et_pb_row _builder_version=\"4.27.3\" background_color=\"transparent\" custom_padding=\"0px|0px|0px|0px|false|false\" global_colors_info=\"{}\"]<br \/>\n[et_pb_column type=\"4_4\" _builder_version=\"4.27.3\" global_colors_info=\"{}\"]<br \/>\n[et_pb_code _builder_version=\"4.27.3\" global_colors_info=\"{}\"]\n<link href=\"https:\/\/fonts.googleapis.com\/css2?family=Inter:wght@400;500;600;700&#038;family=Poppins:wght@700;800&#038;display=swap\" rel=\"stylesheet\">\n<style>\n#unipile-typ-mtproto,\n#unipile-typ-mtproto *,\n#unipile-typ-mtproto *::before,\n#unipile-typ-mtproto *::after {\n  margin: 0 !important;\n  padding: 0 !important;\n  box-sizing: border-box !important;\n  border: none !important;\n  outline: none !important;\n  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;\n  line-height: normal !important;\n  letter-spacing: normal !important;\n  text-transform: none !important;\n  text-decoration: none !important;\n  list-style: none !important;\n  background: transparent !important;\n}\n#unipile-typ-mtproto { display: block !important; overflow-x: hidden !important; max-width: 100% !important; }\n#unipile-typ-mtproto br { display: none !important; }\n#unipile-typ-mtproto p { display: contents !important; }\n#unipile-typ-mtproto .typm-wrap { max-width: 1100px !important; margin: 0 auto !important; padding: 70px 24px !important; }\n#unipile-typ-mtproto .typm-anchor { display: block !important; position: relative !important; top: -80px !important; visibility: hidden !important; }\n#unipile-typ-mtproto .typm-badge {\n  display: inline-flex !important; align-items: center !important; gap: 8px !important;\n  background: rgba(221, 223, 76, 0.18) !important; color: #8a8c2e !important;\n  padding: 6px 14px !important; border-radius: 20px !important; font-size: 12px !important;\n  font-weight: 700 !important; text-transform: uppercase !important; letter-spacing: 0.5px !important;\n  width: fit-content !important; margin-bottom: 18px !important;\n}\n#unipile-typ-mtproto .typm-badge .typm-dot { width: 7px !important; height: 7px !important; background: #DDDF4C !important; border-radius: 50% !important; flex-shrink: 0 !important; display: block !important; }\n#unipile-typ-mtproto h2 { font-family: 'Poppins', sans-serif !important; font-size: 35px !important; font-weight: 700 !important; color: #0f2736 !important; line-height: 1.2 !important; margin-bottom: 16px !important; }\n#unipile-typ-mtproto .typm-intro { font-size: 17px !important; line-height: 1.8 !important; color: #383838 !important; margin-bottom: 32px !important; display: block !important; }\n#unipile-typ-mtproto .typm-intro code { font-family: 'Courier New', monospace !important; background: #f4f5f7 !important; padding: 2px 6px !important; border-radius: 4px !important; font-size: 14.5px !important; color: #0f2736 !important; }<\/p>\n<p>#unipile-typ-mtproto .typm-cards { display: grid !important; grid-template-columns: 1fr 1fr !important; gap: 16px !important; margin-bottom: 30px !important; }\n#unipile-typ-mtproto .typm-card { background: #ffffff !important; border: 1px solid #e5e7eb !important; border-radius: 14px !important; padding: 22px 20px !important; box-shadow: 0 8px 24px rgba(15,39,54,0.06) !important; }\n#unipile-typ-mtproto .typm-card-lang { display: inline-block !important; background: #f4f5f7 !important; color: #64748b !important; padding: 3px 9px !important; border-radius: 5px !important; font-size: 11px !important; font-weight: 700 !important; text-transform: uppercase !important; letter-spacing: 0.4px !important; margin-bottom: 12px !important; }\n#unipile-typ-mtproto .typm-card h3 { font-family: 'Poppins', sans-serif !important; font-size: 16.5px !important; font-weight: 700 !important; color: #0f2736 !important; margin-bottom: 10px !important; display: block !important; }\n#unipile-typ-mtproto .typm-card-text { font-size: 13.5px !important; color: #64748b !important; line-height: 1.65 !important; display: block !important; }<\/p>\n<p>#unipile-typ-mtproto .typm-code-wrap { border-radius: 14px !important; overflow: hidden !important; background: #0d1117 !important; margin-bottom: 30px !important; }\n#unipile-typ-mtproto .typm-editor-bar { background: #161b22 !important; padding: 12px 18px !important; display: flex !important; align-items: center !important; gap: 8px !important; border-bottom: 1px solid rgba(255,255,255,0.06) !important; }\n#unipile-typ-mtproto .typm-dot2 { width: 12px !important; height: 12px !important; border-radius: 50% !important; display: inline-block !important; flex-shrink: 0 !important; }\n#unipile-typ-mtproto .typm-dot-r { background: #ff5f57 !important; }\n#unipile-typ-mtproto .typm-dot-y { background: #febc2e !important; }\n#unipile-typ-mtproto .typm-dot-g { background: #28c840 !important; }\n#unipile-typ-mtproto .typm-filename { color: #8b949e !important; font-size: 13px !important; margin-left: 6px !important; font-family: 'Courier New', monospace !important; }\n#unipile-typ-mtproto .typm-pre { padding: 22px 24px !important; font-size: 12.5px !important; line-height: 1.8 !important; overflow-x: auto !important; background: #0d1117 !important; white-space: pre-wrap !important; word-break: break-word !important; }\n#unipile-typ-mtproto .typm-pre code { font-family: 'Courier New', monospace !important; white-space: pre-wrap !important; display: block !important; word-break: break-word !important; }\n#unipile-typ-mtproto .c { color: #8b949e !important; }\n#unipile-typ-mtproto .k { color: #ff7b72 !important; }\n#unipile-typ-mtproto .fn { color: #d2a8ff !important; }\n#unipile-typ-mtproto .s { color: #a5d6ff !important; }\n#unipile-typ-mtproto .n { color: #79c0ff !important; }\n#unipile-typ-mtproto .w { color: #e6edf3 !important; }<\/p>\n<p>#unipile-typ-mtproto .typm-sub { font-family: 'Poppins', sans-serif !important; font-size: 20px !important; font-weight: 700 !important; color: #0f2736 !important; margin-bottom: 14px !important; display: block !important; }\n#unipile-typ-mtproto .typm-grid { display: grid !important; grid-template-columns: 1.1fr 0.9fr !important; gap: 40px !important; align-items: start !important; }\n#unipile-typ-mtproto .typm-steps { display: flex !important; flex-direction: column !important; gap: 14px !important; }\n#unipile-typ-mtproto .typm-step { background: #ffffff !important; border: 1px solid #e5e7eb !important; border-radius: 14px !important; padding: 18px 20px !important; display: flex !important; gap: 14px !important; align-items: flex-start !important; }\n#unipile-typ-mtproto .typm-step.typm-step-wall { border-color: #DDDF4C !important; background: rgba(221,223,76,0.06) !important; }\n#unipile-typ-mtproto .typm-num { width: 30px !important; height: 30px !important; min-width: 30px !important; border-radius: 8px !important; background: rgba(221,223,76,0.18) !important; color: #8a8c2e !important; display: flex !important; align-items: center !important; justify-content: center !important; font-family: 'Poppins', sans-serif !important; font-size: 12.5px !important; font-weight: 700 !important; }\n#unipile-typ-mtproto .typm-step-title { font-family: 'Poppins', sans-serif !important; font-size: 15px !important; font-weight: 700 !important; color: #0f2736 !important; margin-bottom: 4px !important; display: block !important; }\n#unipile-typ-mtproto .typm-step-desc { font-size: 14px !important; color: #64748b !important; line-height: 1.65 !important; display: block !important; }\n#unipile-typ-mtproto .typm-step-desc code { font-family: 'Courier New', monospace !important; background: #f4f5f7 !important; padding: 2px 6px !important; border-radius: 4px !important; font-size: 12.5px !important; color: #0f2736 !important; }<\/p>\n<p>#unipile-typ-mtproto .typm-warn { background: #0f2736 !important; border-radius: 14px !important; border-left: 4px solid #3BB98B !important; padding: 22px 24px !important; display: flex !important; gap: 14px !important; margin-bottom: 20px !important; }\n#unipile-typ-mtproto .typm-warn svg { width: 22px !important; height: 22px !important; stroke: #3BB98B !important; fill: none !important; stroke-width: 2 !important; stroke-linecap: round !important; stroke-linejoin: round !important; flex-shrink: 0 !important; margin-top: 2px !important; }\n#unipile-typ-mtproto .typm-warn-title { color: #3BB98B !important; font-size: 12px !important; font-weight: 700 !important; text-transform: uppercase !important; letter-spacing: 0.5px !important; margin-bottom: 6px !important; display: block !important; }\n#unipile-typ-mtproto .typm-warn-text { color: rgba(255,255,255,0.85) !important; font-size: 14px !important; line-height: 1.65 !important; display: block !important; }\n#unipile-typ-mtproto .typm-warn-text strong { color: #ffffff !important; font-weight: 700 !important; }\n#unipile-typ-mtproto .typm-warn-text code { font-family: 'Courier New', monospace !important; background: rgba(255,255,255,0.1) !important; padding: 2px 6px !important; border-radius: 4px !important; font-size: 12px !important; color: #ffffff !important; }<\/p>\n<p>#unipile-typ-mtproto .typm-errors-title { font-size: 12px !important; font-weight: 700 !important; color: #0f2736 !important; text-transform: uppercase !important; letter-spacing: 0.4px !important; margin-bottom: 10px !important; display: block !important; }\n#unipile-typ-mtproto .typm-errors { display: flex !important; flex-wrap: wrap !important; gap: 8px !important; margin-bottom: 24px !important; }\n#unipile-typ-mtproto .typm-error-pill { background: #f4f5f7 !important; color: #0f2736 !important; padding: 5px 11px !important; border-radius: 6px !important; font-size: 11.5px !important; font-weight: 600 !important; font-family: 'Courier New', monospace !important; }<\/p>\n<p>#unipile-typ-mtproto .typm-outro { font-size: 15px !important; color: #383838 !important; line-height: 1.8 !important; display: block !important; }\n#unipile-typ-mtproto .typm-outro strong { color: #0f2736 !important; font-weight: 700 !important; }\n#unipile-typ-mtproto .typm-outro a { color: #2aaa7e !important; text-decoration: underline !important; }<\/p>\n<p>@media (max-width: 900px) {\n  #unipile-typ-mtproto .typm-wrap { padding: 50px 20px !important; }\n  #unipile-typ-mtproto h2 { font-size: 28px !important; }\n  #unipile-typ-mtproto .typm-cards { grid-template-columns: 1fr !important; }\n  #unipile-typ-mtproto .typm-grid { grid-template-columns: 1fr !important; gap: 28px !important; }\n}\n@media (max-width: 600px) {\n  #unipile-typ-mtproto .typm-wrap { padding: 40px 16px !important; }\n  #unipile-typ-mtproto h2 { font-size: 26px !important; }\n  #unipile-typ-mtproto .typm-step { padding: 14px !important; gap: 10px !important; }\n  #unipile-typ-mtproto .typm-pre { font-size: 11.5px !important; padding: 16px !important; }\n}\n@media (max-width: 400px) {\n  #unipile-typ-mtproto h2 { font-size: 24px !important; }\n}\n<\/style>\n<div id=\"unipile-typ-mtproto\">\n<div class=\"typm-wrap\">\n    <span id=\"typ-mtproto\" class=\"typm-anchor\"><\/span><\/p>\n<div class=\"typm-badge\"><span class=\"typm-dot\"><\/span><span>Client API \/ MTProto<\/span><\/div>\n<h2>A real user account in Python: Telethon and Pyrogram<\/h2>\n<div class=\"typm-intro\">Sending as a real Telegram account from Python, not a bot, means going through the Client API with <code>api_id<\/code> and <code>api_hash<\/code> from my.telegram.org. Two Python libraries do the MTProto heavy lifting: Telethon and Pyrogram.<\/div>\n<div class=\"typm-cards\">\n<div class=\"typm-card\">\n        <span class=\"typm-card-lang\">Python<\/span><\/p>\n<h3>Telethon<\/h3>\n<div class=\"typm-card-text\">A pure-Python MTProto implementation built around async\/await, with a client API that reads close to plain Python rather than raw protocol calls.<\/div>\n<\/p><\/div>\n<div class=\"typm-card\">\n        <span class=\"typm-card-lang\">Python<\/span><\/p>\n<h3>Pyrogram<\/h3>\n<div class=\"typm-card-text\">Another Python MTProto client, with its own take on session handling and a client surface designed to feel like a conventional SDK rather than a protocol library.<\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div class=\"typm-code-wrap\">\n<div class=\"typm-editor-bar\">\n        <span class=\"typm-dot2 typm-dot-r\"><\/span><br \/>\n        <span class=\"typm-dot2 typm-dot-y\"><\/span><br \/>\n        <span class=\"typm-dot2 typm-dot-g\"><\/span><br \/>\n        <span class=\"typm-filename\">telethon_client.py<\/span>\n      <\/div>\n<div class=\"typm-pre\"><code><span class=\"k\">from<\/span> <span class=\"w\">telethon <\/span><span class=\"k\">import<\/span> <span class=\"w\">TelegramClient<\/span>&#10;<span class=\"k\">from<\/span> <span class=\"w\">telethon.errors <\/span><span class=\"k\">import<\/span> <span class=\"w\">SessionPasswordNeededError<\/span>&#10;&#10;<span class=\"w\">api_id <\/span><span class=\"k\">=<\/span> <span class=\"n\">1234567<\/span>&#10;<span class=\"w\">api_hash <\/span><span class=\"k\">=<\/span> <span class=\"s\">\"your_api_hash_from_my.telegram.org\"<\/span>&#10;&#10;<span class=\"c\"># \"my_account\" is the session file name on disk, reused on every run<\/span>&#10;<span class=\"w\">client <\/span><span class=\"k\">=<\/span> <span class=\"fn\">TelegramClient<\/span><span class=\"w\">(<\/span><span class=\"s\">\"my_account\"<\/span><span class=\"w\">, api_id, api_hash)<\/span>&#10;&#10;<span class=\"k\">async<\/span> <span class=\"k\">def<\/span> <span class=\"fn\">main<\/span><span class=\"w\">():<\/span>&#10;    <span class=\"k\">await<\/span> <span class=\"w\">client.<\/span><span class=\"fn\">start<\/span><span class=\"w\">(phone=<\/span><span class=\"s\">\"+15551234567\"<\/span><span class=\"w\">)<\/span>&#10;    <span class=\"k\">await<\/span> <span class=\"w\">client.<\/span><span class=\"fn\">send_message<\/span><span class=\"w\">(<\/span><span class=\"s\">\"username_or_id\"<\/span><span class=\"w\">, <\/span><span class=\"s\">\"Hello from Telethon\"<\/span><span class=\"w\">)<\/span>&#10;&#10;<span class=\"k\">with<\/span> <span class=\"w\">client:<\/span>&#10;    <span class=\"w\">client.loop.<\/span><span class=\"fn\">run_until_complete<\/span><span class=\"w\">(main())<\/span><\/code><\/div>\n<\/p><\/div>\n<p>    <span class=\"typm-sub\">The 2FA wall every home-built login has to handle<\/span><\/p>\n<div class=\"typm-grid\">\n<div>\n<div class=\"typm-steps\">\n<div class=\"typm-step\">\n<div class=\"typm-num\">1<\/div>\n<div>\n              <span class=\"typm-step-title\">Send the login code<\/span><br \/>\n              <span class=\"typm-step-desc\"><code>client.start(phone=...)<\/code> wraps <code>auth.sendCode<\/code>, which texts a login code to the phone number and returns a <code>phone_code_hash<\/code> used for the next call.<\/span>\n            <\/div>\n<\/p><\/div>\n<div class=\"typm-step\">\n<div class=\"typm-num\">2<\/div>\n<div>\n              <span class=\"typm-step-title\">Validate the code<\/span><br \/>\n              <span class=\"typm-step-desc\">The library prompts for the code and calls <code>auth.signIn<\/code> with it. This is where a happy-path-only implementation stops.<\/span>\n            <\/div>\n<\/p><\/div>\n<div class=\"typm-step typm-step-wall\">\n<div class=\"typm-num\">3<\/div>\n<div>\n              <span class=\"typm-step-title\">Hit SESSION_PASSWORD_NEEDED<\/span><br \/>\n              <span class=\"typm-step-desc\">If the account has two-factor authentication enabled, Telegram answers with a <strong>400 error: SESSION_PASSWORD_NEEDED<\/strong>. Telethon raises this as <code>SessionPasswordNeededError<\/code>, an expected branch, not a bug to catch and ignore.<\/span>\n            <\/div>\n<\/p><\/div>\n<div class=\"typm-step\">\n<div class=\"typm-num\">4<\/div>\n<div>\n              <span class=\"typm-step-title\">Clear it with the cloud password<\/span><br \/>\n              <span class=\"typm-step-desc\">Passing the account's cloud password to <code>client.start(password=...)<\/code> runs the SRP exchange and <code>auth.checkPassword<\/code> for you. Calling the raw MTProto layer directly means building the <code>InputCheckPasswordSRP<\/code> object yourself.<\/span>\n            <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div>\n<div class=\"typm-warn\">\n          <svg viewBox=\"0 0 24 24\"><path d=\"M13.73 21a2 2 0 0 1-3.46 0\"\/><path d=\"M18.63 13A17.89 17.89 0 0 1 18 8\"\/><path d=\"M6.26 6.26A5.86 5.86 0 0 0 6 8c0 7-3 9-3 9h14\"\/><path d=\"M18 8a6 6 0 0 0-9.33-5\"\/><line x1=\"1\" y1=\"1\" x2=\"23\" y2=\"23\"\/><\/svg><\/p>\n<div>\n            <span class=\"typm-warn-title\">Persist the session, or log in every run<\/span><br \/>\n            <span class=\"typm-warn-text\">Telethon and Pyrogram both write a local session file (or an in-memory <code>StringSession<\/code>) after the first successful login. Lose it, or deploy without persisting it, and your script has to run the phone-code and 2FA flow again on every restart.<\/span>\n          <\/div>\n<\/p><\/div>\n<p>        <span class=\"typm-errors-title\">Errors to expect on this path<\/span><\/p>\n<div class=\"typm-errors\">\n          <span class=\"typm-error-pill\">SESSION_PASSWORD_NEEDED<\/span><br \/>\n          <span class=\"typm-error-pill\">PASSWORD_HASH_INVALID<\/span><br \/>\n          <span class=\"typm-error-pill\">API_ID_PUBLISHED_FLOOD<\/span>\n        <\/div>\n<div class=\"typm-outro\">Only Telegram's own official apps get Firebase-based SMS code delivery. A Python script also needs its own <code>api_id<\/code> from my.telegram.org: reusing the example ID shipped in open-source sample code triggers <strong>API_ID_PUBLISHED_FLOOD<\/strong> for your end users, and only one <code>api_id<\/code> is issued per phone number.<\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/div>\n<p>[\/et_pb_code]<br \/>\n[\/et_pb_column]<br \/>\n[\/et_pb_row]<br \/>\n[\/et_pb_section]<br \/>\n[et_pb_section fb_built=\"1\" _builder_version=\"4.27.3\" background_color=\"transparent\" custom_padding=\"0px|0px|0px|0px|false|false\" global_colors_info=\"{}\"]<br \/>\n[et_pb_row _builder_version=\"4.27.3\" background_color=\"transparent\" custom_padding=\"0px|0px|0px|0px|false|false\" global_colors_info=\"{}\"]<br \/>\n[et_pb_column type=\"4_4\" _builder_version=\"4.27.3\" global_colors_info=\"{}\"]<br \/>\n[et_pb_code _builder_version=\"4.27.3\" global_colors_info=\"{}\"]\n<link href=\"https:\/\/fonts.googleapis.com\/css2?family=Inter:wght@400;500;600;700&#038;family=Poppins:wght@700;800&#038;display=swap\" rel=\"stylesheet\">\n<style>\n#unipile-typ-sdk,\n#unipile-typ-sdk *,\n#unipile-typ-sdk *::before,\n#unipile-typ-sdk *::after {\n  margin: 0 !important;\n  padding: 0 !important;\n  box-sizing: border-box !important;\n  border: none !important;\n  outline: none !important;\n  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;\n  line-height: normal !important;\n  letter-spacing: normal !important;\n  text-transform: none !important;\n  text-decoration: none !important;\n  list-style: none !important;\n  background: transparent !important;\n}\n#unipile-typ-sdk { display: block !important; overflow-x: hidden !important; max-width: 100% !important; }\n#unipile-typ-sdk br { display: none !important; }\n#unipile-typ-sdk p { display: contents !important; }\n#unipile-typ-sdk .typs-wrap { max-width: 1100px !important; margin: 0 auto !important; padding: 70px 24px !important; }\n#unipile-typ-sdk .typs-anchor { display: block !important; position: relative !important; top: -80px !important; visibility: hidden !important; }\n#unipile-typ-sdk .typs-badge {\n  display: inline-flex !important; align-items: center !important; gap: 8px !important;\n  background: rgba(59, 185, 139, 0.12) !important; color: #2aaa7e !important;\n  padding: 6px 14px !important; border-radius: 20px !important; font-size: 12px !important;\n  font-weight: 700 !important; text-transform: uppercase !important; letter-spacing: 0.5px !important;\n  width: fit-content !important; margin-bottom: 18px !important;\n}\n#unipile-typ-sdk .typs-badge .typs-dot { width: 7px !important; height: 7px !important; background: #3BB98B !important; border-radius: 50% !important; flex-shrink: 0 !important; display: block !important; }\n#unipile-typ-sdk h2 { font-family: 'Poppins', sans-serif !important; font-size: 35px !important; font-weight: 700 !important; color: #0f2736 !important; line-height: 1.2 !important; margin-bottom: 16px !important; }\n#unipile-typ-sdk .typs-intro { font-size: 17px !important; line-height: 1.8 !important; color: #383838 !important; margin-bottom: 36px !important; display: block !important; }\n#unipile-typ-sdk .typs-intro code { font-family: 'Courier New', monospace !important; background: #f4f5f7 !important; padding: 2px 6px !important; border-radius: 4px !important; font-size: 14.5px !important; color: #0f2736 !important; }<\/p>\n<p>#unipile-typ-sdk .typs-grid { display: grid !important; grid-template-columns: 1.05fr 0.95fr !important; gap: 40px !important; align-items: start !important; margin-bottom: 30px !important; }<\/p>\n<p>#unipile-typ-sdk .typs-para { font-size: 15px !important; color: #383838 !important; line-height: 1.8 !important; margin-bottom: 18px !important; display: block !important; }\n#unipile-typ-sdk .typs-para strong { color: #0f2736 !important; font-weight: 700 !important; }\n#unipile-typ-sdk .typs-para a { color: #2aaa7e !important; text-decoration: underline !important; }\n#unipile-typ-sdk .typs-para code { font-family: 'Courier New', monospace !important; background: #f4f5f7 !important; padding: 2px 6px !important; border-radius: 4px !important; font-size: 13.5px !important; color: #0f2736 !important; }<\/p>\n<p>#unipile-typ-sdk .typs-checklist { display: flex !important; flex-direction: column !important; gap: 10px !important; margin: 20px 0 24px !important; }\n#unipile-typ-sdk .typs-check { display: flex !important; align-items: flex-start !important; gap: 10px !important; font-size: 14px !important; color: #383838 !important; line-height: 1.6 !important; }\n#unipile-typ-sdk .typs-check svg { width: 16px !important; height: 16px !important; stroke: #3BB98B !important; fill: none !important; stroke-width: 2.5 !important; stroke-linecap: round !important; stroke-linejoin: round !important; flex-shrink: 0 !important; margin-top: 2px !important; }<\/p>\n<p>#unipile-typ-sdk .typs-code-wrap { border-radius: 14px !important; overflow: hidden !important; background: #0d1117 !important; margin-bottom: 16px !important; }\n#unipile-typ-sdk .typs-editor-bar { background: #161b22 !important; padding: 12px 18px !important; display: flex !important; align-items: center !important; gap: 8px !important; border-bottom: 1px solid rgba(255,255,255,0.06) !important; }\n#unipile-typ-sdk .typs-dot2 { width: 12px !important; height: 12px !important; border-radius: 50% !important; display: inline-block !important; flex-shrink: 0 !important; }\n#unipile-typ-sdk .typs-dot-r { background: #ff5f57 !important; }\n#unipile-typ-sdk .typs-dot-y { background: #febc2e !important; }\n#unipile-typ-sdk .typs-dot-g { background: #28c840 !important; }\n#unipile-typ-sdk .typs-filename { color: #8b949e !important; font-size: 13px !important; margin-left: 6px !important; font-family: 'Courier New', monospace !important; }\n#unipile-typ-sdk .typs-pre { padding: 22px 24px !important; font-size: 12.5px !important; line-height: 1.8 !important; overflow-x: auto !important; background: #0d1117 !important; white-space: pre-wrap !important; word-break: break-word !important; }\n#unipile-typ-sdk .typs-pre code { font-family: 'Courier New', monospace !important; white-space: pre-wrap !important; display: block !important; word-break: break-word !important; }\n#unipile-typ-sdk .c { color: #8b949e !important; }\n#unipile-typ-sdk .k { color: #ff7b72 !important; }\n#unipile-typ-sdk .fn { color: #d2a8ff !important; }\n#unipile-typ-sdk .s { color: #a5d6ff !important; }\n#unipile-typ-sdk .n { color: #79c0ff !important; }\n#unipile-typ-sdk .w { color: #e6edf3 !important; }<\/p>\n<p>#unipile-typ-sdk .typs-note { background: #f4f5f7 !important; border-radius: 12px !important; padding: 16px 20px !important; font-size: 13.5px !important; line-height: 1.7 !important; color: #4a5568 !important; margin-bottom: 4px !important; }\n#unipile-typ-sdk .typs-note a { color: #2aaa7e !important; text-decoration: underline !important; font-weight: 600 !important; }\n#unipile-typ-sdk .typs-note code { font-family: 'Courier New', monospace !important; background: rgba(0,0,0,0.06) !important; padding: 1px 5px !important; border-radius: 4px !important; font-size: 12.5px !important; }<\/p>\n<p>#unipile-typ-sdk .typs-scope-box { background: #f4f5f7 !important; border-radius: 16px !important; padding: 26px 28px !important; margin-top: 30px !important; }\n#unipile-typ-sdk .typs-scope-title { font-size: 15px !important; font-weight: 700 !important; color: #0f2736 !important; margin-bottom: 14px !important; display: flex !important; align-items: center !important; gap: 8px !important; }\n#unipile-typ-sdk .typs-scope-title svg { width: 17px !important; height: 17px !important; stroke: #64748b !important; fill: none !important; stroke-width: 2 !important; stroke-linecap: round !important; stroke-linejoin: round !important; }\n#unipile-typ-sdk .typs-scope-grid { display: grid !important; grid-template-columns: repeat(2, 1fr) !important; gap: 10px 24px !important; }\n#unipile-typ-sdk .typs-scope-row { display: flex !important; align-items: flex-start !important; gap: 10px !important; font-size: 13.5px !important; line-height: 1.6 !important; color: #4a5568 !important; }\n#unipile-typ-sdk .typs-scope-row svg { width: 15px !important; height: 15px !important; min-width: 15px !important; stroke: #ef4444 !important; fill: none !important; stroke-width: 2.5 !important; stroke-linecap: round !important; stroke-linejoin: round !important; margin-top: 2px !important; }<\/p>\n<p>#unipile-typ-sdk .typs-cta {\n  display: inline-flex !important; align-items: center !important; gap: 8px !important;\n  background: #DDDF4C !important; color: #0f2736 !important; padding: 14px 28px !important;\n  border-radius: 8px !important; font-size: 0.95rem !important; font-weight: 600 !important;\n  border: 2px solid #DDDF4C !important; transition: all 0.3s ease !important; cursor: pointer !important;\n  white-space: nowrap !important; margin-top: 24px !important;\n}\n#unipile-typ-sdk .typs-cta:hover { transform: translateY(-5px) !important; }\n#unipile-typ-sdk .typs-cta svg { width: 15px !important; height: 15px !important; stroke: currentColor !important; fill: none !important; stroke-width: 2.5 !important; stroke-linecap: round !important; stroke-linejoin: round !important; }<\/p>\n<p>@media (max-width: 900px) {\n  #unipile-typ-sdk .typs-wrap { padding: 50px 20px !important; }\n  #unipile-typ-sdk h2 { font-size: 28px !important; }\n  #unipile-typ-sdk .typs-grid { grid-template-columns: 1fr !important; gap: 28px !important; }\n  #unipile-typ-sdk .typs-scope-grid { grid-template-columns: 1fr !important; }\n}\n@media (max-width: 600px) {\n  #unipile-typ-sdk .typs-wrap { padding: 40px 16px !important; }\n  #unipile-typ-sdk h2 { font-size: 26px !important; }\n  #unipile-typ-sdk .typs-cta { width: 100% !important; justify-content: center !important; }\n  #unipile-typ-sdk .typs-pre { font-size: 11.5px !important; padding: 16px !important; }\n}\n@media (max-width: 400px) {\n  #unipile-typ-sdk h2 { font-size: 24px !important; }\n}\n<\/style>\n<div id=\"unipile-typ-sdk\">\n<div class=\"typs-wrap\">\n    <span id=\"typ-sdk\" class=\"typs-anchor\"><\/span><\/p>\n<div class=\"typs-badge\"><span class=\"typs-dot\"><\/span><span>The Unipile approach<\/span><\/div>\n<div class=\"typs-note\"><span>For the full list of Telegram capabilities exposed by Unipile, see the <a href=\"https:\/\/www.unipile.com\/communication-api\/messaging-api\/telegram-api\/\" target=\"_self\">Telegram API product page<\/a>.<\/span><\/div>\n<h2>A real Telegram account in Python, without writing MTProto<\/h2>\n<div class=\"typs-intro\">The Unipile Python SDK connects an existing Telegram user account through Telegram's own <strong style=\"color:#0f2736;\">Devices<\/strong> feature, either a QR code scan or Hosted Auth with <code>providers: \"TELEGRAM\"<\/code>. There is no <code>api_id<\/code>, no session file to persist, and no <code>SESSION_PASSWORD_NEEDED<\/code> branch to write yourself: the linked account either shows as <code>connected<\/code> or it doesn't.<\/div>\n<div class=\"typs-grid\">\n<div>\n<div class=\"typs-para\">Once an account is linked, sending a message from Python is a handful of SDK calls, all running on Unipile's <strong>v2<\/strong> API underneath. <code>start_chat<\/code> takes the linked account's ID and a <code>user_ids<\/code> list, and either opens a new conversation or delivers into the existing one if a chat already exists with that recipient.<\/div>\n<div class=\"typs-checklist\">\n<div class=\"typs-check\"><svg viewBox=\"0 0 24 24\"><polyline points=\"20 6 9 17 4 12\"\/><\/svg><span>No <code>api_id<\/code> \/ <code>api_hash<\/code> pair to request or rotate<\/span><\/div>\n<div class=\"typs-check\"><svg viewBox=\"0 0 24 24\"><polyline points=\"20 6 9 17 4 12\"\/><\/svg><span>No session file, no SRP handshake, no 2FA branch in your code<\/span><\/div>\n<div class=\"typs-check\"><svg viewBox=\"0 0 24 24\"><polyline points=\"20 6 9 17 4 12\"\/><\/svg><span>Same account status handling for group participant management<\/span><\/div>\n<\/p><\/div>\n<div class=\"typs-note\">Installing the SDK is not covered here since the exact package name is best confirmed against the current docs, see <a href=\"https:\/\/developer.unipile.com\/docs\/getting-started\" target=\"_blank\" rel=\"noopener\">developer.unipile.com\/docs\/getting-started<\/a> for the install step and full Python reference.<\/div>\n<div class=\"typs-note\"><span>Every capability shown here is listed endpoint by endpoint on the <a href=\"https:\/\/www.unipile.com\/communication-api\/messaging-api\/telegram-api\/\" target=\"_self\">Unipile Telegram API product page<\/a>, including what is supported and what is not.<\/span><\/div>\n<\/p><\/div>\n<div>\n<div class=\"typs-code-wrap\">\n<div class=\"typs-editor-bar\">\n            <span class=\"typs-dot2 typs-dot-r\"><\/span><br \/>\n            <span class=\"typs-dot2 typs-dot-y\"><\/span><br \/>\n            <span class=\"typs-dot2 typs-dot-g\"><\/span><br \/>\n            <span class=\"typs-filename\">send_telegram.py<\/span>\n          <\/div>\n<div class=\"typs-pre\"><code><span class=\"k\">import<\/span> <span class=\"w\">unipile<\/span>&#10;&#10;<span class=\"w\">configuration <\/span><span class=\"k\">=<\/span> <span class=\"w\">unipile.<\/span><span class=\"fn\">Configuration<\/span><span class=\"w\">()<\/span>&#10;<span class=\"w\">configuration.api_key[<\/span><span class=\"s\">\"apiKey\"<\/span><span class=\"w\">] <\/span><span class=\"k\">=<\/span> <span class=\"s\">\"apikey\"<\/span>&#10;&#10;<span class=\"w\">api_client <\/span><span class=\"k\">=<\/span> <span class=\"w\">unipile.<\/span><span class=\"fn\">ApiClient<\/span><span class=\"w\">(configuration)<\/span>&#10;<span class=\"w\">messaging_api <\/span><span class=\"k\">=<\/span> <span class=\"w\">unipile.<\/span><span class=\"fn\">MessagingApi<\/span><span class=\"w\">(api_client)<\/span>&#10;&#10;<span class=\"w\">chat <\/span><span class=\"k\">=<\/span> <span class=\"w\">messaging_api.<\/span><span class=\"fn\">start_chat<\/span><span class=\"w\">(<\/span>&#10;    <span class=\"s\">\"acc_123456789\"<\/span><span class=\"w\">,<\/span>&#10;    <span class=\"w\">{<\/span><span class=\"s\">\"user_ids\"<\/span><span class=\"w\">: [<\/span><span class=\"s\">\"0123456789\"<\/span><span class=\"w\">], <\/span><span class=\"s\">\"text\"<\/span><span class=\"w\">: <\/span><span class=\"s\">\"Hi, following up on your request.\"<\/span><span class=\"w\">}<\/span>&#10;<span class=\"w\">)<\/span><\/code><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div class=\"typs-scope-box\">\n<div class=\"typs-scope-title\"><svg viewBox=\"0 0 24 24\"><circle cx=\"12\" cy=\"12\" r=\"10\"\/><line x1=\"12\" y1=\"8\" x2=\"12\" y2=\"12\"\/><line x1=\"12\" y1=\"16\" x2=\"12.01\" y2=\"16\"\/><\/svg><span>What the Unipile Telegram integration does not cover<\/span><\/div>\n<div class=\"typs-scope-grid\">\n<div class=\"typs-scope-row\"><svg viewBox=\"0 0 24 24\"><line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\"\/><line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\"\/><\/svg><span>Channels, communities and broadcasts<\/span><\/div>\n<div class=\"typs-scope-row\"><svg viewBox=\"0 0 24 24\"><line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\"\/><line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\"\/><\/svg><span>Group administration: approving or promoting members<\/span><\/div>\n<div class=\"typs-scope-row\"><svg viewBox=\"0 0 24 24\"><line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\"\/><line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\"\/><\/svg><span>Chat archiving<\/span><\/div>\n<div class=\"typs-scope-row\"><svg viewBox=\"0 0 24 24\"><line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\"\/><line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\"\/><\/svg><span>Voice and video calls<\/span><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<p>    <a class=\"typs-cta\" href=\"https:\/\/dashboard.unipile.com\/signup\/\" target=\"_blank\" rel=\"noopener\"><span>Build with the Python SDK<\/span><svg viewBox=\"0 0 24 24\"><line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\"\/><polyline points=\"12 5 19 12 12 19\"\/><\/svg><\/a>\n  <\/div>\n<\/div>\n<p><script>\n(function(){\n  var root = document.getElementById('unipile-typ-sdk');\n  if (!root) return;\n  root.addEventListener('click', function(e){\n    var el = e.target.closest('[data-upl-link]');\n    if (!el || !root.contains(el)) return;\n    e.preventDefault();\n    window.open(el.getAttribute('data-upl-link'), el.getAttribute('data-upl-target') || '_blank');\n  });\n})();\n<\/script><\/p>\n<p>[\/et_pb_code]<br \/>\n[\/et_pb_column]<br \/>\n[\/et_pb_row]<br \/>\n[\/et_pb_section]<br \/>\n[et_pb_section fb_built=\"1\" _builder_version=\"4.27.3\" background_color=\"transparent\" custom_padding=\"0px|0px|0px|0px|false|false\" global_colors_info=\"{}\"]<br \/>\n[et_pb_row _builder_version=\"4.27.3\" background_color=\"transparent\" custom_padding=\"0px|0px|0px|0px|false|false\" global_colors_info=\"{}\"]<br \/>\n[et_pb_column type=\"4_4\" _builder_version=\"4.27.3\" global_colors_info=\"{}\"]<br \/>\n[et_pb_code _builder_version=\"4.27.3\" global_colors_info=\"{}\"]\n<link href=\"https:\/\/fonts.googleapis.com\/css2?family=Inter:wght@400;500;600;700&#038;family=Poppins:wght@700;800&#038;display=swap\" rel=\"stylesheet\">\n<style>\n#unipile-typ-errors,\n#unipile-typ-errors *,\n#unipile-typ-errors *::before,\n#unipile-typ-errors *::after {\n  margin: 0 !important;\n  padding: 0 !important;\n  box-sizing: border-box !important;\n  border: none !important;\n  outline: none !important;\n  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;\n  line-height: normal !important;\n  letter-spacing: normal !important;\n  text-transform: none !important;\n  text-decoration: none !important;\n  list-style: none !important;\n  background: transparent !important;\n}\n#unipile-typ-errors { display: block !important; overflow-x: hidden !important; max-width: 100% !important; }\n#unipile-typ-errors br { display: none !important; }\n#unipile-typ-errors p { display: contents !important; }\n#unipile-typ-errors .tye-wrap { max-width: 1100px !important; margin: 0 auto !important; padding: 70px 24px !important; }\n#unipile-typ-errors .tye-anchor { display: block !important; position: relative !important; top: -80px !important; visibility: hidden !important; }\n#unipile-typ-errors .tye-badge {\n  display: inline-flex !important; align-items: center !important; gap: 8px !important;\n  background: rgba(239, 68, 68, 0.12) !important; color: #dc2626 !important;\n  padding: 6px 14px !important; border-radius: 20px !important; font-size: 12px !important;\n  font-weight: 700 !important; text-transform: uppercase !important; letter-spacing: 0.5px !important;\n  width: fit-content !important; margin-bottom: 18px !important;\n}\n#unipile-typ-errors .tye-badge .tye-dot { width: 7px !important; height: 7px !important; background: #ef4444 !important; border-radius: 50% !important; flex-shrink: 0 !important; display: block !important; }\n#unipile-typ-errors h2 { font-family: 'Poppins', sans-serif !important; font-size: 35px !important; font-weight: 700 !important; color: #0f2736 !important; line-height: 1.2 !important; margin-bottom: 16px !important; }\n#unipile-typ-errors .tye-intro { font-size: 17px !important; line-height: 1.8 !important; color: #383838 !important; margin-bottom: 32px !important; display: block !important; }\n#unipile-typ-errors .tye-intro code { font-family: 'Courier New', monospace !important; background: #f4f5f7 !important; padding: 2px 6px !important; border-radius: 4px !important; font-size: 14.5px !important; color: #0f2736 !important; }<\/p>\n<p>#unipile-typ-errors .tye-stats { display: grid !important; grid-template-columns: repeat(4, 1fr) !important; gap: 16px !important; margin-bottom: 32px !important; }\n#unipile-typ-errors .tye-stat { background: #ffffff !important; border: 1px solid #e5e7eb !important; border-radius: 14px !important; padding: 20px 18px !important; box-shadow: 0 8px 24px rgba(15,39,54,0.06) !important; }\n#unipile-typ-errors .tye-stat-num { font-family: 'Poppins', sans-serif !important; font-size: 22px !important; font-weight: 800 !important; color: #0f2736 !important; margin-bottom: 6px !important; display: block !important; }\n#unipile-typ-errors .tye-stat-label { font-size: 12.5px !important; color: #64748b !important; line-height: 1.5 !important; display: block !important; }\n#unipile-typ-errors .tye-stat.tye-stat-warn .tye-stat-num { color: #b45309 !important; }<\/p>\n<p>#unipile-typ-errors .tye-sub { font-family: 'Poppins', sans-serif !important; font-size: 19px !important; font-weight: 700 !important; color: #0f2736 !important; margin-bottom: 14px !important; display: block !important; }\n#unipile-typ-errors .tye-lead { font-size: 15px !important; color: #4a5568 !important; line-height: 1.75 !important; margin-bottom: 16px !important; display: block !important; }\n#unipile-typ-errors .tye-lead code { font-family: 'Courier New', monospace !important; background: #f4f5f7 !important; padding: 2px 6px !important; border-radius: 4px !important; font-size: 13.5px !important; color: #0f2736 !important; }<\/p>\n<p>#unipile-typ-errors .tye-codes { display: grid !important; grid-template-columns: 1fr 1fr !important; gap: 20px !important; margin-bottom: 30px !important; }\n#unipile-typ-errors .tye-code-block { display: flex !important; flex-direction: column !important; }\n#unipile-typ-errors .tye-code-wrap { border-radius: 14px !important; overflow: hidden !important; background: #0d1117 !important; }\n#unipile-typ-errors .tye-editor-bar { background: #161b22 !important; padding: 12px 18px !important; display: flex !important; align-items: center !important; gap: 8px !important; border-bottom: 1px solid rgba(255,255,255,0.06) !important; }\n#unipile-typ-errors .tye-dot2 { width: 12px !important; height: 12px !important; border-radius: 50% !important; display: inline-block !important; flex-shrink: 0 !important; }\n#unipile-typ-errors .tye-dot-r { background: #ff5f57 !important; }\n#unipile-typ-errors .tye-dot-y { background: #febc2e !important; }\n#unipile-typ-errors .tye-dot-g { background: #28c840 !important; }\n#unipile-typ-errors .tye-filename { color: #8b949e !important; font-size: 13px !important; margin-left: 6px !important; font-family: 'Courier New', monospace !important; }\n#unipile-typ-errors .tye-pre { padding: 20px 20px !important; font-size: 12px !important; line-height: 1.75 !important; overflow-x: auto !important; background: #0d1117 !important; white-space: pre-wrap !important; word-break: break-word !important; }\n#unipile-typ-errors .tye-pre code { font-family: 'Courier New', monospace !important; white-space: pre-wrap !important; display: block !important; word-break: break-word !important; }\n#unipile-typ-errors .c { color: #8b949e !important; }\n#unipile-typ-errors .k { color: #ff7b72 !important; }\n#unipile-typ-errors .fn { color: #d2a8ff !important; }\n#unipile-typ-errors .s { color: #a5d6ff !important; }\n#unipile-typ-errors .n { color: #79c0ff !important; }\n#unipile-typ-errors .w { color: #e6edf3 !important; }<\/p>\n<p>#unipile-typ-errors .tye-box { background: #0f2736 !important; border-radius: 16px !important; padding: 30px 32px !important; }\n#unipile-typ-errors .tye-box-title { font-family: 'Poppins', sans-serif !important; font-size: 17px !important; font-weight: 700 !important; color: #ffffff !important; margin-bottom: 14px !important; display: block !important; }\n#unipile-typ-errors .tye-box-list { display: flex !important; flex-direction: column !important; gap: 10px !important; }\n#unipile-typ-errors .tye-box-item { display: flex !important; align-items: flex-start !important; gap: 10px !important; font-size: 14px !important; color: rgba(255,255,255,0.8) !important; line-height: 1.65 !important; }\n#unipile-typ-errors .tye-box-item svg { width: 16px !important; height: 16px !important; stroke: #3BB98B !important; fill: none !important; stroke-width: 2.5 !important; stroke-linecap: round !important; stroke-linejoin: round !important; flex-shrink: 0 !important; margin-top: 2px !important; }\n#unipile-typ-errors .tye-box-item strong { color: #ffffff !important; font-weight: 700 !important; }<\/p>\n<p>@media (max-width: 900px) {\n  #unipile-typ-errors .tye-wrap { padding: 50px 20px !important; }\n  #unipile-typ-errors h2 { font-size: 28px !important; }\n  #unipile-typ-errors .tye-stats { grid-template-columns: repeat(2, 1fr) !important; }\n  #unipile-typ-errors .tye-codes { grid-template-columns: 1fr !important; }\n}\n@media (max-width: 600px) {\n  #unipile-typ-errors .tye-wrap { padding: 40px 16px !important; }\n  #unipile-typ-errors h2 { font-size: 26px !important; }\n  #unipile-typ-errors .tye-stats { grid-template-columns: 1fr 1fr !important; gap: 12px !important; }\n  #unipile-typ-errors .tye-pre { font-size: 11px !important; padding: 14px !important; }\n  #unipile-typ-errors .tye-box { padding: 22px !important; }\n}\n@media (max-width: 400px) {\n  #unipile-typ-errors h2 { font-size: 24px !important; }\n  #unipile-typ-errors .tye-stats { grid-template-columns: 1fr !important; }\n}\n<\/style>\n<div id=\"unipile-typ-errors\">\n<div class=\"tye-wrap\">\n    <span id=\"typ-errors\" class=\"tye-anchor\"><\/span><\/p>\n<div class=\"tye-badge\"><span class=\"tye-dot\"><\/span><span>Errors and limits<\/span><\/div>\n<h2>Handling errors and rate limits in Python<\/h2>\n<div class=\"tye-intro\">A script that sends one message in a test chat and a script that runs in production hit different problems. The second one eventually gets a <code>429<\/code> or a <code>FLOOD_WAIT_X<\/code>, and what your Python code does next decides whether that is a five-second pause or a banned account.<\/div>\n<div class=\"tye-stats\">\n<div class=\"tye-stat\">\n        <span class=\"tye-stat-num\">1\/sec<\/span><br \/>\n        <span class=\"tye-stat-label\">Maximum Bot API messages to the same individual chat<\/span>\n      <\/div>\n<div class=\"tye-stat\">\n        <span class=\"tye-stat-num\">20\/min<\/span><br \/>\n        <span class=\"tye-stat-label\">Maximum Bot API messages inside a single group<\/span>\n      <\/div>\n<div class=\"tye-stat\">\n        <span class=\"tye-stat-num\">~30\/sec<\/span><br \/>\n        <span class=\"tye-stat-label\">Approximate Bot API ceiling when broadcasting across chats<\/span>\n      <\/div>\n<div class=\"tye-stat tye-stat-warn\">\n        <span class=\"tye-stat-num\">429<\/span><br \/>\n        <span class=\"tye-stat-label\">Status returned once any of these limits is crossed<\/span>\n      <\/div>\n<\/p><\/div>\n<p>    <span class=\"tye-sub\">Retry loops for both sides of the API<\/span><\/p>\n<div class=\"tye-lead\">The Bot API and the Client API signal the same problem with two different shapes. Both need to be caught explicitly, not logged and retried blindly.<\/div>\n<div class=\"tye-codes\">\n<div class=\"tye-code-block\">\n<div class=\"tye-code-wrap\">\n<div class=\"tye-editor-bar\">\n            <span class=\"tye-dot2 tye-dot-r\"><\/span><br \/>\n            <span class=\"tye-dot2 tye-dot-y\"><\/span><br \/>\n            <span class=\"tye-dot2 tye-dot-g\"><\/span><br \/>\n            <span class=\"tye-filename\">bot_api_retry.py<\/span>\n          <\/div>\n<div class=\"tye-pre\"><code><span class=\"k\">import<\/span> <span class=\"w\">time<\/span>&#10;<span class=\"k\">import<\/span> <span class=\"w\">requests<\/span>&#10;&#10;<span class=\"k\">def<\/span> <span class=\"fn\">send_with_retry<\/span><span class=\"w\">(url, payload, max_retries=<\/span><span class=\"n\">3<\/span><span class=\"w\">):<\/span>&#10;    <span class=\"k\">for<\/span> <span class=\"w\">attempt <\/span><span class=\"k\">in<\/span> <span class=\"fn\">range<\/span><span class=\"w\">(max_retries):<\/span>&#10;        <span class=\"w\">r <\/span><span class=\"k\">=<\/span> <span class=\"w\">requests.<\/span><span class=\"fn\">post<\/span><span class=\"w\">(url, json=payload)<\/span>&#10;        <span class=\"k\">if<\/span> <span class=\"w\">r.status_code <\/span><span class=\"k\">!=<\/span> <span class=\"n\">429<\/span><span class=\"w\">:<\/span>&#10;            <span class=\"k\">return<\/span> <span class=\"w\">r<\/span>&#10;        <span class=\"w\">retry_after <\/span><span class=\"k\">=<\/span> <span class=\"w\">r.<\/span><span class=\"fn\">json<\/span><span class=\"w\">().<\/span><span class=\"fn\">get<\/span><span class=\"w\">(<\/span><span class=\"s\">\"parameters\"<\/span><span class=\"w\">, {}).<\/span><span class=\"fn\">get<\/span><span class=\"w\">(<\/span><span class=\"s\">\"retry_after\"<\/span><span class=\"w\">, <\/span><span class=\"n\">1<\/span><span class=\"w\">)<\/span>&#10;        <span class=\"w\">time.<\/span><span class=\"fn\">sleep<\/span><span class=\"w\">(retry_after)<\/span>&#10;    <span class=\"k\">raise<\/span> <span class=\"fn\">RuntimeError<\/span><span class=\"w\">(<\/span><span class=\"s\">\"too many 429 responses\"<\/span><span class=\"w\">)<\/span><\/code><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div class=\"tye-code-block\">\n<div class=\"tye-code-wrap\">\n<div class=\"tye-editor-bar\">\n            <span class=\"tye-dot2 tye-dot-r\"><\/span><br \/>\n            <span class=\"tye-dot2 tye-dot-y\"><\/span><br \/>\n            <span class=\"tye-dot2 tye-dot-g\"><\/span><br \/>\n            <span class=\"tye-filename\">telethon_flood_wait.py<\/span>\n          <\/div>\n<div class=\"tye-pre\"><code><span class=\"k\">from<\/span> <span class=\"w\">telethon.errors <\/span><span class=\"k\">import<\/span> <span class=\"w\">FloodWaitError<\/span>&#10;<span class=\"k\">import<\/span> <span class=\"w\">asyncio<\/span>&#10;&#10;<span class=\"k\">async<\/span> <span class=\"k\">def<\/span> <span class=\"fn\">send_safely<\/span><span class=\"w\">(client, entity, text):<\/span>&#10;    <span class=\"k\">try<\/span><span class=\"w\">:<\/span>&#10;        <span class=\"k\">await<\/span> <span class=\"w\">client.<\/span><span class=\"fn\">send_message<\/span><span class=\"w\">(entity, text)<\/span>&#10;    <span class=\"k\">except<\/span> <span class=\"fn\">FloodWaitError<\/span> <span class=\"k\">as<\/span> <span class=\"w\">e:<\/span>&#10;        <span class=\"c\"># e.seconds is the FLOOD_WAIT_X value Telegram sent back<\/span>&#10;        <span class=\"k\">await<\/span> <span class=\"w\">asyncio.<\/span><span class=\"fn\">sleep<\/span><span class=\"w\">(e.seconds)<\/span>&#10;        <span class=\"k\">await<\/span> <span class=\"w\">client.<\/span><span class=\"fn\">send_message<\/span><span class=\"w\">(entity, text)<\/span><\/code><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div class=\"tye-box\">\n      <span class=\"tye-box-title\">Pacing guidance that keeps you under the limits in the first place<\/span><\/p>\n<div class=\"tye-box-list\">\n<div class=\"tye-box-item\"><svg viewBox=\"0 0 24 24\"><polyline points=\"20 6 9 17 4 12\"\/><\/svg><span>Avoid sending heavy volume from <strong>brand-new accounts<\/strong>, they get flagged faster than established ones.<\/span><\/div>\n<div class=\"tye-box-item\"><svg viewBox=\"0 0 24 24\"><polyline points=\"20 6 9 17 4 12\"\/><\/svg><span>Ramp up sending volume <strong>progressively<\/strong> instead of starting a script at full throughput.<\/span><\/div>\n<div class=\"tye-box-item\"><svg viewBox=\"0 0 24 24\"><polyline points=\"20 6 9 17 4 12\"\/><\/svg><span>Keep at least <strong>10 to 20 seconds<\/strong> between messages sent from the same account, this is Unipile's own recommendation for linked accounts, not just a Bot API ceiling.<\/span><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/div>\n<p>[\/et_pb_code]<br \/>\n[\/et_pb_column]<br \/>\n[\/et_pb_row]<br \/>\n[\/et_pb_section]<br \/>\n[et_pb_section fb_built=\"1\" _builder_version=\"4.27.3\" background_color=\"transparent\" custom_padding=\"0px|0px|0px|0px|false|false\" global_colors_info=\"{}\"]<br \/>\n[et_pb_row _builder_version=\"4.27.3\" background_color=\"transparent\" custom_padding=\"0px|0px|0px|0px|false|false\" global_colors_info=\"{}\"]<br \/>\n[et_pb_column type=\"4_4\" _builder_version=\"4.27.3\" global_colors_info=\"{}\"]<br \/>\n[et_pb_code _builder_version=\"4.27.3\" global_colors_info=\"{}\"]\n<link href=\"https:\/\/fonts.googleapis.com\/css2?family=Inter:wght@400;500;600;700&#038;family=Poppins:wght@700;800&#038;display=swap\" rel=\"stylesheet\">\n<style>\n#unipile-typ-compare,\n#unipile-typ-compare *,\n#unipile-typ-compare *::before,\n#unipile-typ-compare *::after {\n  margin: 0 !important;\n  padding: 0 !important;\n  box-sizing: border-box !important;\n  border: none !important;\n  outline: none !important;\n  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;\n  line-height: normal !important;\n  letter-spacing: normal !important;\n  text-transform: none !important;\n  text-decoration: none !important;\n  list-style: none !important;\n  background: transparent !important;\n}\n#unipile-typ-compare { display: block !important; overflow-x: hidden !important; max-width: 100% !important; }\n#unipile-typ-compare br { display: none !important; }\n#unipile-typ-compare p { display: contents !important; }\n#unipile-typ-compare .typc-wrap { max-width: 1100px !important; margin: 0 auto !important; padding: 70px 24px !important; }\n#unipile-typ-compare .typc-anchor { display: block !important; position: relative !important; top: -80px !important; visibility: hidden !important; }\n#unipile-typ-compare .typc-badge {\n  display: inline-flex !important; align-items: center !important; gap: 8px !important;\n  background: rgba(59, 185, 139, 0.12) !important; color: #2aaa7e !important;\n  padding: 6px 14px !important; border-radius: 20px !important; font-size: 12px !important;\n  font-weight: 700 !important; text-transform: uppercase !important; letter-spacing: 0.5px !important;\n  width: fit-content !important; margin-bottom: 18px !important;\n}\n#unipile-typ-compare .typc-badge .typc-dot { width: 7px !important; height: 7px !important; background: #3BB98B !important; border-radius: 50% !important; flex-shrink: 0 !important; display: block !important; }\n#unipile-typ-compare h2 { font-family: 'Poppins', sans-serif !important; font-size: 35px !important; font-weight: 700 !important; color: #0f2736 !important; line-height: 1.2 !important; margin-bottom: 16px !important; }\n#unipile-typ-compare .typc-intro { font-size: 17px !important; line-height: 1.8 !important; color: #383838 !important; margin-bottom: 36px !important; display: block !important; }<\/p>\n<p>\/* Desktop table *\/\n#unipile-typ-compare .typc-table-wrap { background: #ffffff !important; border: 1px solid #e5e7eb !important; border-radius: 16px !important; overflow: hidden !important; box-shadow: 0 8px 24px rgba(15,39,54,0.06) !important; display: block !important; margin-bottom: 24px !important; }\n#unipile-typ-compare table { width: 100% !important; border-collapse: collapse !important; }\n#unipile-typ-compare thead tr { background: #0f2736 !important; }\n#unipile-typ-compare thead th { color: #ffffff !important; font-family: 'Poppins', sans-serif !important; font-size: 12.5px !important; font-weight: 700 !important; text-align: left !important; padding: 15px 16px !important; }\n#unipile-typ-compare thead th:first-child { width: 24% !important; }\n#unipile-typ-compare tbody tr { border-top: 1px solid #e5e7eb !important; }\n#unipile-typ-compare tbody tr:nth-child(even) { background: #f8fafc !important; }\n#unipile-typ-compare tbody td { padding: 13px 16px !important; font-size: 13px !important; color: #383838 !important; line-height: 1.55 !important; vertical-align: top !important; }\n#unipile-typ-compare tbody td:first-child { font-weight: 700 !important; color: #0f2736 !important; }\n#unipile-typ-compare .typc-yes { color: #2aaa7e !important; font-weight: 600 !important; }\n#unipile-typ-compare .typc-no { color: #94a3b8 !important; }\n#unipile-typ-compare .typc-partial { color: #8a8c2e !important; font-weight: 600 !important; }<\/p>\n<p>\/* Mobile cards *\/\n#unipile-typ-compare .typc-cards { display: none !important; }\n#unipile-typ-compare .typc-card { background: #ffffff !important; border: 1px solid #e5e7eb !important; border-radius: 14px !important; padding: 18px !important; margin-bottom: 14px !important; }\n#unipile-typ-compare .typc-card-title { font-family: 'Poppins', sans-serif !important; font-size: 15px !important; font-weight: 700 !important; color: #0f2736 !important; margin-bottom: 12px !important; display: block !important; padding-bottom: 10px !important; border-bottom: 1px solid #e5e7eb !important; }\n#unipile-typ-compare .typc-card-row { display: flex !important; justify-content: space-between !important; gap: 12px !important; padding: 7px 0 !important; font-size: 12.5px !important; border-top: 1px solid #f0f1f3 !important; }\n#unipile-typ-compare .typc-card-row:first-of-type { border-top: none !important; }\n#unipile-typ-compare .typc-card-row-label { color: #64748b !important; font-weight: 600 !important; flex-shrink: 0 !important; max-width: 55% !important; }\n#unipile-typ-compare .typc-card-row-val { color: #383838 !important; text-align: right !important; }<\/p>\n<p>#unipile-typ-compare .typc-cta-row { display: flex !important; justify-content: center !important; }\n#unipile-typ-compare .typc-cta {\n  display: inline-flex !important; align-items: center !important; gap: 8px !important;\n  background: #DDDF4C !important; color: #0f2736 !important; padding: 14px 28px !important;\n  border-radius: 8px !important; font-size: 0.95rem !important; font-weight: 600 !important;\n  border: 2px solid #DDDF4C !important; transition: all 0.3s ease !important; cursor: pointer !important;\n  white-space: nowrap !important;\n}\n#unipile-typ-compare .typc-cta:hover { transform: translateY(-5px) !important; }\n#unipile-typ-compare .typc-cta svg { width: 15px !important; height: 15px !important; stroke: currentColor !important; fill: none !important; stroke-width: 2.5 !important; stroke-linecap: round !important; stroke-linejoin: round !important; }<\/p>\n<p>@media (max-width: 900px) {\n  #unipile-typ-compare .typc-wrap { padding: 50px 20px !important; }\n  #unipile-typ-compare h2 { font-size: 28px !important; }\n}\n@media (max-width: 768px) {\n  #unipile-typ-compare .typc-table-wrap { display: none !important; }\n  #unipile-typ-compare .typc-cards { display: block !important; }\n}\n@media (max-width: 600px) {\n  #unipile-typ-compare .typc-wrap { padding: 40px 16px !important; }\n  #unipile-typ-compare h2 { font-size: 26px !important; }\n  #unipile-typ-compare .typc-cta { width: 100% !important; justify-content: center !important; }\n}\n@media (max-width: 400px) {\n  #unipile-typ-compare h2 { font-size: 24px !important; }\n}\n<\/style>\n<div id=\"unipile-typ-compare\">\n<div class=\"typc-wrap\">\n    <span id=\"typ-compare\" class=\"typc-anchor\"><\/span><\/p>\n<div class=\"typc-badge\"><span class=\"typc-dot\"><\/span><span>Recap<\/span><\/div>\n<h2>Python Telegram Bot API vs Telethon\/Pyrogram vs Unipile SDK<\/h2>\n<div class=\"typc-intro\">The same recap in table form: what each Python path actually requires, and where it stops.<\/div>\n<div class=\"typc-table-wrap\">\n<table>\n<thead>\n<tr>\n<th>Dimension<\/th>\n<th>Bot API (requests \/ python-telegram-bot)<\/th>\n<th>Telethon \/ Pyrogram (MTProto)<\/th>\n<th>Unipile Python SDK<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Can message a user first<\/td>\n<td class=\"typc-no\">No<\/td>\n<td class=\"typc-yes\">Yes, privacy-dependent<\/td>\n<td class=\"typc-yes\">Yes<\/td>\n<\/tr>\n<tr>\n<td>Setup requirement<\/td>\n<td>Bot token from BotFather<\/td>\n<td><code>api_id<\/code> \/ <code>api_hash<\/code> from my.telegram.org<\/td>\n<td>Linked account via QR code or Hosted Auth<\/td>\n<\/tr>\n<tr>\n<td>Session management<\/td>\n<td>Token-based, nothing to persist<\/td>\n<td>You persist the session file yourself<\/td>\n<td>Managed by Telegram's own Devices feature<\/td>\n<\/tr>\n<tr>\n<td>2FA \/ SESSION_PASSWORD_NEEDED<\/td>\n<td class=\"typc-no\">Not applicable<\/td>\n<td class=\"typc-partial\">You handle the SRP exchange<\/td>\n<td class=\"typc-yes\">Handled for you<\/td>\n<\/tr>\n<tr>\n<td>Group participants (get \/ add \/ remove)<\/td>\n<td class=\"typc-partial\">Limited to bot permissions<\/td>\n<td class=\"typc-yes\">Yes, self-built<\/td>\n<td class=\"typc-yes\">Yes, dedicated v2 endpoints<\/td>\n<\/tr>\n<tr>\n<td>Channels, communities, broadcasts<\/td>\n<td class=\"typc-yes\">Yes, if added as admin<\/td>\n<td class=\"typc-yes\">Yes<\/td>\n<td class=\"typc-no\">Not supported<\/td>\n<\/tr>\n<tr>\n<td>Best for<\/td>\n<td>Notifications and support bots<\/td>\n<td>A fully custom Python MTProto client<\/td>\n<td>Shipping fast without owning MTProto<\/td>\n<\/tr>\n<\/tbody>\n<\/table><\/div>\n<div class=\"typc-cards\">\n<div class=\"typc-card\">\n        <span class=\"typc-card-title\">Can message a user first<\/span><\/p>\n<div class=\"typc-card-row\"><span class=\"typc-card-row-label\">Bot API<\/span><span class=\"typc-card-row-val\">No<\/span><\/div>\n<div class=\"typc-card-row\"><span class=\"typc-card-row-label\">Telethon \/ Pyrogram<\/span><span class=\"typc-card-row-val\">Yes, privacy-dependent<\/span><\/div>\n<div class=\"typc-card-row\"><span class=\"typc-card-row-label\">Unipile SDK<\/span><span class=\"typc-card-row-val\">Yes<\/span><\/div>\n<\/p><\/div>\n<div class=\"typc-card\">\n        <span class=\"typc-card-title\">Setup requirement<\/span><\/p>\n<div class=\"typc-card-row\"><span class=\"typc-card-row-label\">Bot API<\/span><span class=\"typc-card-row-val\">Bot token<\/span><\/div>\n<div class=\"typc-card-row\"><span class=\"typc-card-row-label\">Telethon \/ Pyrogram<\/span><span class=\"typc-card-row-val\">api_id \/ api_hash<\/span><\/div>\n<div class=\"typc-card-row\"><span class=\"typc-card-row-label\">Unipile SDK<\/span><span class=\"typc-card-row-val\">Linked account<\/span><\/div>\n<\/p><\/div>\n<div class=\"typc-card\">\n        <span class=\"typc-card-title\">Session management<\/span><\/p>\n<div class=\"typc-card-row\"><span class=\"typc-card-row-label\">Bot API<\/span><span class=\"typc-card-row-val\">Nothing to persist<\/span><\/div>\n<div class=\"typc-card-row\"><span class=\"typc-card-row-label\">Telethon \/ Pyrogram<\/span><span class=\"typc-card-row-val\">Self-persisted session<\/span><\/div>\n<div class=\"typc-card-row\"><span class=\"typc-card-row-label\">Unipile SDK<\/span><span class=\"typc-card-row-val\">Managed via Devices<\/span><\/div>\n<\/p><\/div>\n<div class=\"typc-card\">\n        <span class=\"typc-card-title\">2FA \/ SESSION_PASSWORD_NEEDED<\/span><\/p>\n<div class=\"typc-card-row\"><span class=\"typc-card-row-label\">Bot API<\/span><span class=\"typc-card-row-val\">Not applicable<\/span><\/div>\n<div class=\"typc-card-row\"><span class=\"typc-card-row-label\">Telethon \/ Pyrogram<\/span><span class=\"typc-card-row-val\">Self-built SRP<\/span><\/div>\n<div class=\"typc-card-row\"><span class=\"typc-card-row-label\">Unipile SDK<\/span><span class=\"typc-card-row-val\">Handled for you<\/span><\/div>\n<\/p><\/div>\n<div class=\"typc-card\">\n        <span class=\"typc-card-title\">Group participants (get \/ add \/ remove)<\/span><\/p>\n<div class=\"typc-card-row\"><span class=\"typc-card-row-label\">Bot API<\/span><span class=\"typc-card-row-val\">Limited to bot permissions<\/span><\/div>\n<div class=\"typc-card-row\"><span class=\"typc-card-row-label\">Telethon \/ Pyrogram<\/span><span class=\"typc-card-row-val\">Self-built<\/span><\/div>\n<div class=\"typc-card-row\"><span class=\"typc-card-row-label\">Unipile SDK<\/span><span class=\"typc-card-row-val\">Dedicated v2 endpoints<\/span><\/div>\n<\/p><\/div>\n<div class=\"typc-card\">\n        <span class=\"typc-card-title\">Channels, communities, broadcasts<\/span><\/p>\n<div class=\"typc-card-row\"><span class=\"typc-card-row-label\">Bot API<\/span><span class=\"typc-card-row-val\">Yes, as admin<\/span><\/div>\n<div class=\"typc-card-row\"><span class=\"typc-card-row-label\">Telethon \/ Pyrogram<\/span><span class=\"typc-card-row-val\">Yes<\/span><\/div>\n<div class=\"typc-card-row\"><span class=\"typc-card-row-label\">Unipile SDK<\/span><span class=\"typc-card-row-val\">Not supported<\/span><\/div>\n<\/p><\/div>\n<div class=\"typc-card\">\n        <span class=\"typc-card-title\">Best for<\/span><\/p>\n<div class=\"typc-card-row\"><span class=\"typc-card-row-label\">Bot API<\/span><span class=\"typc-card-row-val\">Notifications, support bots<\/span><\/div>\n<div class=\"typc-card-row\"><span class=\"typc-card-row-label\">Telethon \/ Pyrogram<\/span><span class=\"typc-card-row-val\">Fully custom client<\/span><\/div>\n<div class=\"typc-card-row\"><span class=\"typc-card-row-label\">Unipile SDK<\/span><span class=\"typc-card-row-val\">Shipping fast, no MTProto<\/span><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div class=\"typc-cta-row\">\n      <a class=\"typc-cta\" href=\"https:\/\/dashboard.unipile.com\/signup\/\" target=\"_blank\" rel=\"noopener\"><span>Build it with the Unipile SDK<\/span><svg viewBox=\"0 0 24 24\"><line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\"\/><polyline points=\"12 5 19 12 12 19\"\/><\/svg><\/a>\n    <\/div>\n<\/p><\/div>\n<\/div>\n<p><script>\n(function(){\n  var root = document.getElementById('unipile-typ-compare');\n  if (!root) return;\n  root.addEventListener('click', function(e){\n    var el = e.target.closest('[data-upl-link]');\n    if (!el || !root.contains(el)) return;\n    e.preventDefault();\n    window.open(el.getAttribute('data-upl-link'), el.getAttribute('data-upl-target') || '_blank');\n  });\n})();\n<\/script><\/p>\n<p>[\/et_pb_code]<br \/>\n[\/et_pb_column]<br \/>\n[\/et_pb_row]<br \/>\n[\/et_pb_section]<br \/>\n[et_pb_section fb_built=\"1\" _builder_version=\"4.27.3\" background_color=\"transparent\" custom_padding=\"0px|0px|0px|0px|false|false\" global_colors_info=\"{}\"]<br \/>\n[et_pb_row _builder_version=\"4.27.3\" background_color=\"transparent\" custom_padding=\"0px|0px|0px|0px|false|false\" global_colors_info=\"{}\"]<br \/>\n[et_pb_column type=\"4_4\" _builder_version=\"4.27.3\" global_colors_info=\"{}\"]<br \/>\n[et_pb_code _builder_version=\"4.27.3\" global_colors_info=\"{}\"]<br \/>\n<script type=\"application\/ld+json\">\n{\n  \"@context\": \"https:\/\/schema.org\",\n  \"@type\": \"FAQPage\",\n  \"mainEntity\": [\n    {\n      \"@type\": \"Question\",\n      \"name\": \"Can I send a Telegram message in Python without a library?\",\n      \"acceptedAnswer\": { \"@type\": \"Answer\", \"text\": \"Yes. The Telegram Bot API is a plain HTTP interface, so a single POST request with Python's requests library to https:\/\/api.telegram.org\/bot<TOKEN>\/sendMessage, with a chat_id and text in the JSON body, is enough. No SDK or wrapper library is required for this call.\" }\n    },\n    {\n      \"@type\": \"Question\",\n      \"name\": \"What is the difference between the Python Telegram Bot API and python-telegram-bot?\",\n      \"acceptedAnswer\": { \"@type\": \"Answer\", \"text\": \"The Telegram Bot API is Telegram's own HTTP interface, callable from Python with requests or any HTTP client. python-telegram-bot is a third-party Python library that wraps those same HTTP endpoints in an async object model, with an Application class, typed methods like bot.send_message, and built-in update polling or webhook handling.\" }\n    },\n    {\n      \"@type\": \"Question\",\n      \"name\": \"Why can't my Python Telegram bot message a user who never wrote to it?\",\n      \"acceptedAnswer\": { \"@type\": \"Answer\", \"text\": \"This is a structural rule of the Bot API, not a bug in your code. A bot cannot call sendMessage against a chat_id until that user has sent at least one message to the bot first. No parameter or Python library works around it. A real linked Telegram account, through Telethon, Pyrogram, or the Unipile SDK, does not have this restriction.\" }\n    },\n    {\n      \"@type\": \"Question\",\n      \"name\": \"Do I need api_id and api_hash for the Python Telegram Bot API?\",\n      \"acceptedAnswer\": { \"@type\": \"Answer\", \"text\": \"No. The Bot API only needs a bot token issued by BotFather. api_id and api_hash from my.telegram.org are required for the Client API (MTProto), the protocol used by Telethon, Pyrogram, and any client that logs in as a real user account instead of a bot.\" }\n    },\n    {\n      \"@type\": \"Question\",\n      \"name\": \"How do I handle Telegram's SESSION_PASSWORD_NEEDED error in Python?\",\n      \"acceptedAnswer\": { \"@type\": \"Answer\", \"text\": \"SESSION_PASSWORD_NEEDED is a 400 error Telegram returns from auth.signIn when the account has two-factor authentication enabled. Telethon raises it as SessionPasswordNeededError. Clearing it means running the SRP protocol and calling auth.checkPassword with the account's cloud password, which Telethon and Pyrogram both handle when you pass the password to their login method.\" }\n    },\n    {\n      \"@type\": \"Question\",\n      \"name\": \"What happens if my Python script exceeds Telegram's rate limits?\",\n      \"acceptedAnswer\": { \"@type\": \"Answer\", \"text\": \"The Bot API returns a 429 status once you exceed roughly one message per second to the same chat, 20 messages per minute in a group, or about 30 messages per second when broadcasting across chats. The response includes a retry_after value in seconds. On the MTProto side, the equivalent is a 420 FLOOD error or a FLOOD_WAIT_X exception, where X is the number of seconds to wait before retrying.\" }\n    },\n    {\n      \"@type\": \"Question\",\n      \"name\": \"Can I use the Telegram API in Python without maintaining an MTProto client?\",\n      \"acceptedAnswer\": { \"@type\": \"Answer\", \"text\": \"Yes. The Unipile Python SDK connects an existing Telegram user account through Telegram's own Devices feature, either a QR code scan or Hosted Auth, and exposes messaging through a few SDK calls such as start_chat. There is no api_id to request, no MTProto implementation, and no session file or 2FA branch to write yourself.\" }\n    },\n    {\n      \"@type\": \"Question\",\n      \"name\": \"Does the Unipile Python SDK support Telegram groups and channels?\",\n      \"acceptedAnswer\": { \"@type\": \"Answer\", \"text\": \"Group participant management is supported, listing, adding, and removing participants through dedicated v2 endpoints. Channels, communities, broadcasts, group administration actions like approving or promoting members, chat archiving, and voice or video calls are not supported.\" }\n    }\n  ]\n}\n<\/script><\/p>\n<link href=\"https:\/\/fonts.googleapis.com\/css2?family=Inter:wght@400;500;600;700&#038;family=Poppins:wght@600;700&#038;display=swap\" rel=\"stylesheet\"><span id=\"faq-typ\" style=\"display:block;position:relative;top:-80px;visibility:hidden;\"><\/span><br \/>\n<style>\n#upl-typ-faq { font-family:'Inter',sans-serif; padding:80px 20px; max-width:900px; margin:0 auto; background:transparent!important; }\n#upl-typ-faq *, #upl-typ-faq *::before, #upl-typ-faq *::after { margin:0!important; padding:0!important; box-sizing:border-box!important; }\n#upl-typ-faq .upl-faq-header { text-align:center!important; margin-bottom:60px!important; }\n#upl-typ-faq .upl-faq-title { font-family:'Poppins',sans-serif!important; font-size:clamp(32px,5vw,38px)!important; font-weight:700!important; color:#0f2736!important; margin-bottom:16px!important; line-height:1.2!important; }\n#upl-typ-faq .upl-faq-subtitle { font-size:17px!important; color:#383838!important; max-width:700px!important; margin:0 auto!important; line-height:1.6!important; }\n#upl-typ-faq .upl-faq-list { display:flex!important; flex-direction:column!important; gap:12px!important; }\n#upl-typ-faq .upl-faq-item { background:#ffffff!important; border:1px solid #e5e7eb!important; border-radius:16px!important; overflow:hidden!important; transition:all 0.3s ease!important; }\n#upl-typ-faq .upl-faq-item:hover { border-color:#3BB98B!important; box-shadow:0 4px 20px rgba(59,185,139,0.08)!important; }\n#upl-typ-faq .upl-faq-item.active { border-color:#3BB98B!important; box-shadow:0 8px 30px rgba(59,185,139,0.12)!important; }\n#upl-typ-faq .upl-faq-question { width:100%!important; display:flex!important; align-items:flex-start!important; justify-content:space-between!important; gap:20px!important; padding:24px 28px!important; background:transparent!important; border:none!important; cursor:pointer!important; text-align:left!important; }\n#upl-typ-faq .upl-faq-question-content { display:flex!important; align-items:flex-start!important; gap:16px!important; flex:1!important; }\n#upl-typ-faq .upl-faq-number { flex-shrink:0!important; padding:6px 12px!important; background:rgba(59,185,139,0.12)!important; color:#3BB98B!important; border-radius:20px!important; font-size:0.8rem!important; font-weight:600!important; }\n#upl-typ-faq .upl-faq-item.active .upl-faq-number { background:rgba(59,185,139,0.2)!important; color:#2a9d6e!important; }\n#upl-typ-faq .upl-faq-question-text { font-family:'Poppins',sans-serif!important; font-size:1.1rem!important; font-weight:600!important; color:#0f2736!important; line-height:1.4!important; padding-top:4px!important; }\n#upl-typ-faq .upl-faq-icon { flex-shrink:0!important; width:36px!important; height:36px!important; background:#f4f5f7!important; border-radius:50%!important; display:flex!important; align-items:center!important; justify-content:center!important; transition:all 0.3s ease!important; margin-top:2px!important; }\n#upl-typ-faq .upl-faq-icon svg { width:18px!important; height:18px!important; color:#64748b!important; transition:all 0.3s ease!important; }\n#upl-typ-faq .upl-faq-item:hover .upl-faq-icon { background:rgba(59,185,139,0.1)!important; }\n#upl-typ-faq .upl-faq-item:hover .upl-faq-icon svg { color:#3BB98B!important; }\n#upl-typ-faq .upl-faq-item.active .upl-faq-icon { background:#3BB98B!important; transform:rotate(45deg)!important; }\n#upl-typ-faq .upl-faq-item.active .upl-faq-icon svg { color:#ffffff!important; }\n#upl-typ-faq .upl-faq-answer { max-height:0!important; overflow:hidden!important; transition:max-height 0.4s ease!important; }\n#upl-typ-faq .upl-faq-item.active .upl-faq-answer { max-height:600px!important; }\n#upl-typ-faq .upl-faq-answer-content { padding:0 28px 28px 76px!important; color:#475569!important; font-size:1rem!important; line-height:1.7!important; }\n#upl-typ-faq .upl-faq-answer-content strong { color:#0f2736!important; font-weight:600!important; }\n#upl-typ-faq .upl-faq-answer-content a { color:#3BB98B!important; text-decoration:underline!important; }\n#upl-typ-faq .upl-faq-answer-content code { font-family:monospace!important; background:#f1f5f9!important; padding:2px 6px!important; border-radius:3px!important; font-size:0.85em!important; }\n#upl-typ-faq .upl-faq-cta { margin-top:50px!important; display:flex!important; align-items:center!important; justify-content:space-between!important; gap:20px!important; padding:20px 28px!important; background:#ffffff!important; border:1px solid #e5e7eb!important; border-radius:12px!important; }\n#upl-typ-faq .upl-faq-cta-text { color:#475569!important; font-size:1rem!important; }\n#upl-typ-faq .upl-faq-cta-button { display:inline-flex!important; align-items:center!important; gap:10px!important; background:#DDDF4C!important; color:#0F2836!important; padding:13px 20px!important; border-radius:8px!important; text-decoration:none!important; font-weight:700!important; font-size:1rem!important; border:none!important; cursor:pointer!important; white-space:nowrap!important; }\n#upl-typ-faq .upl-faq-cta-button:hover { transform:translateY(-2px)!important; }\n@media (max-width:768px) {\n  #upl-typ-faq { padding:60px 16px!important; }\n  #upl-typ-faq .upl-faq-answer-content { padding:0 20px 20px 20px!important; }\n  #upl-typ-faq .upl-faq-question { padding:18px 20px!important; }\n  #upl-typ-faq .upl-faq-cta { flex-direction:column!important; align-items:flex-start!important; }\n}\n\/* Defensive wpautop parade (additive only, does not touch template structure\/JS) *\/\n#upl-typ-faq br { display: none !important; }\n<\/style>\n<section id=\"upl-typ-faq\">\n<div class=\"upl-faq-header\">\n<h2 class=\"upl-faq-title\">Telegram API in Python - FAQ<\/h2>\n<pee class=\"upl-faq-subtitle\">Common questions about the Python Telegram Bot API, python-telegram-bot, Telethon, Pyrogram, and connecting a real account with Unipile.<\/pee>\n  <\/div>\n<div class=\"upl-faq-list\">\n<div class=\"upl-faq-item active\">\n      <button class=\"upl-faq-question\" aria-expanded=\"true\"><\/p>\n<div class=\"upl-faq-question-content\">\n          <span class=\"upl-faq-number\">01<\/span><br \/>\n          <span class=\"upl-faq-question-text\">Can I send a Telegram message in Python without a library?<\/span>\n        <\/div>\n<div class=\"upl-faq-icon\">\n          <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\"><line x1=\"12\" y1=\"5\" x2=\"12\" y2=\"19\"\/><line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\"\/><\/svg>\n        <\/div>\n<p>      <\/button><\/p>\n<div class=\"upl-faq-answer\">\n<div class=\"upl-faq-answer-content\"><pee>Yes. The <strong>Telegram Bot API<\/strong> is a plain HTTP interface, so a single <code>POST<\/code> request with Python's <code>requests<\/code> library to <code>https:\/\/api.telegram.org\/bot&lt;TOKEN&gt;\/sendMessage<\/code>, with a <code>chat_id<\/code> and <code>text<\/code> in the JSON body, is enough. No SDK or wrapper library is required for this call.<\/pee><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div class=\"upl-faq-item\">\n      <button class=\"upl-faq-question\" aria-expanded=\"false\"><\/p>\n<div class=\"upl-faq-question-content\">\n          <span class=\"upl-faq-number\">02<\/span><br \/>\n          <span class=\"upl-faq-question-text\">What is the difference between the Python Telegram Bot API and python-telegram-bot?<\/span>\n        <\/div>\n<div class=\"upl-faq-icon\">\n          <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\"><line x1=\"12\" y1=\"5\" x2=\"12\" y2=\"19\"\/><line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\"\/><\/svg>\n        <\/div>\n<p>      <\/button><\/p>\n<div class=\"upl-faq-answer\">\n<div class=\"upl-faq-answer-content\"><pee>The <strong>Telegram Bot API<\/strong> is Telegram's own HTTP interface, callable from Python with <code>requests<\/code> or any HTTP client. <code>python-telegram-bot<\/code> is a third-party Python library that wraps those same HTTP endpoints in an async object model, with an <code>Application<\/code> class, typed methods like <code>bot.send_message<\/code>, and built-in update polling or webhook handling.<\/pee><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div class=\"upl-faq-item\">\n      <button class=\"upl-faq-question\" aria-expanded=\"false\"><\/p>\n<div class=\"upl-faq-question-content\">\n          <span class=\"upl-faq-number\">03<\/span><br \/>\n          <span class=\"upl-faq-question-text\">Why can't my Python Telegram bot message a user who never wrote to it?<\/span>\n        <\/div>\n<div class=\"upl-faq-icon\">\n          <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\"><line x1=\"12\" y1=\"5\" x2=\"12\" y2=\"19\"\/><line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\"\/><\/svg>\n        <\/div>\n<p>      <\/button><\/p>\n<div class=\"upl-faq-answer\">\n<div class=\"upl-faq-answer-content\"><pee>This is a structural rule of the Bot API, not a bug in your code. A bot cannot call <code>sendMessage<\/code> against a <code>chat_id<\/code> until that user has sent at least one message to the bot first. No parameter or Python library works around it. A real linked Telegram account, through Telethon, Pyrogram, or the <a href=\"https:\/\/dashboard.unipile.com\/signup\/\" target=\"_blank\" rel=\"noopener\">Unipile SDK<\/a>, does not have this restriction.<\/pee><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div class=\"upl-faq-item\">\n      <button class=\"upl-faq-question\" aria-expanded=\"false\"><\/p>\n<div class=\"upl-faq-question-content\">\n          <span class=\"upl-faq-number\">04<\/span><br \/>\n          <span class=\"upl-faq-question-text\">Do I need api_id and api_hash for the Python Telegram Bot API?<\/span>\n        <\/div>\n<div class=\"upl-faq-icon\">\n          <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\"><line x1=\"12\" y1=\"5\" x2=\"12\" y2=\"19\"\/><line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\"\/><\/svg>\n        <\/div>\n<p>      <\/button><\/p>\n<div class=\"upl-faq-answer\">\n<div class=\"upl-faq-answer-content\"><pee>No. The Bot API only needs a bot token issued by BotFather. <code>api_id<\/code> and <code>api_hash<\/code> from my.telegram.org are required for the Client API (MTProto), the protocol used by Telethon, Pyrogram, and any client that logs in as a real user account instead of a bot.<\/pee><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div class=\"upl-faq-item\">\n      <button class=\"upl-faq-question\" aria-expanded=\"false\"><\/p>\n<div class=\"upl-faq-question-content\">\n          <span class=\"upl-faq-number\">05<\/span><br \/>\n          <span class=\"upl-faq-question-text\">How do I handle Telegram's SESSION_PASSWORD_NEEDED error in Python?<\/span>\n        <\/div>\n<div class=\"upl-faq-icon\">\n          <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\"><line x1=\"12\" y1=\"5\" x2=\"12\" y2=\"19\"\/><line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\"\/><\/svg>\n        <\/div>\n<p>      <\/button><\/p>\n<div class=\"upl-faq-answer\">\n<div class=\"upl-faq-answer-content\"><pee><code>SESSION_PASSWORD_NEEDED<\/code> is a 400 error Telegram returns from <code>auth.signIn<\/code> when the account has two-factor authentication enabled. Telethon raises it as <code>SessionPasswordNeededError<\/code>. Clearing it means running the SRP protocol and calling <code>auth.checkPassword<\/code> with the account's cloud password, which Telethon and Pyrogram both handle when you pass the password to their login method.<\/pee><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div class=\"upl-faq-item\">\n      <button class=\"upl-faq-question\" aria-expanded=\"false\"><\/p>\n<div class=\"upl-faq-question-content\">\n          <span class=\"upl-faq-number\">06<\/span><br \/>\n          <span class=\"upl-faq-question-text\">What happens if my Python script exceeds Telegram's rate limits?<\/span>\n        <\/div>\n<div class=\"upl-faq-icon\">\n          <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\"><line x1=\"12\" y1=\"5\" x2=\"12\" y2=\"19\"\/><line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\"\/><\/svg>\n        <\/div>\n<p>      <\/button><\/p>\n<div class=\"upl-faq-answer\">\n<div class=\"upl-faq-answer-content\"><pee>The Bot API returns a <strong>429<\/strong> status once you exceed roughly one message per second to the same chat, 20 messages per minute in a group, or about 30 messages per second when broadcasting across chats. The response includes a <code>retry_after<\/code> value in seconds. On the MTProto side, the equivalent is a <strong>420 FLOOD<\/strong> error or a <code>FLOOD_WAIT_X<\/code> exception, where X is the number of seconds to wait before retrying.<\/pee><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div class=\"upl-faq-item\">\n      <button class=\"upl-faq-question\" aria-expanded=\"false\"><\/p>\n<div class=\"upl-faq-question-content\">\n          <span class=\"upl-faq-number\">07<\/span><br \/>\n          <span class=\"upl-faq-question-text\">Can I use the Telegram API in Python without maintaining an MTProto client?<\/span>\n        <\/div>\n<div class=\"upl-faq-icon\">\n          <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\"><line x1=\"12\" y1=\"5\" x2=\"12\" y2=\"19\"\/><line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\"\/><\/svg>\n        <\/div>\n<p>      <\/button><\/p>\n<div class=\"upl-faq-answer\">\n<div class=\"upl-faq-answer-content\"><pee>Yes. The <strong>Unipile Python SDK<\/strong> connects an existing Telegram user account through Telegram's own Devices feature, either a QR code scan or Hosted Auth, and exposes messaging through a few SDK calls such as <code>start_chat<\/code>. There is no <code>api_id<\/code> to request, no MTProto implementation, and no session file or 2FA branch to write yourself.<\/pee><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div class=\"upl-faq-item\">\n      <button class=\"upl-faq-question\" aria-expanded=\"false\"><\/p>\n<div class=\"upl-faq-question-content\">\n          <span class=\"upl-faq-number\">08<\/span><br \/>\n          <span class=\"upl-faq-question-text\">Does the Unipile Python SDK support Telegram groups and channels?<\/span>\n        <\/div>\n<div class=\"upl-faq-icon\">\n          <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\"><line x1=\"12\" y1=\"5\" x2=\"12\" y2=\"19\"\/><line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\"\/><\/svg>\n        <\/div>\n<p>      <\/button><\/p>\n<div class=\"upl-faq-answer\">\n<div class=\"upl-faq-answer-content\"><pee>Group participant management is supported: listing, adding, and removing participants through dedicated <strong>v2<\/strong> endpoints. Channels, communities, broadcasts, group administration actions like approving or promoting members, chat archiving, and voice or video calls are not supported.<\/pee><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div class=\"upl-faq-cta\">\n    <pee class=\"upl-faq-cta-text\">Still have questions? Our team is here to help.<\/pee>\n    <span class=\"upl-faq-cta-button\" onclick=\"if(window.$crisp){$crisp.push(['do','chat:open'])}\"><span>Talk to an expert<\/span><svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\"\/><polyline points=\"12 5 19 12 12 19\"\/><\/svg><\/span>\n  <\/div>\n<\/section>\n<p><script>\n(function(){\n  function initFaq(){\n    var faq=document.getElementById('upl-typ-faq');\n    if(!faq)return;\n    faq.querySelectorAll('.upl-faq-question').forEach(function(btn){\n      btn.addEventListener('click',function(){\n        var item=btn.closest('.upl-faq-item');\n        var isActive=item.classList.contains('active');\n        faq.querySelectorAll('.upl-faq-item').forEach(function(i){i.classList.remove('active');i.querySelector('.upl-faq-question').setAttribute('aria-expanded','false');});\n        if(!isActive){item.classList.add('active');btn.setAttribute('aria-expanded','true');}\n      });\n    });\n    faq.addEventListener('click',function(e){\n      var el=e.target.closest('[data-upl-link]');\n      if(!el)return;\n      e.preventDefault();\n      window.open(el.getAttribute('data-upl-link'),el.getAttribute('data-upl-target')||'_blank');\n    });\n  }\n  if(document.readyState==='loading'){document.addEventListener('DOMContentLoaded',initFaq);}else{initFaq();}\n})();\n<\/script><\/p>\n<p>[\/et_pb_code]<br \/>\n[\/et_pb_column]<br \/>\n[\/et_pb_row]<br \/>\n[\/et_pb_section]<br \/>\n[et_pb_section fb_built=\"1\" _builder_version=\"4.27.3\" background_color=\"transparent\" custom_padding=\"0px|0px|40px|0px|false|false\" global_colors_info=\"{}\"]<br \/>\n[et_pb_row _builder_version=\"4.27.3\" background_color=\"transparent\" custom_padding=\"0px|0px|0px|0px|false|false\" global_colors_info=\"{}\"]<br \/>\n[et_pb_column type=\"4_4\" _builder_version=\"4.27.3\" global_colors_info=\"{}\"]<br \/>\n[et_pb_code _builder_version=\"4.27.3\" global_colors_info=\"{}\"]\n<link href=\"https:\/\/fonts.googleapis.com\/css2?family=Inter:wght@400;500;600;700&#038;family=Poppins:wght@700;800&#038;display=swap\" rel=\"stylesheet\">\n<style>\n#unipile-typ-cta,\n#unipile-typ-cta *,\n#unipile-typ-cta *::before,\n#unipile-typ-cta *::after {\n  margin: 0 !important;\n  padding: 0 !important;\n  box-sizing: border-box !important;\n  border: none !important;\n  outline: none !important;\n  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;\n  line-height: normal !important;\n  letter-spacing: normal !important;\n  text-transform: none !important;\n  text-decoration: none !important;\n  list-style: none !important;\n  background: transparent !important;\n}\n#unipile-typ-cta { display: block !important; overflow-x: hidden !important; max-width: 100% !important; }\n#unipile-typ-cta br { display: none !important; }\n#unipile-typ-cta p { display: contents !important; }\n#unipile-typ-cta .typf-wrap { max-width: 1100px !important; margin: 0 auto !important; padding: 50px 24px 80px !important; }\n#unipile-typ-cta .typf-card { background: #0f2736 !important; border-radius: 20px !important; padding: 48px !important; text-align: center !important; }\n#unipile-typ-cta .typf-eyebrow { color: #3BB98B !important; font-size: 12px !important; font-weight: 700 !important; text-transform: uppercase !important; letter-spacing: 0.5px !important; margin-bottom: 14px !important; display: block !important; }\n#unipile-typ-cta h2 { font-family: 'Poppins', sans-serif !important; font-size: 32px !important; font-weight: 700 !important; color: #ffffff !important; line-height: 1.25 !important; margin: 0 0 14px !important; }\n#unipile-typ-cta .typf-desc { color: rgba(255,255,255,0.75) !important; font-size: 15.5px !important; line-height: 1.75 !important; margin: 0 0 30px !important; display: block !important; }\n#unipile-typ-cta .typf-actions { display: flex !important; align-items: center !important; justify-content: center !important; gap: 14px !important; flex-wrap: wrap !important; margin-bottom: 26px !important; }\n#unipile-typ-cta .typf-cta-primary {\n  display: inline-flex !important; align-items: center !important; gap: 8px !important;\n  background: #DDDF4C !important; color: #0f2736 !important; padding: 14px 28px !important;\n  border-radius: 8px !important; font-size: 0.95rem !important; font-weight: 600 !important;\n  border: 2px solid #DDDF4C !important; transition: all 0.3s ease !important; cursor: pointer !important;\n  white-space: nowrap !important;\n}\n#unipile-typ-cta .typf-cta-primary:hover { transform: translateY(-5px) !important; }\n#unipile-typ-cta .typf-cta-primary svg { width: 15px !important; height: 15px !important; stroke: currentColor !important; fill: none !important; stroke-width: 2.5 !important; stroke-linecap: round !important; stroke-linejoin: round !important; }\n#unipile-typ-cta .typf-cta-secondary {\n  display: inline-flex !important; align-items: center !important; gap: 8px !important;\n  background: transparent !important; color: #ffffff !important; padding: 12px 24px !important;\n  border-radius: 8px !important; border: 2px solid rgba(255,255,255,0.3) !important;\n  font-size: 0.95rem !important; font-weight: 600 !important; transition: all 0.3s ease !important;\n  cursor: pointer !important; white-space: nowrap !important;\n}\n#unipile-typ-cta .typf-cta-secondary:hover { border-color: #ffffff !important; }\n#unipile-typ-cta .typf-links { display: flex !important; align-items: center !important; justify-content: center !important; gap: 20px !important; flex-wrap: wrap !important; padding-top: 22px !important; border-top: 1px solid rgba(255,255,255,0.1) !important; }\n#unipile-typ-cta .typf-links a { color: rgba(255,255,255,0.65) !important; font-size: 13.5px !important; text-decoration: underline !important; }<\/p>\n<p>@media (max-width: 900px) {\n  #unipile-typ-cta .typf-wrap { padding: 40px 20px 60px !important; }\n  #unipile-typ-cta .typf-card { padding: 36px 24px !important; }\n  #unipile-typ-cta h2 { font-size: 28px !important; }\n}\n@media (max-width: 600px) {\n  #unipile-typ-cta .typf-wrap { padding: 32px 16px 48px !important; }\n  #unipile-typ-cta .typf-card { padding: 30px 20px !important; }\n  #unipile-typ-cta h2 { font-size: 26px !important; }\n  #unipile-typ-cta .typf-actions { flex-direction: column !important; width: 100% !important; }\n  #unipile-typ-cta .typf-cta-primary, #unipile-typ-cta .typf-cta-secondary { width: 100% !important; justify-content: center !important; }\n  #unipile-typ-cta .typf-links { flex-direction: column !important; gap: 10px !important; }\n}\n@media (max-width: 400px) {\n  #unipile-typ-cta h2 { font-size: 24px !important; }\n}<\/p>\n<p>#unipile-toc a{text-decoration:none!important;color:inherit!important}\n#unipile-typ-compare a{text-decoration:none!important;color:inherit!important}\n#unipile-typ-cta a{text-decoration:none!important;color:inherit!important}\n#unipile-typ-errors a{text-decoration:none!important;color:inherit!important}\n#unipile-typ-hero a{text-decoration:none!important;color:inherit!important}\n#unipile-typ-mtproto a{text-decoration:none!important;color:inherit!important}\n#unipile-typ-paths a{text-decoration:none!important;color:inherit!important}\n#unipile-typ-ptb a{text-decoration:none!important;color:inherit!important}\n#unipile-typ-requests a{text-decoration:none!important;color:inherit!important}\n#unipile-typ-sdk a{text-decoration:none!important;color:inherit!important}\n#upl-typ-faq a{text-decoration:none!important;color:inherit!important}<\/style>\n<div id=\"unipile-typ-cta\">\n<div class=\"typf-wrap\">\n<div class=\"typf-card\">\n      <span class=\"typf-eyebrow\">Telegram API Python, done right<\/span><\/p>\n<h2>Build your telegram bot api python integration with Unipile<\/h2>\n<div class=\"typf-desc\">Skip the MTProto session files, skip the bot-only limitation. Connect an existing Telegram account through Unipile's Python SDK and unify it with WhatsApp, LinkedIn, Instagram, Gmail, Outlook and IMAP in one API.<\/div>\n<div class=\"typf-actions\">\n        <a class=\"typf-cta-primary\" href=\"https:\/\/dashboard.unipile.com\/signup\/\" target=\"_blank\" rel=\"noopener\"><span>Build with Unipile<\/span><svg viewBox=\"0 0 24 24\"><line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\"\/><polyline points=\"12 5 19 12 12 19\"\/><\/svg><\/a><br \/>\n        <a class=\"typf-cta-secondary\" href=\"https:\/\/developer.unipile.com\/docs\/getting-started\" target=\"_blank\" rel=\"noopener\"><span>Read the docs<\/span><\/a> <a class=\"typf-cta-secondary\" href=\"\/communication-api\/messaging-api\/telegram-api\/\"><span>See the Telegram API page<\/span><\/a>\n      <\/div>\n<div class=\"typf-links\">\n        <a href=\"\/how-to-get-telegram-api-the-ultimate-step-by-step-guide\/\">Getting Telegram API access, step by step<\/a><br \/>\n        <a href=\"\/telegram-api-send-message-a-comprehensive-guide\/\">Send a Telegram message with the API<\/a><br \/>\n        <a href=\"\/telegram-bot-api-vs-telegram-api\/\">Telegram Bot API vs Telegram API<\/a><br \/>\n        <a href=\"\/communication-api\/messaging-api\/telegram-api\/\">Unipile Telegram API product page<\/a>\n      <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/div>\n<p><script>\n(function(){\n  var root = document.getElementById('unipile-typ-cta');\n  if (!root) return;\n  root.addEventListener('click', function(e){\n    var el = e.target.closest('[data-upl-link]');\n    if (!el || !root.contains(el)) return;\n    e.preventDefault();\n    window.open(el.getAttribute('data-upl-link'), el.getAttribute('data-upl-target') || '_blank');\n  });\n})();\n<\/script><\/p>\n<p>[\/et_pb_code]<br \/>\n[\/et_pb_column]<br \/>\n[\/et_pb_row]<br \/>\n[\/et_pb_section]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Code Tutorial The Python Telegram Bot API with requests The most direct way to call the Telegram Bot API in Python is a plain HTTP call with requests, no wrapper library involved. As of Bot API 10.2 (July 14, 2026), a bot token from BotFather and two parameters are all that sendMessage requires. 1 Get [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"on","_et_pb_old_content":"","_et_gb_content_width":"","inline_featured_image":false,"footnotes":""},"categories":[69],"tags":[],"post_folder":[],"class_list":["post-279750","post","type-post","status-publish","format-standard","hentry","category-api-guidelines"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Telegram API with Python: Bot API, MTProto and Linked Accounts - Unipile<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.unipile.com\/it\/telegram-api-python\/\" \/>\n<meta property=\"og:locale\" content=\"it_IT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Telegram API with Python: Bot API, MTProto and Linked Accounts - Unipile\" \/>\n<meta property=\"og:description\" content=\"Code Tutorial The Python Telegram Bot API with requests The most direct way to call the Telegram Bot API in Python is a plain HTTP call with requests, no wrapper library involved. As of Bot API 10.2 (July 14, 2026), a bot token from BotFather and two parameters are all that sendMessage requires. 1 Get [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.unipile.com\/it\/telegram-api-python\/\" \/>\n<meta property=\"og:site_name\" content=\"Unipile\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/unipilefr\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-13T08:55:26+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-08-13T13:20:54+00:00\" \/>\n<meta name=\"author\" content=\"Damien Girardeau\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@UnipileAPI\" \/>\n<meta name=\"twitter:site\" content=\"@UnipileAPI\" \/>\n<meta name=\"twitter:label1\" content=\"Scritto da\" \/>\n\t<meta name=\"twitter:data1\" content=\"Damien Girardeau\" \/>\n\t<meta name=\"twitter:label2\" content=\"Tempo di lettura stimato\" \/>\n\t<meta name=\"twitter:data2\" content=\"18 minuti\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.unipile.com\\\/telegram-api-python\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.unipile.com\\\/telegram-api-python\\\/\"},\"author\":{\"name\":\"Damien Girardeau\",\"@id\":\"https:\\\/\\\/www.unipile.com\\\/#\\\/schema\\\/person\\\/a2ac44e22bdc27d497ce8b58716a673e\"},\"headline\":\"Telegram API with Python: Bot API, MTProto and Linked Accounts\",\"datePublished\":\"2026-08-13T08:55:26+00:00\",\"dateModified\":\"2026-08-13T13:20:54+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.unipile.com\\\/telegram-api-python\\\/\"},\"wordCount\":3092,\"publisher\":{\"@id\":\"https:\\\/\\\/www.unipile.com\\\/#organization\"},\"articleSection\":[\"API Guidelines\"],\"inLanguage\":\"it-IT\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.unipile.com\\\/telegram-api-python\\\/\",\"url\":\"https:\\\/\\\/www.unipile.com\\\/telegram-api-python\\\/\",\"name\":\"Telegram API with Python: Bot API, MTProto and Linked Accounts - Unipile\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.unipile.com\\\/#website\"},\"datePublished\":\"2026-08-13T08:55:26+00:00\",\"dateModified\":\"2026-08-13T13:20:54+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.unipile.com\\\/telegram-api-python\\\/#breadcrumb\"},\"inLanguage\":\"it-IT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.unipile.com\\\/telegram-api-python\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.unipile.com\\\/telegram-api-python\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Accueil\",\"item\":\"https:\\\/\\\/www.unipile.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Telegram API with Python: Bot API, MTProto and Linked Accounts\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.unipile.com\\\/#website\",\"url\":\"https:\\\/\\\/www.unipile.com\\\/\",\"name\":\"Unipile\",\"description\":\"Integrate Messaging &amp; Email, Connect with Ease via API\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.unipile.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.unipile.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"it-IT\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.unipile.com\\\/#organization\",\"name\":\"Unipile\",\"url\":\"https:\\\/\\\/www.unipile.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"it-IT\",\"@id\":\"https:\\\/\\\/www.unipile.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.unipile.com\\\/wp-content\\\/uploads\\\/2021\\\/05\\\/logo-unipile.png\",\"contentUrl\":\"https:\\\/\\\/www.unipile.com\\\/wp-content\\\/uploads\\\/2021\\\/05\\\/logo-unipile.png\",\"width\":200,\"height\":49,\"caption\":\"Unipile\"},\"image\":{\"@id\":\"https:\\\/\\\/www.unipile.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/unipilefr\",\"https:\\\/\\\/x.com\\\/UnipileAPI\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/unipile\\\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.unipile.com\\\/#\\\/schema\\\/person\\\/a2ac44e22bdc27d497ce8b58716a673e\",\"name\":\"Damien Girardeau\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"it-IT\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/12dd140720736a8db29f540c42a17d2680cd54a04fb26bb7b55423c179b065a9?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/12dd140720736a8db29f540c42a17d2680cd54a04fb26bb7b55423c179b065a9?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/12dd140720736a8db29f540c42a17d2680cd54a04fb26bb7b55423c179b065a9?s=96&d=mm&r=g\",\"caption\":\"Damien Girardeau\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Telegram API with Python: Bot API, MTProto and Linked Accounts - Unipile","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.unipile.com\/it\/telegram-api-python\/","og_locale":"it_IT","og_type":"article","og_title":"Telegram API with Python: Bot API, MTProto and Linked Accounts - Unipile","og_description":"Code Tutorial The Python Telegram Bot API with requests The most direct way to call the Telegram Bot API in Python is a plain HTTP call with requests, no wrapper library involved. As of Bot API 10.2 (July 14, 2026), a bot token from BotFather and two parameters are all that sendMessage requires. 1 Get [&hellip;]","og_url":"https:\/\/www.unipile.com\/it\/telegram-api-python\/","og_site_name":"Unipile","article_publisher":"https:\/\/www.facebook.com\/unipilefr","article_published_time":"2026-08-13T08:55:26+00:00","article_modified_time":"2026-08-13T13:20:54+00:00","author":"Damien Girardeau","twitter_card":"summary_large_image","twitter_creator":"@UnipileAPI","twitter_site":"@UnipileAPI","twitter_misc":{"Scritto da":"Damien Girardeau","Tempo di lettura stimato":"18 minuti"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.unipile.com\/telegram-api-python\/#article","isPartOf":{"@id":"https:\/\/www.unipile.com\/telegram-api-python\/"},"author":{"name":"Damien Girardeau","@id":"https:\/\/www.unipile.com\/#\/schema\/person\/a2ac44e22bdc27d497ce8b58716a673e"},"headline":"Telegram API with Python: Bot API, MTProto and Linked Accounts","datePublished":"2026-08-13T08:55:26+00:00","dateModified":"2026-08-13T13:20:54+00:00","mainEntityOfPage":{"@id":"https:\/\/www.unipile.com\/telegram-api-python\/"},"wordCount":3092,"publisher":{"@id":"https:\/\/www.unipile.com\/#organization"},"articleSection":["API Guidelines"],"inLanguage":"it-IT"},{"@type":"WebPage","@id":"https:\/\/www.unipile.com\/telegram-api-python\/","url":"https:\/\/www.unipile.com\/telegram-api-python\/","name":"Telegram API with Python: Bot API, MTProto and Linked Accounts - Unipile","isPartOf":{"@id":"https:\/\/www.unipile.com\/#website"},"datePublished":"2026-08-13T08:55:26+00:00","dateModified":"2026-08-13T13:20:54+00:00","breadcrumb":{"@id":"https:\/\/www.unipile.com\/telegram-api-python\/#breadcrumb"},"inLanguage":"it-IT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.unipile.com\/telegram-api-python\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.unipile.com\/telegram-api-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Accueil","item":"https:\/\/www.unipile.com\/"},{"@type":"ListItem","position":2,"name":"Telegram API with Python: Bot API, MTProto and Linked Accounts"}]},{"@type":"WebSite","@id":"https:\/\/www.unipile.com\/#website","url":"https:\/\/www.unipile.com\/","name":"Unipile","description":"Integrazione di messaggistica ed e-mail, connessione semplice tramite API","publisher":{"@id":"https:\/\/www.unipile.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.unipile.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"it-IT"},{"@type":"Organization","@id":"https:\/\/www.unipile.com\/#organization","name":"Unipile","url":"https:\/\/www.unipile.com\/","logo":{"@type":"ImageObject","inLanguage":"it-IT","@id":"https:\/\/www.unipile.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.unipile.com\/wp-content\/uploads\/2021\/05\/logo-unipile.png","contentUrl":"https:\/\/www.unipile.com\/wp-content\/uploads\/2021\/05\/logo-unipile.png","width":200,"height":49,"caption":"Unipile"},"image":{"@id":"https:\/\/www.unipile.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/unipilefr","https:\/\/x.com\/UnipileAPI","https:\/\/www.linkedin.com\/company\/unipile\/"]},{"@type":"Person","@id":"https:\/\/www.unipile.com\/#\/schema\/person\/a2ac44e22bdc27d497ce8b58716a673e","name":"Damien Girardeau","image":{"@type":"ImageObject","inLanguage":"it-IT","@id":"https:\/\/secure.gravatar.com\/avatar\/12dd140720736a8db29f540c42a17d2680cd54a04fb26bb7b55423c179b065a9?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/12dd140720736a8db29f540c42a17d2680cd54a04fb26bb7b55423c179b065a9?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/12dd140720736a8db29f540c42a17d2680cd54a04fb26bb7b55423c179b065a9?s=96&d=mm&r=g","caption":"Damien Girardeau"}}]}},"_links":{"self":[{"href":"https:\/\/www.unipile.com\/it\/wp-json\/wp\/v2\/posts\/279750","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.unipile.com\/it\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.unipile.com\/it\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.unipile.com\/it\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.unipile.com\/it\/wp-json\/wp\/v2\/comments?post=279750"}],"version-history":[{"count":2,"href":"https:\/\/www.unipile.com\/it\/wp-json\/wp\/v2\/posts\/279750\/revisions"}],"predecessor-version":[{"id":279769,"href":"https:\/\/www.unipile.com\/it\/wp-json\/wp\/v2\/posts\/279750\/revisions\/279769"}],"wp:attachment":[{"href":"https:\/\/www.unipile.com\/it\/wp-json\/wp\/v2\/media?parent=279750"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.unipile.com\/it\/wp-json\/wp\/v2\/categories?post=279750"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.unipile.com\/it\/wp-json\/wp\/v2\/tags?post=279750"},{"taxonomy":"post_folder","embeddable":true,"href":"https:\/\/www.unipile.com\/it\/wp-json\/wp\/v2\/post_folder?post=279750"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}