- 
                Notifications
    You must be signed in to change notification settings 
- Fork 0
Local Bot API Server
        Bibo-Joshi edited this page Jan 15, 2021 
        ·
        10 revisions
      
    Since Bot API 5.0, Telegram made the Bot API server open source, allowing you to host your own instance. For details on what benefits hosting your own instance has and how it works, please see the official docs.
Bot API 5.0 (and therefore local API server) is supported by PTB since v13.1.
- Before you can move your bot from the official server cloud to a self hosted server, you need to call the log_outmethod.
- Before moving from one self hosted instance to another, you need to use the delete_webhookandclosemethods.
- To make PTB aware that you're not using the official server, pass the following to your Updater(orBot):- base_url='your-bot-api-server.com/bot'
 
- If you are running a local bot API server without the --localflag, also pass:- base_file_url='your-bot-api-server.com/file/bot'
 
- When running the server with the --localflag,get_filewill give you the local file path asfile_path. PTB detects that, so thatget_file(…).download()just returns the local file string instead of downloading it.
- When running the server with the --localflag, you can send files by passing'file:///absolute/path/to/file'instead of an URL or a file handler. Skipping the'file://'prefix, passing relative paths (without prefix) or even passingpathlib.Pathobjects is supported as well as a convenience feature by PTB.
- When running the server without the --localflag, the Bot API server does not automatically serve the files obtained byget_file(). See telegram-bot-api/#26. So be aware that you have to run a web server which serves them, otherwise you will run into 404 errors.
- Wiki of python-telegram-bot© Copyright 2015-2025 – Licensed by Creative Commons
- Architecture Overview
- Builder Pattern for Application
- Types of Handlers
- Working with Files and Media
- Exceptions, Warnings and Logging
- Concurrency in PTB
- Advanced Filters
- Storing data
- Making your bot persistent
- Adding Defaults
- Job Queue
- Arbitrary callback_data
- Avoiding flood limits
- Webhooks
- Bot API Forward Compatiblity
- Frequently requested design patterns
- Code snippets
- Performance Optimizations
- Telegram Passport
- Bots built with PTB
- Automated Bot Tests