Withdrawal API using python

Hi Team,

i want to build a python code to transfer USDT to an address using TRON network.

in the docs, below is the code given as example:

“”"
import logging
from binance.spot import Spot as Client
from binance.lib.utils import config_logging

config_logging(logging, logging.DEBUG)
key = “”
secret = “”
spot_client = Client(key, secret, show_header=True)
logging.info(spot_client.withdraw(coin=“BNB”, amount=0.01, address=""))

please advise how to proceed.

thanks in advance
Sukhwant

Hi,

To withdraw assets out of Binance Spot account have a look at the Withdraw endpoint API documentation

You might also need the All Coin Information endpoint for network specific variables.

import logging
from binance.spot import Spot as Client
from binance.lib.utils import config_logging
import pandas as pd

config_logging(logging, logging.DEBUG)

key = “your key”
secret = “your secret key”

coinname = ‘USDT’

spot_client = Client(key, secret)
a = spot_client.account_snapshot(type =“SPOT”)
df = pd.json_normalize(a,“snapshotVos”, meta=[“msg”,“code”])

i am using the above code to fetch the current wallet positions on USDT coin. i am observing that by running this code, the data is not showing correct information. like i moved 10 USDT to spot wallet on the web and when i run this code after 2 minutes, its still not showing 10 USDT by using this code.

please advise on this.

Can i get a running code to trasnfer USDT to an external address via TROn network? i went through the documents but could not figure out how to proceed. i am new to python language and api concept.

thanks in advance
Sukhwant

AccountSnapshot endpoint provides snapshots at a 24hr frequency, meaning the data you are querying is stale. This can be confirmed by checking the updateTime parameter.

To get a list of open positions on your Spot account, use the Account Information endpoint

@tantialex - thanks for the suggestion on using Account to get live spot balances from the wallet. it works fine now.

But still i read the document on transfers and still would appreciate if you can provide an example link of running code to do withdrawals where one can use Tron as a network to transfer:

got this from github of binance:
logging.info(spot_client.withdraw(coin=“BNB”, amount=0.01, address=""))

so if we do this, will it work:
logging.info(spot_client.withdraw(coin=“USDT”, amount=0.01, address="", network=“TRON”))

please confirm

thanks
Sukhwant

Tron’s network handle is TRX not TRON. The rest should be sufficient apart from the missing address.

EDIT: You have come to the same conclusion in the message below. My apologies for the confusion.

@tantialex

the withdrawal code works fine:
logging.info(spot_client.withdraw(coin=“USDT”, amount=10, address="", network=“TRX”))

appreciate your guidance in the above … thanks again

have a different question: was going through documents and came across:
Enable Fast Withdraw Switch (USER_DATA)
Does this mean we can do withdrawals from binance wallet to external wallets faster than normal?

await your response

thanks
Sukhwant

Fast withdraw is only applicable to Binance accounts, not external accounts.

When Fast Withdraw Switch is on, transferring funds to a Binance account will be done instantly. There is no on-chain transaction, no transaction ID and no withdrawal fee.