Trading API
This page explains how Toxi Bot /sell and /buy commands can be integrated into your application
Single-line /buy and /sell commands
/buy and /sell commandsAll of the automation capabilities shown on this page are based on the newly implemented /buy and /sellcommands. Here is how they work:
/buy command
/buy commandTo execute a Buy trade you should simple send the message in the following format to the bot:
/buy <token> <amount>Example:
/buy 6p6xgHyF7AeE6TZkSmFsko444wqoP15icUSqi2jfGiPN 0.01The following command will execute a buy trade of $TRUMP token for 0.01 SOL . Here is the output you will see from the bot:

/sell command
/sell commandExecuting a /sell trade is almost identical to the buy, and here is how it looks like:
Example
The following command will execute a sell trade of $TRUMP and sell 20%of your total $TRUMP balance. Here is the output you will see from the bot:

Accessing commands within your app
In order to be able to access Toxi Bot trading capabilities, you'd need to send /buy and /sell commands from your application. Since Toxi Bot is a telegram-based trading bot, you'd need to use a telegram-client library (the exact name depends on the programming language you're working with) that communicates with telegram servers via MTProto (the protocol developed by the telegram team specifically for telegram).
Simply put, you'll interact with Toxi Bot like you always do, but instead of typing commands manually, you'll do it programatically via MTProto methods. Your program will use the same account you're using in your desktop/mobile Telgram, it'll be able to do everything you do manually in your Telegram app automatically via the set of instructions you're using in your program.
Now that we understand the theory behind telegram clients, lets outline a language-agnostic approach of building such telegram client:
Obtain
api_idandapi_hash. Follow the set instruction on how to create your telegram api application: https://core.telegram.org/api/obtaining_api_id. After you've completed all the steps, you'll getapi_idandapi_hashparameters necessary to authorize your telegram-client.Create a new telegram session that will be used only within your application. This step depends on the library/package you're using, but normally you'd have to specify your phone number and 2fa password (if 2fa is enabled) and receive a code from telegram needed to create a new session. The session needs to be created to authorize your telegram-client to act on behalf of your telegram account.
After the session is created, it's generally recommended that you save it on your computer to reuse it in your program. This way you can avoid completing step 2 each time you start your program, thus you'll save your time and nerves xD. The session itself is just a encoded string with session data stored in it.
Once you're session is created and your telegram-client is finally authorized, you can do whatever you want on behalf of your telegram account, including sending
/buyand/sellcommands to the Toxi Bot, which is the main purpose of this guide.Congrats 🎉
In this next sub-pages of this guide you'll find a complete integration examples for both TypeScript and Python programming languages
Last updated