buy
buy()
async def buy(nft_id: str, price: int|float, authData: str) -> None
Buy a gift with a known nft_id and price
Returns
None
Raises
authDataError
- ifauthData
is not providedtradingError
:if
nft_id
is not providedif
price <= 0
orprice
isn'tint
orfloat
requestError
- if request fails
Parameters
authData
(str) - authentication data required for the api requestnft_id
(str) - id of the nft to buyprice
(int | float) - price of the nft to buy
Example
Buy first gift from all gifts with sort "price ascending"
from aportalsmp.gifts import search, buy
from aportalsmp.auth import update_auth
import asyncio
auth = asyncio.run(update_auth(api_id=123, api_hash="..."))
async def main():
gift = (await search(sort="price_asc", authData=auth))[0]
print(buy(nft_id=gift.id, price=gift.price, authData=auth))
# will print None if the gift has been bought successfully
See used functions: update_auth, search
Last updated