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 - if authData is not provided

  • tradingError :

    • if nft_id is not provided

    • if price <= 0 or price isn't int or float

  • requestError - if request fails

Parameters

  • authData (str) - authentication data required for the api request

  • nft_id (str) - id of the nft to buy

  • price (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