Toxi
  • Welcome to Toxi
    • 👋 Welcome to Toxi!
    • Fast Links
  • Toxi Integration (API)
    • Trading API
      • TypeScript Example
      • Python Example
    • Data API
  • What is Toxi
    • What is Toxi and how it works
    • Core Features of Toxi
  • Getting Started with Toxi
    • Depositing $SOL into your Wallet
    • Funding Your Toxi Wallet
    • Make your first trade
    • Set up first copytrading wallet
  • Trading on Toxi
    • Basic Trading
    • Portfolio Management
    • Managing Positions
  • Copytrading
    • Understanding Copy Trading
    • Setting Up Copy Trading
    • Managing and Adjusting Copy Trades
  • Settings
    • Settings
  • Security & Self-Custody
    • Security & Self-Custody
    • Self-Custodial Wallets
    • Private Key Encryption
    • Security Tips for Using Toxi
  • Referral Program
    • Referral Program
    • How to Earn with Toxi Referrals
    • Tracking Referral Earnings
    • Referral Rewards and Fees
  • FAQ
    • FAQ
Powered by GitBook
On this page
  • Single-line /buy and /sell commands
  • /buy command
  • /sell command
  • Accessing commands within your app
  1. Toxi Integration (API)

Trading API

This page explains how Toxi Bot /sell and /buy commands can be integrated into your application

PreviousFast LinksNextTypeScript Example

Last updated 2 months ago

We DO NOT provide any assistance or support on creating your own trading bots. Everything shown in this page is only an example of how to integrate Toxi Bot trading capabilities into your own application. So please, do not seek software engineering advices from our support managers. Thank you!

Single-line /buy and /sell commands

All of the automation capabilities shown on this page are based on the newly implemented /buy and /sellcommands. Here is how they work:

/buy command

To execute a Buy trade you should simple send the message in the following format to the bot:

/buy <token> <amount>

Example:

/buy 6p6xgHyF7AeE6TZkSmFsko444wqoP15icUSqi2jfGiPN 0.01

The following command will execute a buy trade of token for 0.01 SOL . Here is the output you will see from the bot:

/sell command

Executing a /sell trade is almost identical to the buy, and here is how it looks like:

/sell <token> <amount>%

Example

/sell 6p6xgHyF7AeE6TZkSmFsko444wqoP15icUSqi2jfGiPN 20%

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.

Do not get confused by thinking that Telegram Bot API and telegram-client are the same thing. Telegram Bot API is an easy-to-use interface for creating telegram bots. What you're building is a telegram client application that will be used to communicate with a telegram bot, you're not building a telegram bot itself.

Now that we understand the theory behind telegram clients, lets outline a language-agnostic approach of building such telegram client:

  1. 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.

  2. 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.

  3. 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 /buy and /sell commands to the Toxi Bot, which is the main purpose of this guide.

  4. Congrats 🎉

In this next sub-pages of this guide you'll find a complete integration examples for both TypeScript and Python programming languages

The following command will execute a sell trade of and sell 20%of your total $TRUMP balance. Here is the output you will see from the bot:

Obtain api_id and api_hash . Follow the set instruction on how to create your telegram api application: . After you've completed all the steps, you'll get api_id and api_hash parameters necessary to authorize your telegram-client.

$TRUMP
https://core.telegram.org/api/obtaining_api_id
$TRUMP
Example of a BUY Trade flow
Example of a SELL Trade flow